Be ready to handle filenames as stupid as `dnl.at', for if even

the maintainer is dumb enough to do that...
* lib/autotest/general.m4 (AT_SETUP, AT_LINE): Demonstrates your
excellence in M4 quotation: consider `__file__' is active.
And BTW, when invoking m4, pass the --include in the right order:
the wrong one.
* bin/autom4te.in, bin/autoupdate.in: Use reverse when kingtal to
4m.
This commit is contained in:
Akim Demaille 2001-09-05 07:06:58 +00:00
parent d134e3aa8d
commit 7d6abb82f3
4 changed files with 39 additions and 8 deletions

View File

@ -1,3 +1,17 @@
2001-09-05 Akim Demaille <akim@epita.fr>
Be ready to handle filenames as stupid as `dnl.at', for if even
the maintainer is dumb enough to do that...
* lib/autotest/general.m4 (AT_SETUP, AT_LINE): Demonstrates your
excellence in M4 quotation: consider `__file__' is active.
And BTW, when invoking m4, pass the --include in the right order:
the wrong one.
* bin/autom4te.in, bin/autoupdate.in: Use reverse when kingtal to
4m.
2001-09-05 Akim Demaille <akim@epita.fr>
* lib/Autom4te/XFile.pm: New lib file.

View File

@ -572,12 +572,14 @@ sub handle_m4 ($@)
unlink ($tcache . $req->id);
# Run m4.
# Be extremely cautious to reverse the includes when talking to M4:
# it doesn't speak the same --include as we do.
my $command = ("$m4"
. " --define m4_warnings=$m4_warnings"
. join (' --include=', '', reverse @include)
. " --define=m4_warnings=$m4_warnings"
. ' --debug=aflq'
. " --error-output=$tcache" . $req->id
. join (' --trace=', '', sort @macro)
. join (' --include=', '', @include)
. $files
. " >$ocache" . $req->id);
verbose "running: $command";

View File

@ -380,8 +380,9 @@ EOF
or die "$me: cannot close $tmp/input.m4: $!\n";
# Now ask m4 to perform the update.
# M4 and I don't agree on the associativity of `--include': reverse!
xsystem ("$m4"
. join (' --include=', '', @include, $tmp)
. join (' --include=', '', reverse (@include, $tmp))
. " $tmp/input.m4 >$tmp/updated");
update_file ("$tmp/updated",
"$file" eq "$tmp/stdin" ? '-' : "$file");

View File

@ -71,9 +71,23 @@ m4_define([_m4_divert(TAIL)], 60)
# AT_LINE
# -------
# Return the current file sans directory, a colon, and the current line.
# Return the current file sans directory, a colon, and the current
# line. Be sure to return a _quoted_ filename, so if, for instance,
# the user is lunatic enough to have a file named `dnl' (and I, for
# one, love to be brainless and stubborn sometimes), then we return a
# quoted name.
#
# Gee, we can't use simply
#
# m4_patsubst(__file__, [^.*/\(.*\)], [[\1]])
#
# since then, since `dnl' doesn't match the pattern, it is returned
# with once quotation level less, so you lose, dammit! And since GNU M4
# is one of the biggest junk in the whole universe wrt regexp, don't
# even think about using `?' or `\?'. Bah, `*' will do.
# Pleeeeeeeease, Gary, provide us with dirname and ERE!
m4_define([AT_LINE],
[m4_patsubst(__file__, ^.*/\(.*\), \1):__line__])
[m4_patsubst(__file__, [^\(.*/\)*\(.*\)], [[\2]]):__line__])
# AT_INIT(PROGRAM)
@ -496,12 +510,12 @@ m4_define([AT_SETUP],
[m4_define([AT_ordinal], m4_incr(AT_ordinal))
m4_append([AT_TESTS_ALL], [ ]m4_defn([AT_ordinal]))
m4_divert_text([HELP],
[m4_format([ %3d: %-15s %s], AT_ordinal, AT_LINE, [$1])])
[m4_format([[ %3d: %-15s %s]], AT_ordinal, AT_LINE, [$1])])
m4_divert_push([TESTS])dnl
AT_ordinal ) [#] AT_ordinal. AT_LINE: $1
AT_ordinal ) @%:@ AT_ordinal. AT_LINE: $1
at_setup_line='AT_LINE'
$at_verbose "AT_ordinal. $srcdir/AT_LINE: testing $1..."
$at_quiet $at_n "m4_format([%3d: %-18s], AT_ordinal, AT_LINE)[]$at_c"
$at_quiet $at_n "m4_format([[%3d: %-18s]], AT_ordinal, AT_LINE)[]$at_c"
(
$at_traceon
])