Otherwise we end up with setting invalid printf format: "%.-1f" (from
"if (snprintf(p, sz, "%%.%df", prec) >= (int)sz)") for prec equal to -1,
which is not canonical (rejected by gcc and clang when used explicitly).
Detected by ASan (MKSANITIZER) for "jot 8".
John A. Kunze requested to add himself as the author of jot
on the FreeBSD bugzilla with the following text:
Please re-instate my name (as "John A. Kunze") as AUTHOR of the
jot, rs, and lam utilities. I wrote these in 1982, around or
before the time that I worked with Jordan at UCB (he left to work
at FreeBSD and later at Apple). Thank you!
-- https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196786
While there add a note that this tool first appeared in BSD 4.2.
This information is based on the FreeBSD manual pages.
Patch submitted by Michal Mazurek <akfaew AT jasminek.net>.
Reviewed by <dholland>
This makes 'jot - 9 - -.5' generate 9 9 8 8 etc again.
When printing random numbers generate a sane range when ender < begin.
For random integers we must use random()/2^31 since we don't want the
value above generated should random() return 2^31-1.
set the defaults at compile time and calculate any derived values in
a simple switch statement.
Use names for the bit-patterns that indicate that fields are present.
Seems to behave the same way as the earlier version.
range by 1 so that the quoted upper and lower values both appear, and
with the same frequency as the intermediate values.
This reverts the change from rev 1.13, and fixes it properly!
Also fixes 'jot -r -c - 97 98' as reported to netbsd-bugs (but not as a PR!).
bin/12316 more completely.
Highlights:
* we only allow explicitly specified set of (numberic) formats
* %% is correctly skipped, extra %foo formats are detected
* '*' in format specification is not allowed
The code in getformat() is slighly different to the OpenBSD version
of fix - the list of allowed printf(3) flags is explicit and the
condition checking 'chardata' is written slighly differently.
Also pull-in some cosmetic changes from OpenBSD - s/isdefault()/is_default()/,
error() -> errx(), usage().