autoconf-patches
[Top][All Lists]
Advanced

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

Re: m4_wrap behavior


From: Paul Eggert
Subject: Re: m4_wrap behavior
Date: Tue, 20 Jun 2006 12:53:32 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> There was also the question of whether m4sugar should reject calls to
> m4_wrap with multiple arguments, since that is not Posix-specified (GNU m4
> 1.4.x concatenates each argument together with a space, but traditional
> implementations only save the first argument).

Posix clearly specifies the traditional behavior: any args past the
first are ignored.  If GNU m4wrap is being changed to conform to
Posix, it should also ignore all but the first argument.  It could
issue a warning, for the same reason it warns about the excess
argument in "len(1,2)".

> A note - I've been trying to clean up m4, so that in its documentation, it
> is called 'm4' if it is the program, and 'GNU M4' if it is the package
> (similar to 'autoconf' vs. 'GNU Autoconf').  We ought to be consistent
> here, and call it GNU M4 2.0 or GNU M4 1.4.x.

OK, thanks.  I installed the following documentation patch, which
should address the above issues (and one or two others that I noticed).

2006-06-20  Paul Eggert  <address@hidden>

        * NEWS: Use "M4" rather than "m4" when appropriate.
        Problem reported by Eric Blake.
        * doc/autoconf.texi: Likewise.
        Use @acronym around BSD, GCC, and GNU when appropriate.
        (Why GNU M4): Renamed from "Why GNU m4".
        (Redefined M4 Macros): Mention that Posix
        m4wrap takes only 1 argument, but GNU M4 1.4.x takes more.
        (Buffer Overruns): Mention size_t and ptrdiff_t as alternatives
        to int.

--- NEWS        19 Jun 2006 23:12:17 -0000      1.382
+++ NEWS        20 Jun 2006 19:48:45 -0000
@@ -1,7 +1,7 @@
 * Major changes in Autoconf 2.59e
 
 ** Autoconf no longer depends on whether m4wrap is FIFO (as Posix requires)
-  or LIFO (as in GNU m4 1.4.x).  GNU m4 2.0 is expected to conform to Posix
+  or LIFO (as in GNU M4 1.4.x).  GNU M4 2.0 is expected to conform to Posix
   here, so m4wrap/m4_wrap users should no longer depend on LIFO behavior.
 
 * Major changes in Autoconf 2.59d
@@ -257,7 +257,7 @@
   especially useful for initial "bootstrapping" of fresh CVS checkouts.
 
 ** AC_CONFIG_MACRO_DIR
-  Use this macro to declare the directory for local m4 macros for aclocal.
+  Use this macro to declare the directory for local M4 macros for aclocal.
 
 ** AC_LIBOBJS
   No longer includes twice the same file in LIBOBJS if invoked
@@ -325,7 +325,7 @@
   Released 2002-12-03 by Paul Eggert.
 
 Bug fixes for problems with AIX linker, with freestanding C compilers,
-with GNU m4 limitations, and with obsolete copies of GNU documents.
+with GNU M4 limitations, and with obsolete copies of GNU documents.
 
 The Free Documentation License has been upgraded from 1.1 to 1.2.
 
@@ -767,7 +767,7 @@ In particular, portability issues are be
 
 ** Use of Automake
 All the standard GNU Makefile targets are supported.  The layout has
-changed: m4/ holds the m4 extensions Autoconf needs for its
+changed: m4/ holds the M4 extensions Autoconf needs for its
 configuration, doc/ contains the documentation, and tests/ contains
 the test suite.
 
@@ -1146,9 +1146,9 @@ Library, need major changes because they
 internals of version 1.  Future releases of those packages will have
 updated configure.in files.
 
-It's best to use GNU m4 1.3 (or later) with Autoconf version 2.
-Autoconf now makes heavy use of m4 diversions, which were implemented
-inefficiently in GNU m4 releases before 1.3.
+It's best to use GNU M4 1.3 (or later) with Autoconf version 2.
+Autoconf now makes heavy use of M4 diversions, which were implemented
+inefficiently in GNU M4 releases before 1.3.
 
 Major changes in Autoconf 2.0:
 
