summaryrefslogtreecommitdiff
path: root/usr.bin/jot
AgeCommit message (Collapse)Author
2019-06-27Some asprintf() calls were checked < 0, rather than the precise == -1.Theo de Raadt
ok millert nicm tb, etc
2018-08-01Use a single space after colon in another errx().Theo Buehler
Pointed out by Kris Katterjohn
2018-08-01Disallow negative reps, they make no sense. While here, sscanf -> strtonum.cheloha
From Kris Katterjohn on tech@. ok tb@
2018-06-24Fix a quirk noticed by espie@: let "jot" without any argument do theIngo Schwarze
same as "jot -", to match the description in the manual page. Very similar patch independently developed by tb@. OK tb@ espie@
2018-01-13Adjust comment to reflect '%F' addition.Theo Buehler
2018-01-13Allow printf '%F' format specifier.Theo Buehler
ok millert
2018-01-12Align cases in conversion switch vertically. Normalize logic inside casesTheo Buehler
and drop an unnecessary test for intdata in '%c'. reads ok to halex, ok millert
2018-01-11Remove arbitary length limits for -s, -b and -w. Based on a diff from kshe.Theo Buehler
schwarze suggested using asprintf, which led to a substantial cleanup. ok schwarze, help & ok millert
2017-12-30Simplify switch by removing some unneeded cases.Theo Buehler
from kshe
2017-12-30Avoid one-byte overflow in error path. If the format string ends in anTheo Buehler
invalid specifier like `%l', p will already point to the trailing NUL upon entering the switch, wherein the instruction *++p = '\0'; will write another NUL after it, but there is no guarantee that the buffer extends beyond that first NUL; thus, in the rare case where it does not, this assignment will write one byte past its end. from kshe
2017-12-15Use the canonical idiom to check strlcat(3). An unchecked strlcat callTheo Buehler
led to unexpected output: compare 'jot -w $(printf %1020s)%d%' 1 1' with 'jot -w $(printf %1019s)%d%' 1 1'. found by & ok martijn
2017-12-15Instead of pointlessly falling through other cases and ending up doingTheo Buehler
goto fmt_broken, do it explicitly. Makes following the code path through the switch a bit easier. Prompted by a request by martijn
2017-12-15Make sure the double is cast to a long if the format string is %D, %O, %U.Theo Buehler
Fixes output of e.g. 'jot -w %D 11 -5'. ok martijn
2016-09-02style cleanup: sort headers; group and sort variables; no parens forTheo Buehler
return; sort getopt string and corresponding switch; and some more tedious stuff ok martijn
2016-08-16Streamline and refactor the code a bit more:Theo Buehler
There are two sentinels for infinite output: infinity == true and reps == 0. Ensure that infinity is set to true whenever reps is set to zero, then we can always use 'if (infinity)'. This allows us to merge the loop for deterministic output into the first if (!randomize) statement, which is a lot tidier. Insert an occasional empty line. "move fast and break stuff" tedu
2016-08-12Simplify getprec() by using strchr(3) and strspn(3).Theo Buehler
Part of NetBSD's jot r1.20 by dsl. ok jca
2016-08-12Rewrite the paragraphs that describe how the last four arguments areTheo Buehler
handled to make them easier to read and understand. with help from jmc
2016-08-12usage() is __deadTheo Buehler
2016-08-12The last four argumens of jot (reps, begin, end, step) can all beTheo Buehler
specified or omitted, yielding 16 possible combinations, plus a few special cases. Instead of hardcoded values, use names to make the bit patterns that indicate which values were specified human readable. Decide once and for all what to do in a single switch statement. Don't enter said switch when random output is requested since that simply makes no sense at all. While there, make the error messages a bit more meaningful and fix a bogus value assigned to begin for jot -r x - y z that has been there since -r1.1. All regression tests now pass. Inspired by David Laight (dsl)'s r1.21 of NetBSD's jot. "move fast and break stuff" tedu agreement from deraadt
2016-08-05All four arguments can be omitted by specifying a dash.Theo Buehler
While there, remove a superfluous 's'. discussed with jmc
2016-08-05If reps and steps were omitted, while begin and end were specified,Theo Buehler
use a default step size of +1 or -1. Fixes the last two failing regression tests dhhd and dhhd2. Adapted from FreeBSD. 'good direction' deraadt
2016-08-05If "%%" appears in the format string, skip it properly.Theo Buehler
Part of pjanzen's fixes in r1.8, but was lost in r1.17. Fixes regression tests wp3, wp4, wp5. 'good direction' deraadt
2016-08-05Initialize reps, begin, end, steps to their defaults.Theo Buehler
Makes jot - - - - behave the same way as jot -, jot - - and jot - - - instead of spurting out zeroes indefinitely. Fixes the dddd regression test and matches FreeBSD and NetBSD. From attila () stalphonsos ! com, thanks! 'good direction' deraadt
2016-07-17Remove now obsolete parenthetical explanation (should have been part ofTheo Buehler
previous commit).
2016-07-171. Update manpage in view of the change of behavior I introduced in -r1.27.Theo Buehler
The bounds are taken inclusive and -w %d doesn't change the output of integer random sequences anymore. This is the same behavior as that of Linux and NetBSD, but differs from FreeBSD and OS X. Issue reported by Philippe Meunier on misc@. 2 Fix a bug from the same commit observed by Otto: if the precision is 0, values may be printed out of bounds. Fall back to the old behavior if at least one bound isn't an integer. General agreement expressed by otto@, tedu@, jmc@, sobrado@ Help with checking other operating systems by sobrado@. Manpage ok jmc@. Bugfix discussed with otto@ on icb
2016-01-10Random sequences generated by jot -r have been suffering from a dramatictb
bias at both ends of the given interval. Various clever workarounds are documented in the manual. This fixes the bias in some of the most common use cases, namely random sequences of integers or real numbers rounded to a fixed number of decimals. So, `jot -p 3 -r 10000 0 1' produces a uniformly distributed sequence of 10,000 decimal numbers of the form 0.abc (or 1). Internally, jot -r now uses arc4random_uniform() whenever this is clearly possible. In particular `jot -r 1 10 20' yields an unbiased random number between 10 and 20 (both ends inclusive) from the shell. guidance and ok deraadt@, "i like it" benno@
2016-01-04Add HISTORY and AUTHORS sections.Ingo Schwarze
From the author John A. Kunze via https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196786 and Michal Mazurek <akfaew at jasminek dot net>. Correctness also verified from the CSRG archive CD.
2015-10-09Change all tame callers to namechange to pledge(2).Theo de Raadt
2015-10-06obvious tame "stdio"Theo de Raadt
2015-07-21whitespaceJasper Lievisse Adriaanse
2014-01-20Obvious .Xr fixes, found while testing mandocdb(8).Ingo Schwarze
2013-11-26unsigned char casts for ctypeTheo de Raadt
ok krw
2013-11-15Include unistd.h as it is the standard location for getopt().Todd C. Miller
From Eitan Adler
2012-01-30typo in error message; ok krw@Okan Demirmen
2011-12-03Remove an OpenBSD-specific tweak regarding .Xr spacingIngo Schwarze
and make it compatible with bsd.lv mandoc and with groff-1.21. This tweak was originally added for compatibility with groff-1.15, which is no longer needed. ok jmc@ kristaps@
2009-10-28rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andTheo de Raadt
unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
2007-05-31convert to new .Dd format;Jason McIntyre
2007-05-01use strtonum; ok millert@Jason Dixon
2005-09-06Fix example that uses rs(1)Todd C. Miller
2005-04-11handle -1 potential case from snprintf tooTheo de Raadt
2004-01-08Pass the right type based on the conversion specified; warn on conversionOtto Moerbeek
errors. Mostly from FreeBSD.
2004-01-01Explain how jot does rounding and truncation. Help from jmc@Otto Moerbeek
ok jmc@ millert@ deraadt@
2003-12-30o From FreeBSD: use the max_value(u_int32_t) + 1 to divide the random number.Otto Moerbeek
o Document and warn that seeding the random generator is no longer supported since arc4random is used as the RG. ok jose@ millert@
2003-12-29Cleanup: KNF, -Wall, do not use pointers if the actual var isOtto Moerbeek
available, plus some other minor cleanup. New features: Allow explicit precision 0. For infinite sequences, do not print trailing newline if the counter wraps. Testing by henning@ and jmc@ ok deraadt@
2003-12-18random numbers are obtained via arc4random(3), not random(3);Jason McIntyre
from FreeBSD PR 54879, forwarded by otto@; ok otto@
2003-12-15jot.1:Jason McIntyre
- use .Bk/.Ek for SYNOPSIS - sort options - better -width for options list - reword examples to make them clearer - fix broken example, as reported by Takanori Isihara jot.c: - sync usage() with SYNOPSIS
2003-06-10mostly ansi cleanup; pval okTheo de Raadt
2003-06-10- section reorderJason McIntyre
- COMPATIBILITY merge - macro cleanup - kill whitespace at EOL - new sentence, new line ssh pages ok markus@
2003-06-03Remove the advertising clause in the UCB license which BerkeleyTodd C. Miller
rescinded 22 July 1999. Proofed by myself and Theo.
2003-01-12Make this work on 64 bit arch'sBob Beck
ok millert@