Re: POSIX behavior of eval

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
Eric Blake <ebb9 <at> byu.net> writes:

> The Austin Group approved XCU ERN 118:

They also approved XCU ERN 137.  This patch has some code cleanups that I 
noticed while implementing ${1} semantics and porting --warn-macro-sequence 
from the branch, I'm committing this to reduce the size of that patch.  main.c 
is listed in diff -b, since I changed some indenting.

2007-02-28  Eric Blake  <[email protected]>

	POSIX XCU ERN 137 was approved.
	* modules/mpeval.c (numb_extension): Delete.
	* modules/m4.c (numb_extension): Likewise.
	* modules/evalparse.c (comma_term, condition_term): Always
	implement ?: and , operators.
	* m4/symtab.c: Update comment to match reality.
	* src/freeze.c (produce_frozen_state, reload_frozen_state): Avoid
	dereferencing context directly when accessor exists.
	* src/main.c (usage): Prefer GNU_M4 over EMACS.
	(struct macro_definition): Rename...
	(struct deferred): ...to match usage.  All uses changed.
	* doc/m4.texinfo (Eval): Document this change.
	(Operation modes, Changeresyntax): Fix wording to prefer GNU_M4
	over emacs.
	(Preprocessor features, Changesyntax): Fix inaccuracies.
	* NEWS: Import branch NEWS items for 1.4.x series.  Document
	change in eval.

Index: NEWS
===================================================================
RCS file: /sources/m4/m4/NEWS,v
retrieving revision 1.39
diff -u -r1.39 NEWS
--- NEWS	28 Feb 2007 14:36:22 -0000	1.39
+++ NEWS	28 Feb 2007 21:24:37 -0000
@@ -103,12 +103,12 @@
     regular expression flavor, to match `-r'/`--regexp-syntax' command-line
     option.
 
-*** New `debuglen' builtin is introduced which allows runtime setting of
-    debug output length, previously controlled only by the `-l' command
-    line argument.  Additionally, whether using the new macro or the
-    command line argument, the length limitation now affects dumpdef output
-    as well as trace output, undergoes argument validation, and accepts an
-    optional multiplier suffix.
+*** New `debuglen' builtin allows runtime setting of debug output length,
+    previously controlled only by the `-l' command line argument.
+    Additionally, whether using the new macro or the command line argument,
+    the length limitation now affects dumpdef output as well as trace
+    output, undergoes argument validation, and accepts an optional
+    multiplier suffix.
   - FIXME the multiplier suffix isn't reliable yet
 
 *** New `mkdtemp' builtin parallels `mkstemp', but allows the creation of
@@ -162,8 +162,7 @@
     macro.
 
 *** The `eval' and `mpeval' builtins now support the following new
