CVSROOT: /sources/m4
Module name: m4
Branch: branch-1_4
Changes by: Eric Blake <ericb> 07/05/29 13:19:48
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.1.1.1.2.126
retrieving revision 1.1.1.1.2.127
diff -u -b -r1.1.1.1.2.126 -r1.1.1.1.2.127
--- doc/m4.texinfo 25 May 2007 20:29:17 -0000 1.1.1.1.2.126
+++ doc/m4.texinfo 29 May 2007 13:19:47 -0000 1.1.1.1.2.127
@@ -4887,15 +4887,27 @@
Its use is best described by a few examples:
[EMAIL PROTECTED] This test is a bit fragile, if someone tries to port to a
[EMAIL PROTECTED] platform without infinity.
@example
define(`foo', `The brown fox jumped over the lazy dog')
@result{}
format(`The string "%s" uses %d characters', foo, len(foo))
@result{}The string "The brown fox jumped over the lazy dog" uses 38 characters
+format(`%*.*d', `-1', `-1', `1')
[EMAIL PROTECTED]
format(`%.0f', `56789.9876')
@result{}56790
-len(format(`%-*X', `300', `1'))
[EMAIL PROTECTED]
+len(format(`%-*X', `5000', `1'))
[EMAIL PROTECTED]
+ifelse(format(`%010F', `infinity'), ` INF', `success',
+ format(`%010F', `infinity'), ` INFINITY', `success',
+ `fail')
[EMAIL PROTECTED]
+ifelse(format(`%.1A', `1.999'), `0X1.0P+1', `success',
+ format(`%.1A', `1.999'), `0X2.0P+0', `success',
+ `fail')
[EMAIL PROTECTED]
@end example
Using the @code{forloop} macro defined earlier (@pxref{Forloop}), this
@@ -4921,18 +4933,32 @@
@end example
The builtin @code{format} is modeled after the ANSI C @samp{printf}
-function, and supports these @samp{%} specifiers: @samp{c},
[EMAIL PROTECTED], @samp{d}, @samp{o}, @samp{x}, @samp{X}, @samp{u}, @samp{e},
[EMAIL PROTECTED], @samp{f}, @samp{F}, @samp{g}, @samp{G}, and @samp{%}; it
-supports field widths and precisions, and the
-modifiers @samp{+}, @samp{-}, @[EMAIL PROTECTED] }}, @samp{0}, @samp{#},
@samp{h} and
[EMAIL PROTECTED] For more details on the functioning of @code{printf}, see the
-C Library Manual.
-
-For now, unrecognized specifiers are silently ignored, but it is
-anticipated that a future release of @acronym{GNU} @code{m4} will support more
-specifiers, and give warnings when problems are encountered. Likewise,
-escape sequences are not yet recognized.
+function, and supports these @samp{%} specifiers: @samp{c}, @samp{s},
[EMAIL PROTECTED], @samp{o}, @samp{x}, @samp{X}, @samp{u}, @samp{a}, @samp{A},
[EMAIL PROTECTED], @samp{E}, @samp{f}, @samp{F}, @samp{g}, @samp{G}, and
[EMAIL PROTECTED]; it supports field widths and precisions, and the flags
[EMAIL PROTECTED], @samp{-}, @samp{ }, @samp{0}, @samp{#}, and @samp{'}. For
+integer specifiers, the width modifiers @samp{hh}, @samp{h}, and
[EMAIL PROTECTED] are recognized, and for floating point specifiers, the width
+modifier @samp{l} is recognized. Items not yet supported include
+positional arguments, the @samp{n}, @samp{p}, @samp{S}, and @samp{C}
+specifiers, the @samp{z}, @samp{t}, @samp{j}, @samp{L} and @samp{ll}
+modifiers, and any platform extensions available in the native
[EMAIL PROTECTED] For more details on the functioning of @code{printf},
+see the C Library Manual, or the @acronym{POSIX} specification (for
+example, @samp{%a} is supported even on platforms that haven't yet
+implemented C99 hexadecimal floating point output natively).
+
+Unrecognized specifiers result in a warning. It is anticipated that a
+future release of @acronym{GNU} @code{m4} will support more specifiers,
+and give better warnings when various problems such as overflow are
+encountered. Likewise, escape sequences are not yet recognized.
+
[EMAIL PROTECTED]
+format(`%p', `0')
[EMAIL PROTECTED]:stdin:1: Warning: unrecognized specifier in `%p'
[EMAIL PROTECTED]
[EMAIL PROTECTED] example
@node Arithmetic
@chapter Macros for doing arithmetic