CVSROOT: /sources/m4
Module name: m4
Changes by: Eric Blake <ericb> 06/08/25 15:34:09
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- doc/m4.texinfo 24 Aug 2006 00:25:04 -0000 1.33
+++ doc/m4.texinfo 25 Aug 2006 15:34:09 -0000 1.34
@@ -838,6 +838,7 @@
@result{}
@end example
[EMAIL PROTECTED]
is the empty string, and double-quoting turns into single-quoting.
@comment ignore
@@ -1137,7 +1138,7 @@
Unquoted strings on either side of a quoted string are subject to
being recognized as macro names. In the following example, quoting the
-empty string allows for the @code{macro} to be recognized as such:
+empty string allows for the second @code{macro} to be recognized as such:
@example
define(`macro', `m')
@@ -1174,14 +1175,40 @@
If the name is followed by an opening parenthesis, the arguments will be
collected before the macro is called. If too few arguments are
-supplied, the missing arguments are taken to be the empty string. If
-there are too many arguments, the excess arguments are ignored. Leading
-whitespace are stripped of all arguments.
+supplied, the missing arguments are taken to be the empty string.
+However, some builtins are documented to behave differently for a
+missing optional argument than for an explicit empty string. If
+there are too many arguments, the excess arguments are ignored.
+Unquoted leading whitespace is stripped off all arguments.
Normally @code{m4} will issue warnings if a builtin macro is called
with an inappropriate number of arguments, but it can be suppressed with
-the @samp{-Q} command line option. For user defined macros, there is no
-check of the number of arguments given.
+the @option{--quiet} command line option (or @option{--silent}, or
[EMAIL PROTECTED], @pxref{Invoking m4}). For user
+defined macros, there is no check of the number of arguments given.
+
[EMAIL PROTECTED]
+$ @kbd{m4}
+index(`abc')
[EMAIL PROTECTED]:input.m4:1: Warning: index: too few arguments: 1 < 2
[EMAIL PROTECTED]
+index(`abc',)
[EMAIL PROTECTED]
+index(`abc', `b', `ignored')
[EMAIL PROTECTED]:input.m4:3: Warning: index: extra arguments ignored: 3 > 2
[EMAIL PROTECTED]
[EMAIL PROTECTED] example
+
[EMAIL PROTECTED] options: -Q
[EMAIL PROTECTED]
+$ @kbd{m4 -Q}
+index(`abc')
[EMAIL PROTECTED]
+index(`abc',)
[EMAIL PROTECTED]
+index(`abc', `b', `ignored')
[EMAIL PROTECTED]
[EMAIL PROTECTED] example
Macros are expanded normally during argument collection, and whatever
commas, quotes and parentheses that might show up in the resulting
@@ -1193,11 +1220,33 @@
bar(a foo, d)
@end example
[EMAIL PROTECTED]
is a macro call with four arguments, which are @samp{a }, @samp{b},
@samp{c} and @samp{d}. To understand why the first argument contains
whitespace, remember that leading unquoted whitespace is never part
of an argument, but trailing whitespace always is.
+It is possible for a macro's definition to change during argument
+collection, in which case the expansion uses the definition that was in
+effect at the time the opening @samp{(} was seen.
+
[EMAIL PROTECTED]
+define(`f', `1')
[EMAIL PROTECTED]
+f(define(`f', `2'))
[EMAIL PROTECTED]
+f
[EMAIL PROTECTED]
[EMAIL PROTECTED] example
+
+It is an error if the end of file occurs while collecting arguments.
+
[EMAIL PROTECTED]
+define(
+^D
[EMAIL PROTECTED]:input.m4:1: ERROR: end of file in argument list
[EMAIL PROTECTED] example
+
@node Quoting Arguments
@section Quoting macro arguments