-    operators: `>>>', `\', `?:', and  `,'.  However, when complying
-    strictly with POSIX, `?:' and `,' are rejected inside `eval'.
+    operators: `>>>', `\', `?:', and  `,'.
 
 *** The `maketemp' builtin now always warns that it is obsolete, even in GNU
     mode where it uses the same secure algorithm as `mkstemp', because of
@@ -192,13 +191,329 @@
   - FIXME: format 2 still needs to catch more missing state; once 2.0 is
     released, any further changes would introduce format 3.
 
-FIXME: include the (long) list of changes in 1.4.x that were not already
-  in earlier betas.
-* Version 1.4.9
-* Version 1.4.8
-* Version 1.4.7
-* Version 1.4.6
-* Version 1.4.5
+*** Improvements made in the 1.4.x stable series have been incorporated.
+
+* Version 1.4.9 - ?? ??? 2007, by ???  (CVS version 1.4.8c)
+
+** Minor documentation and portability cleanups.
+
+* Version 1.4.8b - 24 Feb 2007, by Eric Blake  (CVS version 1.4.8a)
+
+** Fix a regression introduced in 1.4.8 that made m4 unable to process
+   files larger than 2GiB on some platforms.
+
+** Fix a regression introduced in 1.4.8 that made m4 dump core when
+   invoked as 'm4 -- file'.
+
+** The `eval' builtin now follows C precedence rules.  Additionally, the
+   short-circuit operators correctly short-circuit division by zero.  The
+   previously undocumented alias of '=' meaning '==' in eval now triggers a
+   deprecation warning, so that a future version of M4 can implement a form
+   of variable assignment as an extension.
+
+** The `include' builtin now affects exit status on failure, as required by
+   POSIX.  Use `sinclude' if you need a successful exit status.
+
+** The `-E'/`--fatal-warnings' command-line option now has two levels.  When
+   specified only once, warnings affect exit status, but execution
+   continues, so that you can see all warnings instead of fixing them one
+   at a time.  To acheive 1.4.8 behavior, where the first warning
+   immediately exits, specify -E twice on the command line.
+
+** A new `--warn-macro-sequence' command-line option allows detection of
+   sequences in `define' and `pushdef' definitions that match an optional
+   regular expression.  The default regular expression is
+   `\$\({[^}]*}\|[0-9][0-9]+\)', corresponding to the sequences that might
+   not behave correctly when upgrading to the eventual M4 2.0.  By default,
+   M4 2.0 will follow the POSIX requirement that a macro definition
+   containing `$11' must expand to the first argument concatenated with 1,
+   rather than the eleventh argument; and will take advantage of the POSIX
+   wording that allows implementations to treat `${11}' as the eleventh
+   argument instead of literal text.  Be aware that Autoconf 2.61 will not
+   work with this option enabled with the default regular expression; but
+   Autoconf 2.62 will be compatible with this option.
+
+** Improved portability to platforms such as BSD/OS and AIX.
+
+* Version 1.4.8 - 20 November 2006, by Eric Blake  (CVS version 1.4.7a)
+
+** The `divert' macro and `-H'/`--hashsize' command line option no longer
+   cause a core dump when handed extra large values.  Also, `divert' now
+   uses memory proportional to the number of diversions in use, rather than
+   to the maximum diversion number encountered, so that large diversion
+   numbers are less likely to exhaust system memory; and is no longer
+   limited by the maximum number of file descriptors.
+
+** The `--help' and `--version' command line options now consistently
+   override all earlier options.  For example, `m4 --debugfile=trace
+   --help' now no longer accidentally creates an empty file `trace'.
+
+** The `-L'/`--nesting-limit' command line option can now be set to 0
+   to remove the default limit of 1024.  However, it is still possible that
+   heavily nested input can cause abrupt program termination due to stack
+   overflow.
+
+** Problems encountered when writing to standard error, such as with the
+   `errprint' macro, now always cause a non-zero exit status.
+
+** Warnings and errors issued during macro expansion are now consistently
+   reported at the line where the macro name was detected, rather than
+   where the close parenthesis resides.  Text wrapped by `m4wrap' now
+   remembers the location that was in effect when m4wrap was invoked,
+   rather than changing to line 0 and the empty string for a file.  The
+   macros `__line__' and `__file__' now work correctly even as the last
+   token in an included file.
+
+** The `builtin' and `indir' macros now transparently handle builtin
+   tokens generated by `defn'.
+
+** When diversions created by the `divert' macro collect enough text that
+   M4 must use temporary files, the environment variable $TMPDIR is now
+   consulted, and a better effort is made to clean up those files in the
+   event of a fatal signal.
+
+** The `mkstemp' builtin is added with the same GNU semantics as `maketemp',
+   based on the recommendation of POSIX to deprecate the POSIX semantics of
+   `maketemp' as inherently insecure.  In GNU mode (no -G supplied on the
+   command line), `maketemp' silently retains the secure GNU semantics, but
+   a future release of M4 will change this to emit a warning.  In
+   traditional mode (m4 -G), `maketemp' now uses the POSIX-mandated
+   insecure semantics, and issues a warning that you should convert your
+   script to use `mkstemp' instead.  Additionally, `mkstemp' and `maketemp'
+   are now well-defined even if the template argument does not end in six
+   `X' characters.
+
+** The manual has been improved, including a new section on a composite
+   macro `foreach'.
+
+** The `changecom' and `changequote' macros now treat an empty second
+   argument the same as if it were missing, rather than using the empty
+   string and making it impossible to end a comment or quote.
+
+** The `translit' macro now operates in linear instead of quadratic time,
+   and is now eight-bit clean.
+
+** The `-D', `-U', `-s', and `-t' command line options now take effect
+   after any files encountered earlier on the command line, rather than up
+   front, as is done in traditional implementations and required by POSIX.
+
+* Version 1.4.7 - 25 September 2006, by Eric Blake  (CVS version 1.4.6a)
+
+** Fix regression from 1.4.5 in handling a file that ends in a macro
+   expansion without arguments instead of a newline.
+
+** The define and pushdef macros now warn when the first argument is not
+   a string, rather than silently doing nothing.
+
+** Standard input can now be read more than once, as in 'm4 - file -', and
+   is not closed until all wrapped text is handled.  This makes a
+   difference when stdin is not a regular file, and also fixes bugs when
+   using the syscmd or esyscmd macros from wrapped text.
+
+** When standard input is a seekable file, the m4exit, syscmd, and esyscmd
+   macros now restore the current position to the next unread byte rather
+   than discarding an arbitrary amount of buffered data.
+
+** SysV command-line compatibility is no longer a goal of GNU M4; the
+   focus will be instead on POSIX compatibility.  This release continues to
+   support previous usage, but adds warnings in areas which will allow a
+   future version of GNU M4 to use its own extensions without being tied to
+   the SysV command line interface.
+
+** The no-op compatibility command line options -B, -N, -S, -T, and
+   --diversions may be withdrawn or assigned new meanings in future
+   releases, so they now issue a warning if used.
+
+** A new command line option -i replaces the compatibility -e as the
+   short spelling of --interactive, for consistency with other GNU tools; a
+   warning is issued if the old spelling is used, and it may be assigned
+   new meaning in future releases.
+
+** A new command line option --debugfile replaces the options -o and
+   --error-output as the preferred spelling.  The old options were
+   misleading in their names and inconsistent with other GNU tools; they
+   are still silently accepted, but no longer documented in --help, and may
+   be assigned new meanings in future releases.
+
+* Version 1.4.6 - 25 August 2006, by Eric Blake  (CVS version 1.4.5a)
+
+** Fix buffer overruns in regexp and patsubst macros when handed a trailing
+   backslash in the replacement text, or when handling \n substitutions
+   beyond the number of \(\) groups.
+
+** Fix memory leak in regexp, patsubst, and changeword macros.
+
+** The format macro now understands %F, %g, and %G.
+
+** When loading frozen files, m4 now exits with status 63 if version
+   mismatch is detected.
+
+** Fix bugs that occurred when invoked with stdout or stderr closed,
+   and detect write failures to stdout or to the target of the debugfile
+   macro.  In particular, the syscmd and esyscmd macros can no longer
+   interfere with the debug stream or diversions.
+
+** The m4exit macro now converts values outside the range 0-255 to 1.
+
+** It is now an error if a command-line input file ends in the middle of a
+   comment, matching the behavior of mid-string and mid-argument
+   collection.
+
+** The dnl macro now warns if end of file is encountered instead of a
+   newline.
+
+** The error message when end of file is encountered now uses the file and
+   line where the dangling construct started, rather than `NONE:0:'.
+
+** The debugmode and __file__ macros, and the -s/--synclines option, now
+   show what directory a file was found in when the -I/--include option or
+   M4PATH variable had an effect.
+
+** The changequote and changecom macros now work with 8-bit characters, and
+   quotes and comments that begin with `(' are properly recognized
+   following a word.
+
+** The new macro __program__ is added, which allows the input file to issue
+   an error message that resembles messages from m4.  Warning and error
+   messages have been reformatted to comply with GNU Coding Standards.
+
+** The errprint, m4wrap, and shift macros are now recognized only with
+   arguments.
+
+** The index, substr, translit, regexp, and patsubst macros now produce
+   output when given only one argument, but still warn about a missing
+   second argument.
+
+** The patsubst macro now reliably finds zero-length matches at the end
+   of a string.
+
+* Version 1.4.5 - 15 July 2006, by Eric Blake  (CVS version 1.4.4c)
+
+** Fix sysval on BeOS, OS/2, and other systems that store exit status
+   in the low-order byte.  Additionally, on Unix platforms, if syscmd was
+   terminated by a signal, sysval now displays the signal number shifted
+   left by eight bits, to match traditional m4 implementations.
+
+** The maketemp macro is no longer subject to platform limitations (such as
+   26 or 32 max files from a given template).
+
+** Frozen files now require that the first directive be V (version), to
+   better diagnose version mismatch.  Additionally, if the F directive
+   (builtin function) names an unknown builtin that existed in the m4 that
+   froze the file but not in the current m4 (for example, changeword), the
+   warning is deferred until an attempt is made to actually use the
+   builtin.  This allows downgrading from beta m4-1.4o to stable m4-1.4.5
+   without breaking autoconf.
+
+** The format and indir macros are now recognized only with arguments.
+
+** The eval macro no longer crashes on x86 architectures when dividing the
+   minimum integer by -1.
+
+** On systems with ecvt and fcvt, format no longer truncates trailing
+   zeroes on integers printed with %.0f.  On systems without these
+   functions, format is no longer subject to a buffer overflow that
+   permitted arbitrary code execution.
+
+** On native Windows builds, the macro __windows__ is provided instead of
+   __unix__.  Likewise, on OS/2 builds, the macro __os2__ is provided.
+   This allows input files to determine when syscmd might behave
+   differently.
+
+** Fix bug in 1.4.3 patch to use \n line-endings that did not work for
+   cygwin.
+
+** When given the empty string or 0, undivert is now documented as a no-op
+   rather than closing stdout, warning about a non-existent file, or trying
+   to read a directory as a file.
+
+** Many documentation improvements.  Also, the manual is now distributed
+   under FDL 1.2, rather than a stricter verbatim-only license.
+
+** Raise the -L (--nesting-limit) command line option limit from 250 to
+   1024.
+
+** The decr, incr, divert, m4exit, and substr macros treat an empty number
+   as 0, issue a warning, and expand as normal; rather than issuing an
+   error and expanding to the empty string.
+
+** The eval macro now treats an empty radix argument as 10, handles radix 1,
+   and treats the width argument as number of digits excluding the sign,
+   for compatibility with other m4 implementations.
+
+** The ifdef, divert, m4exit, substr, and translit macros now correctly
+   ignore extra arguments.
+
+** The popdef and undefine macros now correctly accept multiple arguments.
+
+** Although changeword is on its last leg, if enabled, it now reverts to the
+   default (faster) regexp when passed the empty string.
+
+** The regexp and substr macros now warn and ignore a trailing backslash in
+   the replacement, and warn on \n for n larger than the number of
+   sub-expressions in the regexp.
+
+* Version 1.4.4b - 17 June 2006, by Eric Blake  (CVS version 1.4.4a)
+
+** Fix a recursive push_string crashing bug, which affected changequote of
+   three or more characters on some compilers.
+
+** Use automake to fix build portability issues.
+
+** Fix a recursive m4wrap crashing bug.
+
+** Fix a 1 in 2**32 hash crashing bug.
+
+** Tracing a macro by name is now persistent, even if the macro is
+   subsequently undefined or redefined.  The traceon and traceoff macros no
+   longer warn about undefined symbols.  This solves a crash when using
+   indir on an undefined macro traced with the -t option, as well as an
+   incorrect result of ifdef.  Furthermore, tracing is no longer
+   transferred with builtins, solving the bug of "m4 -tm4_eval" failing to
+   give trace output on the input
+   "define(`m4_eval',defn(`eval'))m4_eval(1)".
+
+** Fix a crash when a macro is undefined while collecting its arguments, by
+   always using the definition that was in effect before argument
+   collection.  This behavior matches the C pre-processor, and means that
+   the sequence "define(`f',`1')f(define(`f',`2'))f" is now documented to
+   result in "12", rather than the previously undocumented "22".
+
+** Update the regex engine to fix several bugs.
+
+** Fix a potential crash on machines where char is signed.
+
+* Version 1.4.4 - October 2005, by Gary V. Vaughan
+
+** ./configure --infodir=/usr/share/info now works correctly.
+
+** When any file named on the command line is missing exit with status 1.
+
+* Version 1.4.3 - March 2005, by Gary V. Vaughan
+
+** DESTDIR installs now work correctly.
+
+** Don't segfault with uncompilable regexps to changeword().
+
+** Always use \n line-endings for frozen files (fixes a Windows bug).
+
+** Portability fix for systems lacking mkstemp(3).
+
+** Approximately 20% speed up in the common case of usage with autoconf.
+
+** Supported on QNX 6.3.
+
+* Version 1.4.2 - August 2004, by Paul Eggert
+
+** No user visible changes; portability bug fixes only.
+
+* Version 1.4.1 - June 2004, by Paul Eggert
+
+** The 1.4.x series is intended to be stable; features added in 1.4[a-q]
+   were not backported to 1.4.x unless specifically mentioned above.
+
+** maketemp now creates an empty file with the given name, instead of merely
+   returning the name of a nonexistent file.  This closes a security hole.
 
 * Version beta 1.4q - August 2001, by Gary V. Vaughan
 
@@ -355,13 +670,6 @@
 
 *** All 8-bit characters can now be used for quotes.
 
-FIXME: include the (long) list of changes in 1.4.x that were not already
-  in earlier betas.
-* Version 1.4.4
-* Version 1.4.3
-* Version 1.4.2
-* Version 1.4.1
-
 * Version 1.4 - October 1994, by Franc,ois Pinard
 
 ** (No user visible changes)
Index: src/freeze.c
===================================================================
RCS file: /sources/m4/m4/src/freeze.c,v
retrieving revision 1.61
diff -u -r1.61 freeze.c
--- src/freeze.c	25 Feb 2007 23:19:32 -0000	1.61
+++ src/freeze.c	28 Feb 2007 21:24:37 -0000
@@ -239,12 +239,12 @@
       || strcmp (m4_get_syntax_rquote (M4SYNTAX), DEF_RQUOTE))
     {
       fprintf (file, "Q%lu,%lu\n",
-	       (unsigned long int) context->syntax->lquote.length,
-	       (unsigned long int) context->syntax->rquote.length);
-      produce_mem_dump (file, context->syntax->lquote.string,
-			context->syntax->lquote.length);
-      produce_mem_dump (file, context->syntax->rquote.string,
-			context->syntax->rquote.length);
+	       (unsigned long int) M4SYNTAX->lquote.length,
+	       (unsigned long int) M4SYNTAX->rquote.length);
+      produce_mem_dump (file, M4SYNTAX->lquote.string,
+			M4SYNTAX->lquote.length);
+      produce_mem_dump (file, M4SYNTAX->rquote.string,
+                        M4SYNTAX->rquote.length);
       fputc ('\n', file);
     }
 
