groff
[Top][All Lists]
Advanced

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

Re: pic anomalies


From: Steffen Nurpmeso
Subject: Re: pic anomalies
Date: Fri, 27 Dec 2019 18:45:23 +0100
User-agent: s-nail v14.9.15-262-g449d711c

Doug McIlroy wrote in <address@hidden>:
 |The description of sprintf in the man page pic(1) does not
 |reveal that only a few format codes are permitted.
 |
 |Eric Raymond's "Making Pictures With GNU PIC" says only
 |%,%e,%f,%g are  permitted. But what does a bare % mean?
 |
 |In fact pic rejects a bare %. However it does accept
 |%%, which is supposed to print a single %. Pic,
 |however prints %%.
 |
 |So I believe we have
 |1. An incompleteness in pic(1)
 |2. An error in "Making Pictures With GNU PIC"
 |3. An error in pic itself

Should be handled by

  diff --git a/doc/pic.ms b/doc/pic.ms
  index da95de80..89ba9f37 100644
  --- a/doc/pic.ms
  +++ b/doc/pic.ms
  @@ -1652,7 +1652,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 the format strings %e, %E, %f, %g and %G,
  +as well as %% for printing a raw percent character.
   .
   .
   .NH 1
  diff --git a/man/pre-pic.1.in b/man/pre-pic.1.in
  index aae228a4..4edfe548 100644
  --- a/man/pre-pic.1.in
  +++ b/man/pre-pic.1.in
  @@ -795,6 +795,11 @@ 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
  +.B #-+ 0123456789.,
  +and the formats
  +.B eEfgG%
  +are supported.
   .
   .LP
   The thickness of the lines used to draw objects is controlled by the
  diff --git a/src/pre-pic/pic.y b/src/pre-pic/pic.y
  index c6e4c0f5..e107b7c9 100644
  --- a/src/pre-pic/pic.y
  +++ b/src/pre-pic/pic.y
  @@ -1889,6 +1889,11 @@ char *do_sprintf(const char *form, const double *v, 
int nv)
     string one_format;
     while (*form) {
       if (*form == '%') {
  +      if(form[1] == '%'){
  +        result += '%';
  +        form += 2;
  +        continue;
  +      }
         one_format += *form++;
         for (; *form != '\0' && su_cs_find_c("#-+ 0123456789.", *form) != NIL;
             form++)

in my GPLv2 tree, or as attached for groff v1.22.4.
(I have only compile-tested v1.22.4, and my tree is not at all
ready yet.)

 |Doug
 --End of <address@hidden>

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

Attachment: pic.diff
Description: Text Data


reply via email to

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