groff
[Top][All Lists]
Advanced

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

Re: pic anomalies


From: Ingo Schwarze
Subject: Re: pic anomalies
Date: Fri, 27 Dec 2019 22:27:05 +0100
User-agent: Mutt/1.12.2 (2019-09-21)

Hi Doug,

Steffen Nurpmeso wrote on Fri, Dec 27, 2019 at 06:45:23PM +0100:

> Should be handled by [...]

I believe the first patch that got sent to the list is incorrect.

The parser in src/pre-pic/pic.y already parses '%%' correctly, so
there is no need to change the parsing.  Only the assignment to
one_format needs to be corrected.  Besides, the "continue;" that
was inserted feels premature; i think appending to "result" at the
end of the while loop is still needed.

The existing text in doc/pic.ms uses the term "format string"
incorrectly.  That's the complete first argument to sprintf(3).
Saying that the format string must be "%e" would mean that the
argument cannot contain any additional characters.  The correct
term for something like "%e" according to the C standard is
"conversion specification".  Note that according to the C standard,
"%%" is also a conversion specification, so there is no need to
describe it using more words.

With respect to src/preproc/pic/pic.1.man, "0123456789." are not
flags, so let's use a better wording.

Doug, thank you for your report.  Could you please test and confirm
that this patch fixes all the issues you found?

Yours,
  Ingo


commit 78667baa4e207359b071ccfe884c4783c721d3e6
Author: Ingo Schwarze <address@hidden>
Date:   Fri Dec 27 21:09:24 2019 +0100

    Fix code and documentation in pic(1) regarding printf.
    
     * src/preproc/pic/pic.ypp:
       Let the "%%" conversion specification print "%" rather than "%%".
     * src/preproc/pic/pic.1.man:
       Document which conversion specifications are supported.
     * doc/pic.ms:
       Correct the list of supported conversion specifications.
    
    All three bugs were reported by
    Doug McIlroy <doug at cs dot dartmouth dot edu>.

diff --git a/ChangeLog b/ChangeLog
index 727c3673..6fcb45e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2019-12-27  Ingo Schwarze  <address@hidden>
+
+       Fix code and documentation in pic(1) regarding printf.
+
+       * src/preproc/pic/pic.ypp:
+         Let the "%%" conversion specification print "%" rather than "%%".
+       * src/preproc/pic/pic.1.man:
+         Document which conversion specifications are supported.
+       * doc/pic.ms:
+         Correct the list of supported conversion specifications.
+
+       All three bugs were reported by
+       Doug McIlroy <doug at cs dot dartmouth dot edu>.
+
 2019-12-21  Ingo Schwarze  <address@hidden>
 
        Update NetBSD, OpenBSD, FreeBSD, Darwin, and DragonFly version strings.
diff --git a/doc/pic.ms b/doc/pic.ms
index 6d581ba3..b7dfe32f 100644
--- a/doc/pic.ms
+++ b/doc/pic.ms
@@ -1722,7 +1722,8 @@ GNU \fBgpic\fP also documents a one-argument form or rand,
 version.
 .PP
 The function \fBsprintf()\fP behaves like a C \fIsprintf\/\fP(3)
-function that only takes %, %e, %f, and %g format strings.
+function that only takes %%, %e, %E, %f, %g, and %G conversion
+specifications.
 .
 .
 .NH 1
diff --git a/src/preproc/pic/pic.1.man b/src/preproc/pic/pic.1.man
index ae4c205c..281a69e3 100644
--- a/src/preproc/pic/pic.1.man
+++ b/src/preproc/pic/pic.1.man
@@ -906,6 +906,20 @@ this will produce the arguments formatted according to
 which should be a string as described in
 .BR printf (3)
 appropriate for the number of arguments supplied.
+Only the flags
+.RB ' # ',
+.RB ' \- ',
+.RB ' + ',
+and '\ ' (space), a minimum field width, an optional precision,
+and the conversion specifications
+.BR %e ,
+.BR %E ,
+.BR %f ,
+.BR %g ,
+.BR %G ,
+and
+.B %%
+are supported.
 .
 .
 .LP
diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp
index 6afa2ab3..b6a6b241 100644
--- a/src/preproc/pic/pic.ypp
+++ b/src/preproc/pic/pic.ypp
@@ -1905,7 +1905,7 @@ char *do_sprintf(const char *form, const double *v, int 
nv)
        break;
       }
       if (*form == '%') {
-       one_format += *form++;
+       form++;
        one_format += '\0';
        snprintf(sprintf_buf, sizeof(sprintf_buf),
                 "%s", one_format.contents());



reply via email to

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