@@ -254,12 +254,10 @@
       || strcmp (m4_get_syntax_ecomm (M4SYNTAX), DEF_ECOMM))
     {
       fprintf (file, "C%lu,%lu\n",
-	       (unsigned long int) context->syntax->bcomm.length,
-	       (unsigned long int) context->syntax->ecomm.length);
-      produce_mem_dump (file, context->syntax->bcomm.string,
-			context->syntax->bcomm.length);
-      produce_mem_dump (file, context->syntax->ecomm.string,
-			context->syntax->ecomm.length);
+	       (unsigned long int) M4SYNTAX->bcomm.length,
+	       (unsigned long int) M4SYNTAX->ecomm.length);
+      produce_mem_dump (file, M4SYNTAX->bcomm.string, M4SYNTAX->bcomm.length);
+      produce_mem_dump (file, M4SYNTAX->ecomm.string, M4SYNTAX->ecomm.length);
       fputc ('\n', file);
     }
 
@@ -495,7 +493,7 @@
 	m4__module_open (context, "gnu", NULL);
       /* Disable { and } categories, since ${11} was not supported in
          1.4.x.  */
-      m4_set_syntax (context->syntax, 'O', '+', "{}");
+      m4_set_syntax (M4SYNTAX, 'O', '+', "{}");
       break;
     default:
       if (version > 2)
