Commit Graph

51 Commits

Author SHA1 Message Date
Xin LI
82417e9f03 Use explicit braces to avoid ambiguous else. 2006-12-09 15:23:20 +00:00
Diomidis Spinellis
f88b45d7df Prevent buffer overflow when forcibly terminating an escape character.
Obtained from:	OpenBSD
Note: In the case of a full buffer the OpenBSD implementation will
leave in the format string an invalid escape sequence.  This appears
to be harmless with our C library, but according to C99 this can
cause undefined behavior.

MFC after:      2 weeks
2006-12-03 17:50:21 +00:00
Diomidis Spinellis
34785a9fc0 Correct handling of format strings with escaped % specifications.
Note: It would be nice to be able to implement getformat() using
fmtcheck(3), but fmtcheck does not distinguish between signed and
unsigned types, a facility jot needs to perform range checks on its
output.

Submitted by:   Per Kristian Hove
MFC after:	2 weeks
2006-12-03 17:05:04 +00:00
Diomidis Spinellis
3241f274f1 Style facelift.
- Reduce the number of global variables
- Make global objects static
- Use bool consistently
- Sort getopt arguments and their processing
- Add function comments
- Change notlast != 0 into !last
2006-11-06 15:58:35 +00:00
Diomidis Spinellis
7d71f06cb4 Use a more sensible default of 1 or -1 when only the start and
end values are specified.

PR:		bin/68981
Submitted by:	Stefan `Sec` Zehl
MFC after:	2 weeks
2006-11-06 15:11:50 +00:00
Diomidis Spinellis
d129c68a14 Do What I Mean when the user asks for random integers or characters.
Up to now jot would fail to generate the last character in the range
or skew the integer distribution in a way that would generate the numbers
in the range's limits with half the probability of the rest.

This modification fixes the program, rather than documenting the
strange behavior, as suggested in docs/54879.

Also, correctly specify the range of random(3).

PR:		docs/54879
MFC after:	2 weeks
2006-11-06 13:55:11 +00:00
Diomidis Spinellis
fee14f30e9 Avoid negative array indices: an empty string can also be used
to specify a default value.
2006-11-06 11:03:43 +00:00
Diomidis Spinellis
1ab8c5be60 See also arc4random
PR:		docs/54879
MFC after:	2 weeks
2006-11-06 10:39:49 +00:00
Diomidis Spinellis
a26a66124e Restore jot's ability to use a seed for producing a deterministic
sequence of random numbers.
This functionality was lost in revision 1.9 when the random number
generator was switched to arc4random.

PR:		docs/54879
MFC after:	2 weeks
2006-11-06 10:30:29 +00:00
Diomidis Spinellis
55f965ae6a Replace obscure aliases through pointers with plain variables.
MFC after:	2 weeks
2006-11-06 09:15:21 +00:00
Diomidis Spinellis
d737ec1ad4 Merge code in common cases.
Verified by:	New regression tests in tools/regression/usr.bin/jot
MFC after:	2 weeks
2006-11-06 08:47:41 +00:00
Diomidis Spinellis
afe53a4950 Replace opaque numeric bit flag values with #defined identifiers.
While there, add some missing FALLTHROUGH comments.

Verified with:	cmp(1) on the executable
MFC after:	2 weeks
2006-11-06 07:26:16 +00:00
Colin Percival
04f064d680 Document that jot(1), rs(1), and lam(1) first appeared in 4.2BSD.
MFC after:	1 month
2006-10-20 04:31:01 +00:00
Ruslan Ermilov
6c7216df78 Sort sections. 2005-01-18 13:43:56 +00:00
Ruslan Ermilov
a866e17077 Added the EXIT STATUS section where appropriate. 2005-01-17 07:44:44 +00:00
Tim J. Robbins
911a3ff97b Avoid passing negative values to <ctype.h> functions on machines with
signed chars.
2004-07-16 05:10:46 +00:00
Ruslan Ermilov
6a3e8b0adc Mechanically kill hard sentence breaks. 2004-07-02 22:22:35 +00:00
David Schultz
bbc7056be8 Fix jot so that 'jot -r -w %d 1 1 4' never prints 4. Previously, it
would print it with probability 1/2**32.  It seems that the correct
behavior is to print 4 with probability 1/4, but I'd like to avoid
breaking POLA until all the range inconsistencies in jot can be fixed
in one pass.  See PR for details.

PR:		54878
Submitted by:	David Brinegar <jot.3.brinegar@spamgourmet.com>
2003-08-01 16:23:24 +00:00
Mike Barcroft
0ad736e62b Don't depend on pollution in <limits.h> for the definition of
<stdint.h> macros.
2002-07-05 15:58:27 +00:00
Ruslan Ermilov
ff9a78c08e mdoc(7) police: added missing markup bits, lowercased argument names. 2002-07-03 12:24:11 +00:00
David E. O'Brien
e026a48c34 Consistently use FBSDID 2002-06-30 05:25:07 +00:00
Juli Mallett
9ed3737fca Remove local prototype for main(). 2002-06-15 11:28:09 +00:00
Juli Mallett
cf0def9349 Protoize. Remove un-needed cast to char in switch of getopt(3)'s return value.
FBSDID.
2002-06-15 11:26:25 +00:00
Philippe Charnier
e8937ba009 Use `The .Nm utility' 2002-04-20 12:18:28 +00:00
Warner Losh
f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
Mark Murray
91bd71d206 Remove leaf node WARNS?=2 (that mainly I added). This should
help the GCC3 transition and CURRENT in general.
2002-02-08 22:31:43 +00:00
Garrett Wollman
07321a183e Actually, arc4random() returns a uint32_t, not an int. Use the correct
constant, just in case uint32_t turns into a `short' ten years from now.
If this is MFC'd it will be necessary to hard-code the constant since
-stable doesn't have UINT32_MAX.
2001-11-08 22:01:35 +00:00
Andrew Gallatin
f776d8e82b fix jot -r on 64-bit platforms by teaching it that arc4random outputs
an int, not a long

