Commit Graph

43 Commits

Author SHA1 Message Date
kamil 5dc82c03ce Generate format after setting the prec value
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".
2020-06-14 01:26:46 +00:00
simonb 48c051401b Document the default values for options in a way that hopefully makes
much more sense.
2020-04-25 11:11:33 +00:00
mrg fbffadb9f8 - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily
2019-02-03 03:19:25 +00:00
christos fd98358317 Don't require any arguments as the usage indicates; simplifies the code
and the documentation: now "jot" works like "jot -" used to (and continues
to). From Ingo Schwarze
2018-06-25 14:29:17 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
kamil 4929734205 Bump date for previous 2016-01-04 23:55:36 +00:00
kamil 1b333769e1 Add HISTORY and AUTHORS to jot
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>
2016-01-04 23:32:45 +00:00
wiz 1ac719d147 Remove unnecessary Bk/Ek pairs from SYNOPSIS.
No effective change except where I used the opportunity to sort options
and/or option descriptions.
2012-04-08 22:00:37 +00:00
christos 5353040f23 document non-literal format strings 2011-08-16 10:35:03 +00:00
apb 71bcc2da8f Add an example of generating a list of integers; make it the first
example.  Also add a reference to seq(1).
2011-01-05 19:59:48 +00:00
lukem 39a84db38a fix sign-compare issue 2009-04-12 11:19:18 +00:00
joerg 223f3c1eab Use semantic markup 2009-03-11 13:53:30 +00:00
lukem 98e5374ccb Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 14:19:20 +00:00
dsl 9890613c15 Fix integer random numbers when bounds given in the wrong order. 2008-04-21 20:33:41 +00:00
dsl 1b00238d8c When printing non-random integers, add 0.5 to get 'schoolboy' rounding.
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.
2008-03-02 21:33:42 +00:00
dsl 93190b890c Remove the loop used to set default and calculated parameters, instead
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.
2008-02-29 22:43:48 +00:00
dsl f127a329db Sprinkle 'static' and 'EXIT_FAILURE'. Use getopt().
Simplify getprec() using libc functions.
Code from me partially inspired by a diff sent by xtos.
2008-02-27 22:47:32 +00:00
dsl e16564a11e Remove a 9 from the stuttered example in order to match the only
possible reality.
2008-02-24 00:05:31 +00:00
dsl 2791dfc743 When converting fp values to integer, use floor(x) so that we get
consistent convertions not the 'round to even'.
This means that it is possibly to generate the 'stuttered' sequence
4 4 3 3 2 2 1 1 0 0 -1 -1.
2008-02-24 00:04:00 +00:00
dsl 9d6613d400 Rename 's' to 'step', allow a precision of 0 to be specified (overriding
the value determined from 'begin' and 'end').
2008-02-23 23:59:59 +00:00
dsl a357ac4921 If we are doing a random integer (or character) format, then increase the
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!).
2008-02-23 22:46:10 +00:00
dsl c4d8b28d09 Remove some pointless indirections and add {} around some long single
statements.
2008-02-23 22:26:41 +00:00
peter e263dfd62f WFORMAT is no more... 2006-10-08 17:52:28 +00:00
christos 7afd9e136a PR/33709: Kevin Massey: Avoid stack smashing in args copy 2006-06-13 03:22:00 +00:00
garbled d8817d5ac1 Apply modified fix for PR bin/23763
jot(1)'s output now matches the examples given in the manpage.
2006-01-07 07:09:01 +00:00
perry 10e955c2f8 de-__P, ANSIfy prototypes 2006-01-04 01:44:06 +00:00
peter 2c12af6a77 Sort options, standardize usage message.
ok wiz@
2004-11-22 17:34:24 +00:00
jmmv b635f565e7 Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
2004-01-05 23:23:32 +00:00
agc 89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
wiz 990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
atatat 3db0e47b56 Make the randomness a tad more random. It's still not terribly
random, but it's considerably less lame now.

before% echo `jot -r 5` ; echo `jot -r 5`
66 5 78 82 66
66 5 78 82 66

after% echo `jot -r 5` ; echo `jot -r 5`
15 94 47 32 25
78 52 73 52 47
2002-09-27 20:54:51 +00:00
ross 2a76afae02 Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:36:18 +00:00
simonb 618d628845 Reverse the if and else clauses for the chardata test if there is
no format string specified.

Fixes PR bin/12424 from Jim Bernard.
2001-03-17 11:43:06 +00:00
jdolecek 507cbfd5d0 Use patch provided Paul Janzen <pjanzen@OpenBSD.org> to fix
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().
2001-03-14 07:50:06 +00:00
jdolecek 13cb1a6488 Don't coredump if format given via -w doesn't contain alphanumeric
character; in such case, warn user the format is invalid.

This addresses bin/12316 by Perry E. Metzger.
2001-03-02 21:17:31 +00:00
is 135600f947 More format string cleanup by sommerfeld. 2000-10-11 14:46:00 +00:00
mycroft a1c657fe56 Clean up SYNOPSIS formatting. 1999-03-07 11:29:58 +00:00
christos 844b3dce90 char -> unsigned char 1998-12-19 17:06:20 +00:00
mycroft a2fa91a9c4 Reformat in mandoc. 1997-11-01 04:58:39 +00:00
lukem ac4e9aa74a WARNSify, fix .Nm usage, deprecate register, use <err.h> 1997-10-19 03:32:11 +00:00
pk 22e62219f7 Allocate proper storage.
Avoid interpretation of boring words as printf(3) style format strings.
1994-12-02 20:29:43 +00:00
jtc 6e0c4ded79 Changed to conform to NetBSD's new RCS Id convention. 1994-11-14 20:27:21 +00:00
jtc 9636069c3e imported from 4.4lite 1994-11-14 20:11:58 +00:00