The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Doug McIlroy <doug@cs.dartmouth.edu>
To: tuhs@tuhs.org
Subject: Re: [TUHS] pic anomalies
Date: Mon, 30 Dec 2019 23:12:44 -0500	[thread overview]
Message-ID: <201912310412.xBV4Ci4P015155@tahoe.cs.Dartmouth.EDU> (raw)

According to K&R the behavior of % followed by something
unexpected is undefined. So the behavior of Ralph's example
is officially an accident. (It's uncharacteristic of Dennis
to have defined printf so that there was no guaranteed way
to get a literal % into a format.)

Doug

------------------------------------------------

Ralph Corderoy wrote:

    $ printf '%s\n' \
        .PS 'print sprintf("%.17g %.0f% % %%", 3.14, 42, 99)' .PE |
    > pic >/dev/null
    3.1400000000000001 42% % %%

Though that may seem odd to our modern C-standardised eyes, it's
understandable in that if it isn't a valid %f, etc., format specifier
then it's a literal percent sign.

             reply	other threads:[~2019-12-31  4:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-31  4:12 Doug McIlroy [this message]
2019-12-31  4:24 Doug McIlroy
2019-12-31 16:40 ` Clem Cole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201912310412.xBV4Ci4P015155@tahoe.cs.Dartmouth.EDU \
    --to=doug@cs.dartmouth.edu \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).