autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awk for config headers


From: Eric Blake
Subject: Re: awk for config headers
Date: Fri, 12 Oct 2007 16:38:43 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de> writes:

> +m4_define([_AC_OUTPUT_HEADERS_PREPARE],
> +[# Set up the scripts for CONFIG_HEADERS section.
> +# No need to generate them if there are no CONFIG_HEADERS.
> +# This happens for instance with `./config.status Makefile'.
> +if test -n "$CONFIG_HEADERS"; then
> +cat >"$tmp/defines.awk" <<\_CEOF

Sorry for not noticing this sooner, but I think we should be namespace clean 
where possible.  Your patch introduced a delimiter outside of the _A[SCT][A-Z]* 
namespace used by all other autoconf here-docs.  I'm committing this followup:

From: Eric Blake <address@hidden>
Date: Fri, 12 Oct 2007 10:34:27 -0600
Subject: [PATCH] Namespace cleanup.

* lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE)
(_AC_OUTPUT_HEADERS_PREPARE): Convert here-doc delimiters into
autoconf namespace.
* doc/autoconf.texi (Programming in M4sugar, Forbidden Patterns)
(Programming in M4sh, Macro Names): Beef up description of
namespaces reserved for autoconf.
* configure: Regenerate.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog              |   11 ++++++++
 configure              |    8 +++---
 doc/autoconf.texi      |   61 ++++++++++++++++++++++++++++++++++++++---------
 lib/autoconf/status.m4 |   22 ++++++++--------
 4 files changed, 75 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2fc0a0b..c1d5c0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
 2007-10-12  Eric Blake  <address@hidden>
+
+       Namespace cleanup.
+       * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE)
+       (_AC_OUTPUT_HEADERS_PREPARE): Convert here-doc delimiters into
+       autoconf namespace.
+       * doc/autoconf.texi (Programming in M4sugar, Forbidden Patterns)
+       (Programming in M4sh, Macro Names): Beef up description of
+       namespaces reserved for autoconf.
+       * configure: Regenerate.
+
+2007-10-12  Eric Blake  <address@hidden>
        and Paolo Bonzini  <address@hidden>
 
        Speed up execution of subset of testsuite.
diff --git a/configure b/configure
index a7a7eb1..bccfc0a 100755
--- a/configure
+++ b/configure
@@ -3574,7 +3574,7 @@ done
 rm -f conf$$subs.sh
 
 cat >>$CONFIG_STATUS <<_ACEOF
-cat >>"\$tmp/subs1.awk" <<\CEOF
+cat >>"\$tmp/subs1.awk" <<\_ACAWK
 _ACEOF
 sed -n '
 h
@@ -3621,8 +3621,8 @@ t delim
 ' >>$CONFIG_STATUS
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF
-CEOF
-cat >>"\$tmp/subs1.awk" <<CEOF
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK
   for (key in S) S_is_set[key] = 1
   FS = ""
 
@@ -3647,7 +3647,7 @@ cat >>"\$tmp/subs1.awk" <<CEOF
   print line
 }
 
-CEOF
+_ACAWK
 sed "s/\$ac_cr\\\$//; s/\$ac_cr/\$ac_cs_awk_cr/g" < "\$tmp/subs1.awk" 
> "\$tmp/subs.awk"
 _ACEOF
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index faeb9fc..74295b6 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10073,6 +10073,10 @@ macros.  M4sugar introduces additional generic 
macros.  Its name was
 coined by Lars J. Aas: ``Readability And Greater Understanding Stands 4
 M4sugar''.
 
+M4sugar reserves the macro namespace @samp{^_m4_} for internal use, and
+the macro namespace @samp{^m4_} for M4sugar macros.  You should not
+define your own macros into these namespaces.
+
 @menu
 * Redefined M4 Macros::         M4 builtins changed in M4sugar
 * Conditional constructs::      Conditions in M4
@@ -10554,7 +10558,9 @@ instance, if an Autoconf @file{configure} script 
includes tokens such as
 @samp{AC_DEFINE}, or @samp{dnl}, then most probably something went
 wrong (typically a macro was not evaluated because of overquotation).
 
