summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-12-30 19:41:49 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-12-30 19:41:49 +0000
commit6176ba98b1cd210011621f2a86f8f788b16f5f54 (patch)
treeaadfe1910109fe452ee78b2c0dc504be87466dad /usr.bin
parentdaf750abf9256ea6d87054f82f58e3504033cfbf (diff)
o From FreeBSD: use the max_value(u_int32_t) + 1 to divide the random number.
o Document and warn that seeding the random generator is no longer supported since arc4random is used as the RG. ok jose@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/jot/jot.114
-rw-r--r--usr.bin/jot/jot.c17
2 files changed, 17 insertions, 14 deletions
diff --git a/usr.bin/jot/jot.1 b/usr.bin/jot/jot.1
index 4024f15068a..cfa0273a028 100644
--- a/usr.bin/jot/jot.1
+++ b/usr.bin/jot/jot.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: jot.1,v 1.12 2003/12/18 11:51:13 jmc Exp $
+.\" $OpenBSD: jot.1,v 1.13 2003/12/30 19:41:48 otto Exp $
.\" $NetBSD: jot.1,v 1.2 1994/11/14 20:27:36 jtc Exp $
.\"
.\" Copyright (c) 1993
@@ -103,7 +103,7 @@ in which case the data is inserted rather than appended.
.Pp
The last four arguments indicate, respectively,
the maximum number of data, the lower bound, the upper bound,
-and the step size or, for random data, the seed.
+and the step size.
While at least one of them must appear,
any of the other three may be omitted, and
will be considered as such if given as
@@ -122,9 +122,7 @@ and
are given.
.Pp
Defaults for the four arguments are, respectively,
-100, 1, 100, and 1, except that when random data are requested,
-.Ar s
-defaults to a seed depending upon the time of day.
+100, 1, 100, and 1.
.Ar reps
is expected to be an unsigned integer,
and if given as zero is taken to be infinite.
@@ -137,6 +135,12 @@ The last argument must be a real number.
.Pp
Random numbers are obtained through
.Xr arc4random 3 .
+Historical versions of
+.Nm
+used
+.Ar s
+to seed the random number generator.
+This is no longer supported.
The name
.Nm
derives in part from
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c
index 014bfc15775..db1426f5c27 100644
--- a/usr.bin/jot/jot.c
+++ b/usr.bin/jot/jot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jot.c,v 1.15 2003/12/29 08:51:19 otto Exp $ */
+/* $OpenBSD: jot.c,v 1.16 2003/12/30 19:41:48 otto Exp $ */
/* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */
/*-
@@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)jot.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: jot.c,v 1.15 2003/12/29 08:51:19 otto Exp $";
+static const char rcsid[] = "$OpenBSD: jot.c,v 1.16 2003/12/30 19:41:48 otto Exp $";
#endif /* not lint */
/*
@@ -56,7 +56,6 @@ static const char rcsid[] = "$OpenBSD: jot.c,v 1.15 2003/12/29 08:51:19 otto Exp
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
#define REPS_DEF 100
#define BEGIN_DEF 1
@@ -138,6 +137,8 @@ main(int argc, char *argv[])
if (!sscanf(argv[3], "%lf", &s))
errx(1, "Bad s value: %s", argv[3]);
mask |= 01;
+ if (randomize)
+ warnx("random seeding not supported");
}
case 3:
if (!is_default(argv[2])) {
@@ -225,7 +226,7 @@ main(int argc, char *argv[])
mask = 015;
break;
case 012:
- s = (randomize ? time(NULL) : STEP_DEF);
+ s = STEP_DEF;
mask = 013;
break;
case 013:
@@ -237,7 +238,7 @@ main(int argc, char *argv[])
mask = 0;
break;
case 014:
- s = (randomize ? time(NULL) : STEP_DEF);
+ s = STEP_DEF;
mask = 015;
break;
case 015:
@@ -248,9 +249,7 @@ main(int argc, char *argv[])
mask = 0;
break;
case 016:
- if (randomize)
- s = time(NULL);
- else if (reps == 0)
+ if (reps == 0)
errx(1, "Infinite sequences cannot be bounded");
else if (reps == 1)
s = 0.0;
@@ -276,7 +275,7 @@ main(int argc, char *argv[])
if (randomize) {
x = (ender - begin) * (ender > begin ? 1 : -1);
for (i = 1; i <= reps || infinity; i++) {
- y = (double) arc4random() / UINT_MAX;
+ y = arc4random() / ((double)0xffffffff + 1);
putdata(y * x + begin, reps - i == 0 && !infinity);
}
}