Eric Blake <ebb9 <at> byu.net> writes:

> Good idea.  Here's what I'm committing; differences from the previous 
proposal 
> include a more thorough testsuite, falling back to here-docs if the string 
> contains a \, and a slicker choice of $1 to invoke an appropriate callback 
> routine.

I'm delaying the commit just a bit longer, due to one more modification needed 
to pass the testsuite.  It turns out that m4_expand([#]) doesn't recognize the 
end-of-comment; you have to call m4_expand([[#]]) or m4_expand([EMAIL 
PROTECTED]:@]).  
fortran.m4 had a case of insufficient quoting, and I suspect other packages 
might as well.

I suppose it might be possible to make m4_expand tolerant of underquoted # (and 
also a trailing dnl), by having it append a newline prior to the alternate 
close-quote handed to _m4_expand, then stripping the newline after the fact, 
but it seems like a lot of overhead when the correct solution is to properly 
quote in the first place.  Not many people use # inside AC_DEFINE, in part 
because you have to use config.h instead of command line (after all, we 
document that passing # through AC_DEFINE tends to get eaten by Makefile).


diff --git a/NEWS b/NEWS
index d8cb06d..c10c446 100644
--- a/NEWS
+++ b/NEWS
@@ -45,7 +45,8 @@ GNU Autoconf NEWS - User visible changes.
 
 ** The autoconf macros AC_DEFINE and AC_DEFINE_UNQUOTED now output
    fewer blank lines.  This generally is not a problem, but changes
-   semantics for any users that did 'var=value AC_DEFINE(...)'.
+   semantics for any users that did 'var=value AC_DEFINE(...)'.  Also,
+   these macros are stricter at enforcing proper m4 quoting around #.
 
 
 * Major changes in Autoconf 2.63 (2008-09-09) [stable]
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 6743aa8..c1c4fc0 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -1032,25 +1032,25 @@ case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
   "lower case, no underscore, extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
-         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
+         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name [##] _]) ;;
   "lower case, underscore, no extra underscore")
-         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
-         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
+         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name [##] _])
+         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name [##] _]) ;;
   "lower case, underscore, extra underscore")
-         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
-         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
+         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name [##] _])
+         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name [##] __]) ;;
   "upper case, no underscore, no extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
          AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
   "upper case, no underscore, extra underscore")
          AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
-         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
+         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME [##] _]) ;;
   "upper case, underscore, no extra underscore")
-         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
-         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
+         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME [##] _])
+         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME [##] _]) ;;
   "upper case, underscore, extra underscore")
-         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
-         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
+         AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME [##] _])
+         AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME [##] __]) ;;
   *)
          AC_MSG_WARN([unknown Fortran name-mangling scheme])
          ;;




Reply via email to