@@ -1349,7 +1349,7 @@ Major changes in Autoconf 1.4:
 * New macros AC_HAVE_POUNDBANG, AC_TIME_WITH_SYS_TIME, AC_LONG_DOUBLE,
   AC_GETGROUPS_T, AC_DEFINE_UNQUOTED.
 * autoconf and autoheader use the M4 environment variable to determine the
-  name of the m4 program to use.
+  name of the M4 program to use.
 * The --macrodir option to autoconf and autoheader specifies the directory
   in which acspecific.m4, acgeneral.m4, etc. reside if not the default.
 * autoconf and autoheader can take `-' as their file names, which means to
@@ -1361,7 +1361,7 @@ Major changes in Autoconf 1.4:
   expansion done by the shell.  If you don't want this, use
   AC_DEFINE_UNQUOTED instead.
 * Much textual processing done with external calls to tr and sed have been
-  internalized with builtin m4 `patsubst' and `translit' calls.
+  internalized with builtin M4 `patsubst' and `translit' calls.
 * AC_OUTPUT doesn't hardwire the file names it outputs.  Instead, you can
   set the shell variables `gen_files' and `gen_config' to the list of
   file names to output.
--- doc/autoconf.texi   19 Jun 2006 23:12:17 -0000      1.1052
+++ doc/autoconf.texi   20 Jun 2006 19:48:45 -0000
@@ -589,7 +589,7 @@ Using an Autotest Test Suite
 Frequent Autoconf Questions, with answers
 
 * Distributing::                Distributing @command{configure} scripts
-* Why GNU m4::                  Why not use the standard M4?
+* Why GNU M4::                  Why not use the standard M4?
 * Bootstrapping::               Autoconf and @acronym{GNU} M4 require each 
other?
 * Why Not Imake::               Why @acronym{GNU} uses @command{configure} 
instead of Imake
 * Defining Directories::        Passing @code{datadir} to program
@@ -733,7 +733,7 @@ Peter Simons}.
 
 @node The GNU Build System
 @chapter The @acronym{GNU} Build System
address@hidden GNU build system
address@hidden @acronym{GNU} build system
 
 Autoconf solves an important problem---reliable discovery of
 system-specific build and runtime information---but this is only one
@@ -1552,8 +1552,8 @@ Gettext supplies the @command{autopoint}
 infrastructure to a source package.  If you use @command{autopoint},
 your @file{configure.ac} should invoke both @code{AM_GNU_GETTEXT} and
 @code{AM_GNU_GETTEXT_VERSION(@var{gettext-version})}.  @xref{autopoint
-Invocation, , Invoking the @code{autopoint} Program, gettext, GNU
address@hidden utilities}, for further details.
+Invocation, , Invoking the @code{autopoint} Program, gettext,
address@hidden @code{gettext} utilities}, for further details.
 
 @noindent
 @command{autoreconf} accepts the following options:
@@ -2487,7 +2487,7 @@ The top-level directory for installing d
 
 @defvar oldincludedir
 @ovindex oldincludedir
-The directory for installing C header files for non-GCC compilers.
+The directory for installing C header files for address@hidden compilers.
 @end defvar
 
 @defvar pdfdir
