m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

format(%a)


From: Eric Blake
Subject: format(%a)
Date: Wed, 7 Mar 2007 15:30:59 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Gnulib is awesome!  Even though cygwin doesn't (yet) support printf("%a"), the 
format builtin does just fine on cygwin with this deceptively simple patch:

2007-03-07  Eric Blake  <address@hidden>

        Exercise gnulib's new POSIX *printf modules.
        * ltdl/m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
        vasprintf-posix'.
        * modules/format.c (format): Support %a and %A.
        * doc/m4.texinfo (Format): Test this addition.
        * NEWS: Document this addition.

Index: NEWS
===================================================================
RCS file: /sources/m4/m4/NEWS,v
retrieving revision 1.40
diff -u -r1.40 NEWS
--- NEWS        28 Feb 2007 21:31:12 -0000      1.40
+++ NEWS        7 Mar 2007 15:28:47 -0000
@@ -164,6 +164,9 @@
 *** The `eval' and `mpeval' builtins now support the following new
     operators: `>>>', `\', `?:', and  `,'.
 
+*** The `format' builtin now supports the C99 specifiers of %a and %A, even
+    on platforms that don't yet support C99.
+
 *** 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
     the recommendation of POSIX to obsolete `maketemp' as inherently
Index: ltdl/m4/gnulib-cache.m4
===================================================================
RCS file: /sources/m4/m4/ltdl/m4/gnulib-cache.m4,v
retrieving revision 1.22
diff -u -r1.22 gnulib-cache.m4
--- ltdl/m4/gnulib-cache.m4     5 Feb 2007 16:20:25 -0000       1.22
+++ ltdl/m4/gnulib-cache.m4     7 Mar 2007 15:28:47 -0000
@@ -15,11 +15,11 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnu --m4-
base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --libtool --macro-prefix=M4 
assert avltree-oset binary-io clean-temp cloexec close-stream closeout config-h 
configmake dirname error exit fdl filenamecat fopen-safer free gendocs gettext 
gnupload mkstemp obstack progname regex regexprops-generic stdbool stdlib-safer 
strnlen strtol tempname unlocked-io verror xalloc xalloc-die xstrndup xstrtol 
xvasprintf
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnu --m4-
base=ltdl/m4 --doc-base=doc --aux-dir=ltdl/config --libtool --macro-prefix=M4 
assert avltree-oset binary-io clean-temp cloexec close-stream closeout config-h 
configmake dirname error exit fdl filenamecat fopen-safer free gendocs gettext 
gnupload mkstemp obstack progname regex regexprops-generic stdbool stdlib-safer 
strnlen strtol tempname unlocked-io vasprintf-posix verror xalloc xalloc-die 
xstrndup xstrtol xvasprintf
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
-gl_MODULES([assert avltree-oset binary-io clean-temp cloexec close-stream 
closeout config-h configmake dirname error exit fdl filenamecat fopen-safer 
free gendocs gettext gnupload mkstemp obstack progname regex regexprops-generic 
stdbool stdlib-safer strnlen strtol tempname unlocked-io verror xalloc xalloc-
die xstrndup xstrtol xvasprintf])
+gl_MODULES([assert avltree-oset binary-io clean-temp cloexec close-stream 
closeout config-h configmake dirname error exit fdl filenamecat fopen-safer 
free gendocs gettext gnupload mkstemp obstack progname regex regexprops-generic 
stdbool stdlib-safer strnlen strtol tempname unlocked-io vasprintf-posix verror 
xalloc xalloc-die xstrndup xstrtol xvasprintf])
 gl_AVOID([])
 gl_SOURCE_BASE([gnu])
 gl_M4_BASE([ltdl/m4])
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.101
diff -u -r1.101 m4.texinfo
--- doc/m4.texinfo      3 Mar 2007 21:10:24 -0000       1.101
+++ doc/m4.texinfo      7 Mar 2007 15:28:47 -0000
@@ -66,9 +66,9 @@
 @title GNU M4, version @value{VERSION}
 @subtitle A powerful macro processor
 @subtitle Edition @value{EDITION}, @value{UPDATED}
address@hidden by Ren@'e Seindal
address@hidden and Gary V. Vaughan
address@hidden and Eric Blake
address@hidden by Ren@'e Seindal, Fran@,{c}ois Pinard,
address@hidden Gary V. Vaughan, and Eric Blake
address@hidden (@email{bug-m4@@gnu.org})
 
 @page
 @vskip 0pt plus 1filll
@@ -431,11 +431,11 @@
 say what you expected to occur; this will help us decide whether the
 problem was really in the documentation.
 
-Once you've got a precise problem, send e-mail to (Internet)
+Once you've got a precise problem, send e-mail to
 @email{bug-m4@@gnu.org}.  Please include the version number of @code{m4}
 you are using.  You can get this information with the command
address@hidden --version}.  You can also run @kbd{make check} to generate the 
file
address@hidden/@/testsuite.log}, useful for including in your report.
address@hidden --version}.  You can also run @kbd{make check} to generate the
+file @file{tests/@/testsuite.log}, useful for including in your report.
 
 Non-bug suggestions are always welcome as well.  If you have questions
 about things that are unclear in the documentation or are just obscure
@@ -5996,6 +5996,10 @@
 @result{}56790
 len(format(`%-*X', `5000', `1'))
 @result{}5000
+ifelse(format(`%.1A', `1.999'), `0X1.0P+1', `success',
+       format(`%.1A', `1.999'), `0X2.0P+0', `success',
+       `fail')
address@hidden
 @end example
 
 Using the @code{forloop} macro defined earlier (@pxref{Forloop}), this
@@ -6022,13 +6026,15 @@
 @end example
 
 The builtin @code{format} is modeled after the ANSI C @samp{printf}
-function, and supports these @samp{%} specifiers: @samp{c},
address@hidden, @samp{d}, @samp{o}, @samp{x}, @samp{X}, @samp{u}, @samp{e},
address@hidden, @samp{f}, @samp{F}, @samp{g}, @samp{G}, and @samp{%}; it
-supports field widths and precisions, and the
-modifiers @samp{+}, @samp{-}, @address@hidden }}, @samp{0}, @samp{#}, @samp{h} 
and
+function, and supports these @samp{%} specifiers: @samp{c}, @samp{s},
address@hidden, @samp{o}, @samp{x}, @samp{X}, @samp{u}, @samp{a}, @samp{A},
address@hidden, @samp{E}, @samp{f}, @samp{F}, @samp{g}, @samp{G}, and
address@hidden; it supports field widths and precisions, and the modifiers
address@hidden, @samp{-}, @address@hidden }}, @samp{0}, @samp{#}, @samp{h} and
 @samp{l}.  For more details on the functioning of @code{printf}, see the
-C Library Manual.
+C Library Manual, or the @acronym{POSIX} specification (for example,
address@hidden is supported even on platforms that haven't yet implemented
+C99 hexadecimal floating point output natively).
 
 @c FIXME - format still needs some improvements.
 For now, unrecognized specifiers are silently ignored, but it is
Index: modules/format.c
===================================================================
RCS file: /sources/m4/m4/modules/format.c,v
retrieving revision 1.20
diff -u -r1.20 format.c
--- modules/format.c    27 Oct 2006 04:03:28 -0000      1.20
+++ modules/format.c    7 Mar 2007 15:28:47 -0000
@@ -1,5 +1,5 @@
 /* GNU m4 -- A simple macro processor
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2001, 2006
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2001, 2006, 2007
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -205,6 +205,8 @@
            }
          break;
 
+       case 'a':
+       case 'A':
        case 'e':
        case 'E':
        case 'f':






reply via email to

[Prev in Thread] Current Thread [Next in Thread]