-M4sugar forbids all the tokens matching @samp{^m4_} and @samp{^dnl$}.
+M4sugar forbids all the tokens matching @samp{^_?m4_} and @samp{^dnl$}.
+Additional layers, such as M4sh and Autoconf, add additional forbidden
+patterns to the list.
 
 @defmac m4_pattern_forbid (@var{pattern})
 @msindex{pattern_forbid}
@@ -10563,8 +10569,9 @@ Comments are not checked; this can be a problem if, for 
instance, you
 have some macro left unexpanded after an @samp{#include}.  No consensus
 is currently found in the Autoconf community, as some people consider it
 should be valid to name macros in comments (which doesn't make sense to
-the author of this documentation, as @samp{#}-comments should document
-the output, not the input, documented by @samp{dnl} comments).
+the authors of this documentation: input, such as macros, should be
+documented by @samp{dnl} comments; reserving @samp{#}-comments to
+document the output).
 @end defmac
 
 Of course, you might encounter exceptions to these generic rules, for
@@ -10606,6 +10613,13 @@ A mess; trouble.  [Obs.] --Beau.@: & Fl.
 
 For the time being, it is not mature enough to be widely used.
 
+M4sh reserves the M4 macro namespace @samp{^_AS_} for internal use, and
+the namespace @samp{^AS_} for M4sh macros.  It also reserves the shell
+and environment variable namespace @samp{^as_}, and the here-doc
+delimiter namespace @samp{^_AS[A-Z]} in the output file.  You should not
+define your own macros or output shell code that conflicts with these
+namespaces.
+
 M4sh provides portable alternatives for some common shell constructs
 that unfortunately are not portable in practice.
 
@@ -10851,14 +10865,36 @@ that produce no output, such as @code{AC_REQUIRE}.
 @node Macro Names
 @section Macro Names
 
-All of the Autoconf macros have all-uppercase names starting with
address@hidden to prevent them from accidentally conflicting with other
-text.  All shell variables that they use for internal purposes have
-mostly-lowercase names starting with @samp{ac_}.  To ensure that your
-macros don't conflict with present or future Autoconf macros, you should
-prefix your own macro names and any shell variables they use with some
-other sequence.  Possibilities include your initials, or an abbreviation
-for the name of your organization or software package.
+All of the public Autoconf macros have all-uppercase names in the
+namespace @samp{^AC_} to prevent them from accidentally conflicting with
+other text; Autoconf also reserves the namespace @samp{^_AC_} for
+internal macros.  All shell variables that they use for internal
+purposes have mostly-lowercase names starting with @samp{ac_}.  Autoconf
+also uses here-doc delimiters in the namespace @samp{^_AC[A-Z]}.  During
address@hidden, files produced by Autoconf make heavy use of the
+file system namespace @samp{^conf}.
+
+Since Autoconf is built on top of M4sugar (@pxref{Programming in
+M4sugar}) and M4sh (@pxref{Programming in M4sh}), you must also be aware
+of those namespaces (@samp{^_?\(m4\|AS\)_}).  And since
address@hidden is also designed to be scanned by Autoheader,
+Autoscan, Autoupdate, and Automake, you should be aware of the
address@hidden namespaces.  In general, you @emph{should not use}
+the namespace of a package that does not own the macro or shell code you
+are writing.
+
+To ensure that your macros don't conflict with present or future
+Autoconf macros, you should prefix your own macro names and any shell
+variables they use with some other sequence.  Possibilities include your
+initials, or an abbreviation for the name of your organization or
+software package.  Historically, people have not always followed the
+rule of using a namespace appropriate for their package, and this has
+made it difficult for determining the origin of a macro (and where to
+report bugs about that macro), as well as difficult for the true
+namespace owner to add new macros without interference from pre-existing
+uses of third-party macros.  Perhaps the best example of this confusion
+is the @code{AM_GNU_GETTEXT} macro, which belongs, not to Automake, but
+to Gettext.
 
 Most of the Autoconf macros' names follow a structured naming convention
 that indicates the kind of feature check by the name.  The macro names
@@ -10867,7 +10903,8 @@ general to most specific.  The names of their cache 
variables use the
 same convention (@pxref{Cache Variable Names}, for more information on
 them).
 
-The first word of the name after @samp{AC_} usually tells the category
+The first word of the name after the namepace initials (such as
address@hidden) usually tells the category
 of the feature being tested.  Here are the categories used in Autoconf for
 specific test macros, the kind of macro that you are more likely to
 write.  They are also used for cache variables, in all-lowercase.  Use
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index 0c00af2..1511aae 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -387,9 +387,9 @@ m4_ifdef([_AC_SUBST_FILES],
 [# Create commands to substitute file output variables.
 {
   echo "cat >>$CONFIG_STATUS <<_ACEOF"
-  echo 'cat >>"\$tmp/subs1.awk" <<\CEOF'
+  echo 'cat >>"\$tmp/subs1.awk" <<\_ACAWK'
   echo "$ac_subst_files" | sed 's/.*/F@<:@"&"@:>@="$&"/'
-  echo "CEOF"
+  echo "_ACAWK"
   echo "_ACEOF"
 } >conf$$files.sh
 . ./conf$$files.sh
@@ -444,7 +444,7 @@ dnl - Writing `$ 0' prevents expansion by both the shell 
and m4 here.
 dnl
 dnl m4-double-quote most of the scripting for readability.
 [cat >>$CONFIG_STATUS <<_ACEOF
-cat >>"\$tmp/subs1.awk" <<\CEOF
+cat >>"\$tmp/subs1.awk" <<\_ACAWK
 _ACEOF
 sed -n '
 h
@@ -491,8 +491,8 @@ t delim
 ' >>$CONFIG_STATUS
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF
-CEOF
-cat >>"\$tmp/subs1.awk" <<CEOF
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK
   for (key in S) S_is_set[key] = 1
   FS = ""
 ]m4_ifdef([_AC_SUBST_FILES],
@@ -526,7 +526,7 @@ cat >>"\$tmp/subs1.awk" <<CEOF
 }
 ]m4_ifdef([_AC_SUBST_FILES],
 [\$ac_cs_awk_pipe_fini])[
-CEOF
+_ACAWK
 sed "s/\$ac_cr\\\$//; s/\$ac_cr/\$ac_cs_awk_cr/g" < "\$tmp/subs1.awk" 
> "\$tmp/subs.awk"
 _ACEOF
 ]dnl end of double-quoted part
@@ -586,13 +586,13 @@ m4_ifndef([AC_DATAROOTDIR_CHECKED],
 # FIXME: This hack should be removed a few years after 2.60.
 ac_datarootdir_hack=; ac_datarootdir_seen=
 m4_define([_AC_datarootdir_vars],
-          [datadir, docdir, infodir, localedir, mandir])
+         [datadir, docdir, infodir, localedir, mandir])
 case `sed -n '/datarootdir/ {
   p
   q
 }
 m4_foreach([_AC_Var], m4_defn([_AC_datarootdir_vars]),
-           [/@_AC_Var@/p
+          [/@_AC_Var@/p
 ])' $ac_file_inputs` in
 *datarootdir*) ac_datarootdir_seen=yes;;
 address@hidden(address@hidden|address@hidden, _AC_datarootdir_vars)@*)
@@ -601,7 +601,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
   ac_datarootdir_hack='
   m4_foreach([_AC_Var], m4_defn([_AC_datarootdir_vars]),
-               [s&@_AC_Var@&$_AC_Var&g
+              [s&@_AC_Var@&$_AC_Var&g
   ])dnl
   s&\\\${datarootdir}&$datarootdir&g' ;;
 esac
@@ -688,7 +688,7 @@ m4_define([_AC_OUTPUT_HEADERS_PREPARE],
 # No need to generate them if there are no CONFIG_HEADERS.
 # This happens for instance with `./config.status Makefile'.
 if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_CEOF
+cat >"$tmp/defines.awk" <<\_ACAWK
 BEGIN {
 _ACEOF
 
@@ -807,7 +807,7 @@ cat >>$CONFIG_STATUS <<_ACEOF
 }
 { print }
 ]dnl End of double-quoted section
-_CEOF
+_ACAWK
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF
-- 
1.5.3.2







reply via email to

[Prev in Thread] Current Thread [Next in Thread]