summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-03-30 23:13:59 +0000
committerache <ache@FreeBSD.org>1997-03-30 23:13:59 +0000
commitf673899804337487c03c460fe7cbebca19789781 (patch)
treeeca7888b1aa06eb4a51d5dd54d76bb3281c7387c /usr.bin
parent29d246343bb7aa77721c635e334f75c86cff923e (diff)
downloadFreeBSD-src-f673899804337487c03c460fe7cbebca19789781.zip
FreeBSD-src-f673899804337487c03c460fe7cbebca19789781.tar.gz
Use srandomdev() now
Fix error with begin variable calculation
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/jot/jot.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c
index 408af5c..dba1804 100644
--- a/usr.bin/jot/jot.c
+++ b/usr.bin/jot/jot.c
@@ -96,7 +96,11 @@ main(argc, argv)
getargs(argc, argv);
if (randomize) {
*x = (ender - begin) * (ender > begin ? 1 : -1);
- srandom((unsigned long) s);
+ if (s == -1.0) {
+ if (srandomdev() < 0)
+ srandom(time(NULL) ^ getpid());
+ } else
+ srandom((unsigned long) s);
for (*i = 1; *i <= reps || infinity; (*i)++) {
*y = (double) random() / LONG_MAX;
putdata(*y * *x + begin, reps - *i);
@@ -250,7 +254,7 @@ getargs(ac, av)
mask = 015;
break;
case 012:
- s = (randomize ? time(NULL) ^ getpid() : STEP_DEF);
+ s = (randomize ? -1.0 : STEP_DEF);
mask = 013;
break;
case 013:
@@ -258,11 +262,12 @@ getargs(ac, av)
begin = BEGIN_DEF;
else if (reps == 0)
error("Must specify begin if reps == 0", "");
- begin = ender - reps * s + s;
+ else
+ begin = ender - reps * s + s;
mask = 0;
break;
case 014:
- s = (randomize ? time(NULL) ^ getpid() : STEP_DEF);
+ s = (randomize ? -1.0 : STEP_DEF);
mask = 015;
break;
case 015:
@@ -274,7 +279,7 @@ getargs(ac, av)
break;
case 016:
if (randomize)
- s = time(NULL) ^ getpid();
+ s = -1.0;
else if (reps == 0)
error("Infinite sequences cannot be bounded",
"");
OpenPOWER on IntegriCloud