[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to m4/doc/m4.texinfo,v [branch-1_4]
From: |
Eric Blake |
Subject: |
Changes to m4/doc/m4.texinfo,v [branch-1_4] |
Date: |
Tue, 09 Jan 2007 16:12:44 +0000 |
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
address@hidden 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.
+
address@hidden status: 1
address@hidden
+eval(`2 = 2')
address@hidden:stdin:1: Warning: recommend ==, not =, for equality operator
address@hidden
+eval(`++0')
address@hidden:stdin:2: invalid operator in eval: ++0
address@hidden
+eval(`0 |= 1')
address@hidden:stdin:3: invalid operator in eval: 0 |= 1
address@hidden
address@hidden 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:
address@hidden status: 1
@example
eval(`1 == 2 > 0')
@result{}1
@@ -4508,24 +4525,15 @@
@result{}0
eval(`+ + - ~ ! ~ 0')
@result{}1
-eval(`++0')
address@hidden:stdin:8: invalid operator in eval: ++0
address@hidden
-eval(`1 = 1')
address@hidden:stdin:9: invalid operator in eval: 1 = 1
address@hidden
-eval(`0 |= 1')
address@hidden:stdin:10: invalid operator in eval: 0 |= 1
address@hidden
eval(`2 || 1 / 0')
@result{}1
eval(`0 || 1 / 0')
address@hidden:stdin:12: divide by zero in eval: 0 || 1 / 0
address@hidden:stdin:9: divide by zero in eval: 0 || 1 / 0
@result{}
eval(`0 && 1 % 0')
@result{}0
eval(`2 && 1 % 0')
address@hidden:stdin:14: modulo by zero in eval: 2 && 1 % 0
address@hidden: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