@@ -646,7 +644,7 @@
 
 	  /* Syntax under M4_SYNTAX_MASKS is handled specially; all
 	     other characters are additive.  */
-	  if ((m4_set_syntax (context->syntax, syntax,
+	  if ((m4_set_syntax (M4SYNTAX, syntax,
 			      (m4_syntax_code (syntax) & M4_SYNTAX_MASKS
 			       ? '=' : '+'), string[0]) < 0)
 	      && (syntax != '\0'))
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.97
diff -u -r1.97 m4.texinfo
--- doc/m4.texinfo	28 Feb 2007 14:36:22 -0000	1.97
+++ doc/m4.texinfo	28 Feb 2007 21:24:37 -0000
@@ -655,11 +655,12 @@
 @item -r@r{[}@var{RESYNTAX-SPEC}@r{]}
 @itemx --regexp-syntax@r{[}=@var{RESYNTAX-SPEC}@r{]}
 Set the regular expression syntax according to @var{RESYNTAX-SPEC}.
-When this option is not given, @var{RESYNTAX-SPEC} is omitted,
-@acronym{GNU} M4 uses emacs compatible regular expressions.
-@xref{Changeresyntax}, for more details on the format and meaning of
-@var{RESYNTAX-SPEC}.  This option may be given more than once, and order
-with respect to file names is significant.
+When this option is not given, or @var{RESYNTAX-SPEC} is omitted,
+@acronym{GNU} M4 uses the flavor @code{GNU_M4}, which provides
+emacs-compatible regular expressions.  @xref{Changeresyntax}, for more
+details on the format and meaning of @var{RESYNTAX-SPEC}.  This option
+may be given more than once, and order with respect to file names is
+significant.
 
 @item --safer
 Cripple the following builtins, since each can perform potentially
@@ -735,13 +736,12 @@
 
 @item -D @var{NAME}@r{[}=@var{VALUE}@r{]}
 @itemx --define=@var{NAME}@r{[}=@var{VALUE}@r{]}
-This enters @var{NAME} into the symbol table, before any input files are
-read.  If @samp{=@var{VALUE}} is missing, the value is taken to be the
-empty string.  The @var{VALUE} can be any string, and the macro can be
-defined to take arguments, just as if it was defined from within the
-input.  This option may be given more than once; order with respect to
-file names is significant, and redefining the same @var{NAME} loses the
-previous value.
+This enters @var{NAME} into the symbol table.  If @samp{=@var{VALUE}} is
+missing, the value is taken to be the empty string.  The @var{VALUE} can
+be any string, and the macro can be defined to take arguments, just as
+if it was defined from within the input.  This option may be given more
+than once; order with respect to file names is significant, and
+redefining the same @var{NAME} loses the previous value.
 
 @item --import-environment
 Imports every variable in the environment as a macro.  This is done
@@ -763,13 +763,12 @@
 
 @item -p @var{NAME}@r{[}=@var{VALUE}@r{]}
 @itemx --pushdef=@var{NAME}@r{[}=@var{VALUE}@r{]}
-This enters @var{NAME} into the symbol table, before any input files are
-read.  If @samp{=@var{VALUE}} is missing, the value is taken to be the
-empty string.  The @var{VALUE} can be any string, and the macro can be
-defined to take arguments, just as if it was defined from within the
-input.  This option may be given more than once; order with respect to
-file names is significant, and redefining the same @var{NAME} adds
-another definition to its stack.
+This enters @var{NAME} into the symbol table.  If @samp{=@var{VALUE}} is
+missing, the value is taken to be the empty string.  The @var{VALUE} can
+be any string, and the macro can be defined to take arguments, just as
+if it was defined from within the input.  This option may be given more
+than once; order with respect to file names is significant, and
+redefining the same @var{NAME} adds another definition to its stack.
 
 @item -s
 @itemx --synclines
@@ -1924,6 +1923,20 @@
 @result{}1
 @end example
 
+Remember that @samp{#} defaults to the comment character; if you forget
+quotes to inhibit the comment behavior, your macro definition may not
+end where you expected.
+
+@example
+dnl Attempt to define a macro to just `$#'
+define(underquoted, $#)
+oops)
+@result{}
+underquoted
+@result{}0)
+@result{}oops
+@end example
+
 The notation @code{$*} can be used in the expansion text to denote all
 the actual arguments, unquoted, with commas in between.  For example
 
@@ -4168,7 +4181,8 @@
 the value of @var{resyntax}, equivalent to passing @var{resyntax} as the
 argument to the command line option @option{--regexp-syntax}
 (@pxref{Operation modes, , Invoking m4}).  If @var{resyntax} is empty,
-the default flavor is reverted to emacs style.
+the default flavor is reverted to the @code{GNU_M4} style, compatible
+with emacs.
 
 @var{resyntax} can be any one of the values in the table below.  Case is
 not important, and @kbd{-} or @kbd{ } can be substituted for @kbd{_} in
@@ -4354,8 +4368,6 @@
 @comment FIXME - we should also consider supporting:
 @comment @item Ignore - characters that are ignored if they appear in
 @comment the input; perhaps defaulting to '\0', category 'I'.
-@comment @item Assign -character used in macro definitions for default
-@comment variables, category '='.
 @end table
 
 @noindent
@@ -4412,6 +4424,10 @@
 Argument separator
 @item $
 Dollar
+@item @{
+Left brace
+@item @}
+Right brace
 @item O
 Other
 @item @@
@@ -4428,8 +4444,6 @@
 End comment
 @comment @item I
 @comment Ignore
-@comment @item =
-@comment Assign
 @end table
 
 The remaining characters of each @var{syntax-spec} form the set of
@@ -6046,11 +6060,10 @@
 @end deffn
 
 All binary operators, except exponentiation, are left associative.  C
-operators that perform variable assignment, such as @samp{=} or
-@samp{--}, are forbidden by @acronym{POSIX}, since @code{eval} only
-operates on constants, not variables.  Attempting to use them results
-in an error.
-@comment fixme If XCU ERN 137 is approved, then we could provide an
+operators that perform variable assignment, such as @samp{+=} or
+@samp{--}, are not implemented, since @code{eval} only operates on
+constants, not variables.  Attempting to use them results in an error.
+@comment FIXME - since XCU ERN 137 is approved, we could provide an
 @comment extension that supported assignment operators.
 
 Note that some older @code{m4} implementations use @samp{^} as an
@@ -6122,6 +6135,7 @@
 which shifts in 0 bits rather than twos-complement sign-extension.  A
 ratio operator @samp{\} behaves like normal division @samp{/} on
 integers, but is provided for symmetry with @code{mpeval}.
+Additionally, the C operators @samp{,} and @samp{?:} are supported.
 
 @example
 eval(`2 ** 3 ** 2')
@@ -6146,40 +6160,18 @@
 @result{}1
 eval(`6 \ 3')
 @result{}2
-@end example
-
-Furthermore, when you do not use the @option{--traditional} command line
-option (or @option{-G}, @pxref{Limits control, , Invoking m4}), the C
-operators @samp{,} and @samp{?:} are supported.  But in traditional
-mode, @acronym{POSIX} requires that the use of these two operators cause
-an error.
-
-@example
-$ @kbd{m4}
-eval(`1?2:3')
+eval(`1 ? 2 : 3')
 @result{}2
-eval(`0?2:3')
+eval(`0 ? 2 : 3')
 @result{}3
-eval(`1?2:1/0')
+eval(`1 ? 2 : 1/0')
 @result{}2
-eval(`0?1/0:3')
+eval(`0 ? 1/0 : 3')
 @result{}3
-eval(`4,5')
+eval(`4, 5')
 @result{}5
 @end example
 
-@comment options: -G
-@comment status: 1
-@example
-$ @kbd{m4 --posix}
-eval(`1?2:3')
-@error{}m4:stdin:1: eval: invalid operator: 1?2:3
-@result{}
-eval(`4,5')
-@error{}m4:stdin:2: eval: invalid operator: 4,5
-@result{}
-@end example
-
 Within @var{expression}, (but not @var{radix} or @var{width}), numbers
 without a special prefix are decimal.  A simple @samp{0} prefix
 introduces an octal number.  @samp{0x} introduces a hexadecimal number.
Index: m4/symtab.c
===================================================================
RCS file: /sources/m4/m4/m4/symtab.c,v
retrieving revision 1.70
diff -u -r1.70 symtab.c
--- m4/symtab.c	27 Jan 2007 00:25:14 -0000	1.70
+++ m4/symtab.c	28 Feb 2007 21:24:37 -0000
@@ -32,15 +32,16 @@
    simply ordered on the stack by age.  The most recently pushed definition
    will then always be the first found.
 
-   Also worthy of mention is the way traced symbols are managed:  the trace
-   bit is associated with a particular symbol name.  If a symbol is
-   undefined and then redefined, it does not lose its trace bit (in GNU
-   mode).  This is achieved by not removing traced symbol names from the
-   symbol table, even if their value stack is empty.  That way, when the
-   name is given a new value, it is pushed onto the empty stack, and the
-   trace bit attached to the name was never lost.  There is a small amount
-   of fluff in these functions to make sure that such symbols (with empty
-   value stacks) are invisible to the users of this module.  */
+   Also worthy of mention is the way traced symbols are managed: the
+   trace bit is associated with a particular symbol name.  If a symbol
+   is undefined and then redefined, it does not lose its trace bit.
+   This is achieved by not removing traced symbol names from the
+   symbol table, even if their value stack is empty.  That way, when
+   the name is given a new value, it is pushed onto the empty stack,
+   and the trace bit attached to the name was never lost.  There is a
+   small amount of fluff in these functions to make sure that such
+   symbols (with empty value stacks) are invisible to the users of
+   this module.  */
 
 #define M4_SYMTAB_DEFAULT_SIZE		2047
 
Index: modules/evalparse.c
===================================================================
RCS file: /sources/m4/m4/modules/evalparse.c,v
retrieving revision 1.16
diff -u -r1.16 evalparse.c
--- modules/evalparse.c	6 Jan 2007 19:56:54 -0000	1.16
+++ modules/evalparse.c	28 Feb 2007 21:24:37 -0000
@@ -341,9 +341,6 @@
   numb_init (v2);
   while ((et = eval_lex (&v2)) == COMMA)
     {
-      /* Unless XCU ERN 137 is approved, eval must reject this in
-	 POSIX mode.  */
-      numb_extension (context);
       et = eval_lex (&v2);
       if (et == ERROR)
 	return UNKNOWN_INPUT;
@@ -374,9 +371,6 @@
   numb_init (v3);
   if ((et = eval_lex (&v2)) == QUESTION)
     {
-      /* Unless XCU ERN 137 is approved, eval must reject this in
-	 POSIX mode.  */
-      numb_extension (context);
       et = eval_lex (&v2);
       if (et == ERROR)
 	return UNKNOWN_INPUT;
Index: modules/m4.c
===================================================================
RCS file: /sources/m4/m4/modules/m4.c,v
retrieving revision 1.103
diff -u -r1.103 m4.c
--- modules/m4.c	28 Feb 2007 14:36:22 -0000	1.103
+++ modules/m4.c	28 Feb 2007 21:24:37 -0000
@@ -1111,15 +1111,6 @@
 #define numb_urshift(c, x, y)				\
    (*(x) = (number) ((unumber) *(x) >> (unumber) *(y)))
 
-#define numb_extension(c)			      \
-  do						      \
-    {						      \
-      /* Revisit this if XCU ERN 137 is approved.  */ \
-      if (m4_get_posixly_correct_opt (context))	      \
-	return INVALID_OPERATOR;		      \
-    }						      \
-  while (0)
-
 
 /* The function ntoa () converts VALUE to a signed ascii representation in
    radix RADIX.  */
Index: modules/mpeval.c
===================================================================
RCS file: /sources/m4/m4/modules/mpeval.c,v
retrieving revision 1.23
diff -u -r1.23 mpeval.c
--- modules/mpeval.c	15 Jan 2007 14:04:27 -0000	1.23
+++ modules/mpeval.c	28 Feb 2007 21:24:37 -0000
@@ -143,7 +143,6 @@
 static void numb_lshift (m4 *context, number *x, number *y);
 static void numb_rshift (m4 *context, number *x, number *y);
 #define numb_urshift(c, x, y) numb_rshift (c, x, y)
-#define numb_extension(c) /* no-op */
 
 
 static number numb_ZERO;
Index: src/main.c
===================================================================
RCS file: /sources/m4/m4/src/main.c,v
retrieving revision 1.108
diff -u -b -r1.108 main.c
--- src/main.c	5 Feb 2007 17:31:10 -0000	1.108
+++ src/main.c	28 Feb 2007 21:24:47 -0000
@@ -33,12 +33,12 @@
 
 #define AUTHORS _("Rene' Seindal"), "Gary V. Vaughan", "Eric Blake"
 
-typedef struct macro_definition
+typedef struct deferred
 {
-  struct macro_definition *next;
+  struct deferred *next;
   int code;			/* deferred optchar */
-  const char *macro;
-} macro_definition;
+  const char *value;
+} deferred;
 
 
 /* Error handling functions.  */
@@ -92,7 +92,7 @@
   -i, --interactive            unbuffer output, ignore interrupts\n\
   -P, --prefix-builtins        force a `m4_' prefix to all builtins\n\
   -Q, --quiet, --silent        suppress some warnings for builtins\n\
-  -r, --regexp-syntax[=SPEC]   set default regexp syntax to SPEC [EMACS]\n\
+  -r, --regexp-syntax[=SPEC]   set default regexp syntax to SPEC [GNU_M4]\n\
       --safer                  disable potentially unsafe builtins\n\
   -W, --warnings               enable all warnings\n\
 "), stdout);
@@ -325,13 +325,12 @@
 int
 main (int argc, char *const *argv, char *const *envp)
 {
-  macro_definition *head = NULL;	/* head of deferred argument list */
-  macro_definition *tail = NULL;
-  macro_definition *defn;
+  deferred *head = NULL;	/* head of deferred argument list */
+  deferred *tail = NULL;
+  deferred *defn;
   int optchar;			/* option character */
   size_t size;			/* for parsing numeric option arguments */
 
-  macro_definition *defines;
   bool read_stdin = false;	/* true iff we have read from stdin */
   bool import_environment = false; /* true to import environment */
   bool seen_file = false;
@@ -428,7 +427,7 @@
 
 	defn = xmalloc (sizeof *defn);
 	defn->code = optchar;
-	defn->macro = optarg;
+	defn->value = optarg;
 	defn->next = NULL;
 
 	if (head == NULL)
@@ -641,7 +640,7 @@
 	{
 	  defn = xmalloc (sizeof *defn);
 	  defn->code = 'D';
-	  defn->macro = *env;
+	  defn->value = *env;
 	  defn->next = head;
 	  head = defn;
 	}
@@ -649,22 +648,20 @@
 
   /* Handle deferred command line macro definitions.  Must come after
      initialization of the symbol table.  */
+  defn = head;
+  while (defn != NULL)
   {
-    defines = head;
+      deferred *next;
+      const char *arg = defn->value;
 
-    while (defines != NULL)
-      {
-	macro_definition *next;
-	const char *arg = defines->macro;
-
-	switch (defines->code)
+      switch (defn->code)
 	  {
 	  case 'D':
 	  case 'p':
 	    {
 	      m4_symbol_value *value = m4_symbol_value_create ();
 
-	      /* defines->arg is read-only, so we need a copy.	*/
+	    /* defn->value is read-only, so we need a copy.  */
 	      char *macro_name = xstrdup (arg);
 	      char *macro_value = strchr (macro_name, '=');
 
@@ -673,7 +670,7 @@
 	      m4_set_symbol_value_text (value, xstrdup (macro_value
 							? macro_value : ""));
 
-	      if (defines->code == 'D')
+	    if (defn->code == 'D')
 		m4_symbol_define (M4SYMTAB, macro_name, value);
 	      else
 		m4_symbol_pushdef (M4SYMTAB, macro_name, value);
@@ -691,13 +688,10 @@
 	    break;
 
 	  case 'r':
-	    m4_set_regexp_syntax_opt (context,
-				      m4_regexp_syntax_encode (arg));
+	  m4_set_regexp_syntax_opt (context, m4_regexp_syntax_encode (arg));
 	    if (m4_get_regexp_syntax_opt (context) < 0)
-	      {
 		m4_error (context, EXIT_FAILURE, 0,
 			  _("bad regexp syntax option: `%s'"), arg);
-	      }
 	    break;
 
 	  case 't':
@@ -737,10 +731,9 @@
 	    abort ();
 	  }
 
-	next = defines->next;
-	free (defines);
-	defines = next;
-      }
+      next = defn->next;
+      free (defn);
+      defn = next;
   }
 
   /* Handle remaining input files.  Each file is pushed on the input,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.