FreeBSD Bugzilla – Attachment 146536 Details for
Bug 193147
[patch] Change rand(3) to random(3) in awk(1)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
The patch.
patch.diff (text/plain), 1.63 KB, created by
horus.li
on 2014-08-30 13:39:25 UTC
(
hide
)
Description:
The patch.
Filename:
MIME Type:
Creator:
horus.li
Created:
2014-08-30 13:39:25 UTC
Size:
1.63 KB
patch
obsolete
>Index: awk.1 >=================================================================== >--- awk.1 (revision 270781) >+++ awk.1 (working copy) >@@ -208,7 +208,7 @@ > if no argument. > .TP > .B rand >-random number on (0,1) >+random number on [0,1) > .TP > .B srand > sets seed for >Index: main.c >=================================================================== >--- main.c (revision 270781) >+++ main.c (working copy) >@@ -74,7 +74,7 @@ > signal(SIGFPE, fpecatch); > > srand_seed = 1; >- srand(srand_seed); >+ srandom((unsigned long) srand_seed); > > yyin = NULL; > symtab = makesymtab(NSYMTAB/NSYMTAB); >Index: run.c >=================================================================== >--- run.c (revision 270781) >+++ run.c (working copy) >@@ -1521,8 +1521,10 @@ > u = (Awkfloat) system(getsval(x)) / 256; /* 256 is unix-dep */ > break; > case FRAND: >- /* in principle, rand() returns something in 0..RAND_MAX */ >- u = (Awkfloat) (rand() % RAND_MAX) / RAND_MAX; >+ /* random() returns numbers in [0..2^31-1] >+ * in order to get a number in [0, 1), divide it by 2^31 >+ */ >+ u = (Awkfloat) random() / (0x7fffffffL + 0x1UL); > break; > case FSRAND: > if (isrec(x)) /* no argument provided */ >@@ -1530,7 +1532,7 @@ > else > u = getfval(x); > tmp = u; >- srand((unsigned int) u); >+ srandom((unsigned long) u); > u = srand_seed; > srand_seed = tmp; > break;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 193147
:
146536
|
147313