Submitted by: Paul Herman <pherman@frenchfries.net>
PR#: alpha/31859
2001-11-08 20:49:24 +00:00
Ruslan Ermilov
d628d776c4 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
Dima Dorfman
f247324df7 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
Dima Dorfman
f878e83f9d Replace the cast I removed in rev. 1.16 with a slightly less evil one
(well, at least one that gcc doesn't complain about).  This fixes -r,
which rev. 1.16 broke.

Submitted by:	bde
2001-05-29 23:35:18 +00:00
Dima Dorfman
edd7b2674d Silence warnings and compile with WARNS=2 on i386 and alpha. 2001-05-28 00:55:50 +00:00
Dima Dorfman
15ba0427d3 Miscellaneous cleanups; sync to OpenBSD as much as feasible.
Noteworthy changes include:
 * Use getopt(3).
 * Fix overflows in -b and -w options.
 * Use strlcpy(3) and snprintf(3) in favor of strcpy(3) and
   sprintf(3), respectively.  Also check return values of the former
   two.
 * Fix lots of other gratuitous differences with OpenBSD.

Obtained from:	OpenBSD
2001-05-27 21:08:19 +00:00
Ruslan Ermilov
9b88faecd3 Prepare for mdoc(7)NG. 2000-12-19 16:00:12 +00:00
Ruslan Ermilov
8fe908ef0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
Kris Kennaway
612740bdcf Don't call printf with no format string. 2000-07-10 06:02:13 +00:00
Sheldon Hearn
5249bd84d6 Back out rev 1.11, about which bde had concerns, and instead implement
appropriate bounds-checking and typecasts based on our knowledge of
the desired conversion format specifier.

Simplify diagnostics and take care to print the correct conversion
format specifier when %l is involved.
2000-01-06 15:37:37 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Sheldon Hearn
d8d41a0985 Don't dump core for a known, documented bug.
PR:	12611
Reviewed by:	markm
1999-07-22 17:33:11 +00:00
Sheldon Hearn
8db8a33bb9 Improve printf(3) conversion specifier parsing so that silly formats
aren't allowed and the right casts can be used for printf() statements.

Document the conversion specifier limitations and the fact that
arithmetic overflow causes a fatal error.

PR:	12611
Reported by:	Frode Vatvedt Fjeld <frodef@acm.org>
Reviewed by:	bde
1999-07-22 17:11:59 +00:00
Nik Clayton
3be5f1f5ce Add $Id$, to make it simpler for members of the translation teams to
track.

The $Id$ line is normally at the bottom of the main comment block in the
man page, separated from the rest of the manpage by an empty comment,
like so;

     .\"    $Id$
     .\"

If the immediately preceding comment is a @(#) format ID marker than the
the $Id$ will line up underneath it with no intervening blank lines.
Otherwise, an additional blank line is inserted.

Approved by:            bde
1999-07-12 20:24:20 +00:00
Kris Kennaway
4b9cb490c3 Correct an error in a manpage example, add -Wall -W to Makefile (no
warnings given) and modify source to use arc4random() instead of random().

Reviewed by:	ache
1999-05-13 12:18:24 +00:00
Steve Price
86fb910326 Random data is no longer based on the time of day, rather the random
number device.  Also clearly state that sequential data is the default.

PR:		5553
Submitted by:	Jonathan Hanna <pangolin@rogers.wave.ca>
1998-01-24 03:32:33 +00:00
Philippe Charnier
d078aa135c Mdoc'ify man page. 1997-11-03 07:45:33 +00:00
Philippe Charnier
7bd7ad50aa Use err(3) instead of local redefinition. Add usage(). 1997-07-15 09:59:30 +00:00
Andrey A. Chernov
687ee69a2a Remove srandomdev fallback code 1997-06-14 00:27:03 +00:00
Andrey A. Chernov
5790155e89 Use srandomdev() now
Fix error with begin variable calculation
1997-03-30 23:13:59 +00:00
Andrey A. Chernov
28c4ca5ce6 Fix srandom arg type according to Lite2 1997-03-11 14:06:52 +00:00
Andrey A. Chernov
9d288406f5 Add ^ getpid() to make more random results for subsequent calling.
Add proper type casting to random calls

Should go into 2.2
1997-03-08 11:40:15 +00:00
Joerg Wunsch
e29b080f61 >Number: 917
>Category:       bin
>Synopsis:       -s option in jot is broken
1995-12-29 12:18:46 +00:00