CVSROOT: /sources/m4
Module name: m4
Branch: branch-1_4
Changes by: Eric Blake <ericb> 07/01/09 16:12:43
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.1.1.1.2.106
retrieving revision 1.1.1.1.2.107
diff -u -b -r1.1.1.1.2.106 -r1.1.1.1.2.107
--- doc/m4.texinfo 6 Jan 2007 19:56:11 -0000 1.1.1.1.2.106
+++ doc/m4.texinfo 9 Jan 2007 16:12:43 -0000 1.1.1.1.2.107
@@ -4466,10 +4466,28 @@
@end deffn
All binary operators, except exponentiation, are left associative. C
-operators that perform variable assignment, such as @samp{=} or
+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.
+in an error. However, since traditional implementations treated
[EMAIL PROTECTED] as an undocumented alias for @samp{==} as opposed to an
+assignment operator, this usage is supported as a special case. Be
+aware that a future version of @acronym{GNU} M4 may support assignment
+semantics as an extension when @acronym{POSIX} mode is not requested,
+and that using @samp{=} to check equality is not portable.
+
[EMAIL PROTECTED] status: 1
[EMAIL PROTECTED]
+eval(`2 = 2')
[EMAIL PROTECTED]:stdin:1: Warning: recommend ==, not =, for equality operator
[EMAIL PROTECTED]
+eval(`++0')
[EMAIL PROTECTED]:stdin:2: invalid operator in eval: ++0
[EMAIL PROTECTED]
+eval(`0 |= 1')
[EMAIL PROTECTED]:stdin:3: invalid operator in eval: 0 |= 1
[EMAIL PROTECTED]
[EMAIL PROTECTED] example
Note that some older @code{m4} implementations use @samp{^} as an
alternate operator for the exponentiation, although @acronym{POSIX}
@@ -4492,7 +4510,6 @@
implementations of @code{m4} require explicit parentheses to get the
correct result:
[EMAIL PROTECTED] status: 1
@example
eval(`1 == 2 > 0')
@result{}1
@@ -4508,24 +4525,15 @@
@result{}0
eval(`+ + - ~ ! ~ 0')
@result{}1
-eval(`++0')
[EMAIL PROTECTED]:stdin:8: invalid operator in eval: ++0
[EMAIL PROTECTED]
-eval(`1 = 1')
[EMAIL PROTECTED]:stdin:9: invalid operator in eval: 1 = 1
[EMAIL PROTECTED]
-eval(`0 |= 1')
[EMAIL PROTECTED]:stdin:10: invalid operator in eval: 0 |= 1
[EMAIL PROTECTED]
eval(`2 || 1 / 0')
@result{}1
eval(`0 || 1 / 0')
[EMAIL PROTECTED]:stdin:12: divide by zero in eval: 0 || 1 / 0
[EMAIL PROTECTED]:stdin:9: divide by zero in eval: 0 || 1 / 0
@result{}
eval(`0 && 1 % 0')
@result{}0
eval(`2 && 1 % 0')
[EMAIL PROTECTED]:stdin:14: modulo by zero in eval: 2 && 1 % 0
[EMAIL PROTECTED]:stdin:11: modulo by zero in eval: 2 && 1 % 0
@result{}
@end example
@@ -5672,7 +5680,9 @@
ensure proper precedence. As extensions to @acronym{POSIX},
@acronym{GNU} @code{m4} gives well-defined semantics to operations that
C leaves undefined, such as when overflow occurs, when shifting negative
-numbers, or when performing division by zero.
+numbers, or when performing division by zero. @acronym{POSIX} also
+requires @samp{=} to cause an error, but many traditional
+implementations allowed it as an alias for @samp{==}.
@item
@acronym{POSIX} requires @code{translit} (@pxref{Translit}) to treat