From 7d6abb82f326a97e4eeac52bd58cc3f1e1af389a Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 5 Sep 2001 07:06:58 +0000 Subject: [PATCH] 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. --- ChangeLog | 14 ++++++++++++++ bin/autom4te.in | 6 ++++-- bin/autoupdate.in | 3 ++- lib/autotest/general.m4 | 24 +++++++++++++++++++----- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90388cf2..d433c96d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2001-09-05 Akim Demaille + + 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 * lib/Autom4te/XFile.pm: New lib file. diff --git a/bin/autom4te.in b/bin/autom4te.in index 152c4101..f10457ba 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -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"; diff --git a/bin/autoupdate.in b/bin/autoupdate.in index fc21a7ee..5bbf9797 100644 --- a/bin/autoupdate.in +++ b/bin/autoupdate.in @@ -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"); diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index 08e367ad..3a96202e 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -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 ])