Hi, i pushed the documentation improvements because they were ready and esr@ OK'ed them.
Regarding the bugfix in the code, thanks to Larry McVoy for providing feedback directly to me. In particular, he suggested that while my fix wasn't incorrect, the two lines immediately following it can be simplified, making the code easier to read. There may be opportunity for major cleanup in this code, too, but i don't think that should be mixed into a bugfix. The simplification of these two lines, however, is so closely related to the bugfix that it seems reasonable to include it. Any OKs for the patch in the following form? Thanks, Ingo commit 7cdbc2233d93e8e47b585a5b47319efde61980e1 Author: Ingo Schwarze <schwa...@openbsd.org> Date: Fri Dec 27 21:09:24 2019 +0100 Correct output of sprintf("%%") in pic(1). * src/preproc/pic/pic.ypp: Print "%" rather than "%%". Bug reported by Doug McIlroy <doug at cs dot dartmouth dot edu>. Patch using feedback from Larry McVoy <lm at mcvoy dot com>. diff --git a/ChangeLog b/ChangeLog index 90792bd1..f2357719 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2019-12-29 Ingo Schwarze <schwa...@openbsd.org> + + Correct output of sprintf("%%") in pic(1). + + * src/preproc/pic/pic.ypp: Print "%" rather than "%%". + + Bug reported by Doug McIlroy <doug at cs dot dartmouth dot edu>. + Patch using feedback from Larry McVoy <lm at mcvoy dot com>. + 2019-12-29 Ingo Schwarze <schwa...@openbsd.org> Improve documentation of pic(1) regarding printf. diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp index 6afa2ab3..92d2bb1c 100644 --- a/src/preproc/pic/pic.ypp +++ b/src/preproc/pic/pic.ypp @@ -1905,10 +1905,8 @@ char *do_sprintf(const char *form, const double *v, int nv) break; } if (*form == '%') { - one_format += *form++; - one_format += '\0'; - snprintf(sprintf_buf, sizeof(sprintf_buf), - "%s", one_format.contents()); + form++; + snprintf(sprintf_buf, sizeof(sprintf_buf), "%%"); } else { if (i >= nv) {