@@ -4101,8 +4101,8 @@ longer need to be worried about.
 On various old systems, e.g., HP-UX 9, @code{sscanf} requires that its
 input string be writable (though it doesn't actually change it).  This
 can be a problem when using @command{gcc} since it normally puts
-constant strings in read-only memory
-(@pxref{Incompatibilities, Incompatibilities of GCC, , gcc, Using and
+constant strings in read-only memory (@pxref{Incompatibilities,
+Incompatibilities of @acronym{GCC}, , gcc, Using and
 Porting the @acronym{GNU} Compiler Collection}).  Apparently in some cases even
 having format strings read-only can be a problem.
 
@@ -4950,7 +4950,8 @@ additions.  Please help us keeping it as
 @item @file{limits.h}
 C99 says that @file{limits.h} defines @code{LLONG_MIN},
 @code{LLONG_MAX}, and @code{ULLONG_MAX}, but many almost-C99
-environments (e.g., default GCC 4.0.2 + glibc 2.4) do not define them.
+environments (e.g., default @acronym{GCC} 4.0.2 + glibc 2.4) do not
+define them.
 
 @item @file{inttypes.h} vs.@: @file{stdint.h}
 @hdrindex{inttypes.h}
@@ -5538,7 +5539,7 @@ For each of the @var{symbols} (@emph{com
 execute when one of the function declarations is needed, otherwise
 @var{action-if-found} is executed.
 
-This macro uses an m4 list as first argument:
+This macro uses an M4 list as first argument:
 @example
 AC_CHECK_DECLS([strdup])
 AC_CHECK_DECLS([strlen])
@@ -5730,7 +5731,7 @@ capitals, with spaces and dots replaced 
 members.  If @var{action-if-not-found} is given, it is executed for each
 of the members that could not be found.
 
-This macro uses m4 lists:
+This macro uses M4 lists:
 @example
 AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blksize])
 @end example
@@ -5999,7 +6000,7 @@ specified, the default includes are used
 when one of the types is found.  If @var{action-if-not-found} is given,
 it is executed when one of the types is not found.
 
-This macro uses m4 lists:
+This macro uses M4 lists:
 @example
 AC_CHECK_TYPES([ptrdiff_t])
 AC_CHECK_TYPES([unsigned long long int, uintmax_t])
@@ -6118,7 +6119,8 @@ Normally Autoconf ignores warnings gener
 preprocessor.  If this macro is used, warnings count as fatal
 errors for the current language.  This macro is useful when the
 results of configuration are used where warnings are unacceptable; for
-instance, if parts of a program are built with the GCC @option{-Werror}
+instance, if parts of a program are built with the @acronym{GCC}
address@hidden
 option.  If the whole program is built using @option{-Werror} it is
 often simpler to put @option{-Werror} in the compiler flags (@code{CFLAGS},
 etc.).
@@ -6223,7 +6225,8 @@ variable
 If using the @acronym{GNU} C compiler, set shell variable @code{GCC} to
 @samp{yes}.  If output variable @code{CFLAGS} was not already set, set
 it to @option{-g -O2} for the @acronym{GNU} C compiler (@option{-O2} on systems
-where GCC does not accept @option{-g}), or @option{-g} for other compilers.
+where @acronym{GCC} does not accept @option{-g}), or @option{-g} for
+other compilers.
 @end defmac
 
 @defmac AC_PROG_CC_C_O
@@ -6369,7 +6372,7 @@ If @command{autoconf} detects this situa
 as this generally yields better results in practice.  However, using a
 C++ compiler to compile C code is not recommended or supported, and
 installers who run into trouble in this area should get a C compiler
-like GCC to compile their C code.
+like @acronym{GCC} to compile their C code.
 
 This macro is obsolescent, as current C compilers support @code{const}.
 New programs need not use this macro.
@@ -6450,7 +6453,8 @@ stringizing operator.  New programs need
 @acindex{C_TYPEOF}
 @cvindex HAVE_TYPEOF
 @cvindex typeof
-If the C compiler supports GCC's @code{typeof} syntax either directly or
+If the C compiler supports @acronym{GCC}'s @code{typeof} syntax either
+directly or
 through a different spelling of the keyword (e.g., @code{__typeof__}),
 define @code{HAVE_TYPEOF}.  If the support is available only through a
 different spelling, define @code{typeof} to that spelling.
@@ -7472,12 +7476,14 @@ If a test program calls a function with 
 whether it exists), organize the program to ensure that it never invokes
 that function.  You can do this by calling it in another function that is
 never invoked.  You can't do it by putting it after a call to
address@hidden, because GCC version 2 knows that @code{exit} never returns
address@hidden, because @acronym{GCC} version 2 knows that @code{exit}
+never returns
 and optimizes out any code that follows it in the same block.
 
 If you include any header files, be sure to call the functions
 relevant to them with the correct number of arguments, even if they are
-just 0, to avoid compilation errors due to prototypes.  GCC version 2
+just 0, to avoid compilation errors due to prototypes.  @acronym{GCC}
+version 2
 has internal prototypes for several functions that it automatically
 inlines; for example, @code{memcpy}.  To avoid errors when checking for
 them, either pass them the correct number of arguments or redeclare them
@@ -9158,7 +9164,7 @@ overquoting in @code{AC_DEFINE} descript
 
 The Autoconf suite, including M4sugar, M4sh, and Autotest, in addition
 to Autoconf per se, heavily rely on M4.  All these different uses
-revealed common needs factored into a layer over @command{m4}:
+revealed common needs factored into a layer over M4:
 @address@hidden
 @c
 Yet another great name from Lars J. Aas.
@@ -9185,7 +9191,8 @@ autom4te @var{options} @var{files}
 @noindent
 @evindex M4
 where the @var{files} are directly passed to @command{m4}.  By default,
address@hidden m4 is found during configure, but the environment variable
address@hidden M4 is found during configuration, but the environment
+variable
 @env{M4} can be set to tell @command{autom4te} where to look.  In addition
 to the regular expansion, it handles the replacement of the quadrigraphs
 (@pxref{Quadrigraphs}), and of @samp{__oline__}, the current line in the
@@ -9346,8 +9353,8 @@ output and traces at the same time.  Tra
 @acronym{GNU} Build System: @command{autoheader} uses them to build
 @file{config.h.in}, @command{autoreconf} to determine what
 @acronym{GNU} Build System components are used, @command{automake} to
-``parse'' @file{configure.ac} etc.  To save the long runs of
address@hidden, traces are cached while performing regular expansion,
+``parse'' @file{configure.ac} etc.  To avoid recomputation,
+traces are cached while performing regular expansion,
 and conversely.  This cache is (actually, the caches are) stored in
 the directory @file{autom4te.cache}.  @emph{It can safely be removed}
 at any moment (especially if for some reason @command{autom4te}
@@ -9645,6 +9652,11 @@ reprocessed at @acronym{EOF} in the same
 @acronym{GNU} M4 versions through 1.4.x, however, reprocess them in
 reverse order.  Your code should not depend on the order.
 
+Also, Posix requires @code{m4wrap} to ignore its second and succeeding
+arguments, but @acronym{GNU} M4 versions through 1.4.x concatenate the
+arguments with intervening spaces.  Your code should not pass more than
+one argument.
+
 You are encouraged to end @var{text} with @samp{[]}, to avoid unexpected
 token pasting between consecutive invocations of @code{m4_wrap}, as in:
 
@@ -9689,7 +9701,7 @@ order.
 
 @defmac m4_foreach (@var{var}, @var{list}, @var{expression})
 @msindex{foreach}
-Loop over the comma-separated m4 list @var{list}, assigning each value
+Loop over the comma-separated M4 list @var{list}, assigning each value
 to @var{var}, and expand @var{expression}.  The following example
 outputs two lines:
 
@@ -10069,7 +10081,7 @@ AC_DEFUN(@var{macro-name}, @var{macro-bo
 
 You can refer to any arguments passed to the macro as @samp{$1},
 @samp{$2}, etc.  @xref{Definitions, , How to define new macros, m4.info,
address@hidden m4}, for more complete information on writing M4 macros.
address@hidden M4}, for more complete information on writing M4 macros.
 
 Be sure to properly quote both the @var{macro-body} @emph{and} the
 @var{macro-name} to avoid any problems if the macro happens to have
@@ -13392,7 +13404,7 @@ In Mac OS X 10.3, @command{od} does not 
 standard Posix options @option{-A}, @option{-j}, @option{-N}, or
 @option{-t}, or the @acronym{XSI} option @option{-s}.  The only
 supported Posix option is @option{-v}, and the only supported
address@hidden options are those in @option{-bcdox}.  The BSD
address@hidden options are those in @option{-bcdox}.  The @acronym{BSD}
 @command{hexdump} program can be used instead.
 
 This problem no longer exists in Mac OS X 10.4.3.
@@ -13669,10 +13681,10 @@ remove @file{U} with Posix make, but inc
 @command{touch} fails.  One way to work around this is to reword the
 affected simple-commands so that they always succeed, e.g., @samp{touch
 T || :; rm -f U}.
-However, even this approach can run into common bugs in BSD
+However, even this approach can run into common bugs in @acronym{BSD}
 implementations of the @option{-e} option of @command{sh} and
 @command{set} (@pxref{Limitations of Builtins}), so if you are worried
-about porting to buggy BSD shells it may be simpler to migrate
+about porting to buggy @acronym{BSD} shells it may be simpler to migrate
 complicated @command{make} actions into separate scripts.
 
 @node Special Chars in Names
@@ -14554,8 +14566,9 @@ platforms.
 Several standards have been developed to help make your programs more
 portable.  If you write programs with these standards in mind, you can
 have greater confidence that your programs work on a wide variety
-of systems.  @xref{Standards, , Language Standards Supported by GCC,
-gcc, Using the GNU Compiler Collection (GCC)}, for a list of C-related
+of systems.  @xref{Standards, , Language Standards Supported by
address@hidden, gcc, Using the @acronym{GNU} Compiler Collection
+(@acronym{GCC})}, for a list of C-related
 standards.  Many programs also assume the
 @uref{http://www.opengroup.org/susv3, Posix standard}.
 
@@ -14634,7 +14647,7 @@ of these two values typically yields the
 even though the C standard requires @code{INT_MIN % -1} to yield zero
 because the expression does not overflow.
 
-GCC users might consider using the
address@hidden users might consider using the
 @option{-ftrapv} option if they are worried about porting their code to
 the rare platforms where signed integer overflow does not wrap around
 after addition, subtraction, or multiplication.
@@ -14678,7 +14691,8 @@ reliable in general, and it is usually e
 potential portability problem, e.g., by allocating an extra unused array
 element at the start or end.
 
address@hidden://valgrind.org/, Valgrind} can catch many overruns.  GCC
address@hidden://valgrind.org/, Valgrind} can catch many overruns.
address@hidden
 users might also consider using the @option{-fmudflap} option to catch
 overruns.
 
@@ -14687,7 +14701,9 @@ more subtle ways to get them.
 
 Using @code{int} values to index into an array or compute array sizes
 causes problems on typical 64-bit hosts where an array index might
-be @math{2^31} or larger.
+be @math{2^31} or larger.  Index values of type @code{size_t} avoid this
+problem, but cannot be negative.  Index values of type @code{ptrdiff_t}
+are signed, and are wide enough in practice.
 
 If you add or multiply two numbers to calculate an array size, e.g.,
 @code{malloc (x * sizeof y + z)}, havoc ensues if the addition or
@@ -14704,7 +14720,8 @@ portable code should not use them unless
 within certain limits.  The time-related functions can overflow their
 buffers if given timestamps out of range (e.g., a year less than -999
 or greater than 9999).  Time-related buffer overflows cannot happen with
-recent-enough versions of the GNU C library, but are possible with other
+recent-enough versions of the @acronym{GNU} C library, but are possible
+with other
 implementations.  The @code{gets} function is the worst, since it almost
 invariably overflows its buffer when presented with an input line larger
 than the buffer.
@@ -17976,7 +17993,7 @@ are addressed.
 
 @menu
 * Distributing::                Distributing @command{configure} scripts
-* Why GNU m4::                  Why not use the standard M4?
+* Why GNU M4::                  Why not use the standard M4?
 * Bootstrapping::               Autoconf and @acronym{GNU} M4 require each 
other?
 * Why Not Imake::               Why @acronym{GNU} uses @command{configure} 
instead of Imake
 * Defining Directories::        Passing @code{datadir} to program
@@ -18008,7 +18025,7 @@ exception to the @acronym{GPL} when they
 same terms as the rest of your package.  @file{install-sh} is from the X
 Consortium and is not copyrighted.
 
address@hidden Why GNU m4
address@hidden Why GNU M4
 @section Why Require @acronym{GNU} M4?
 
 @display




reply via email to

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