aboutsummaryrefslogtreecommitdiffstats
path: root/run.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2011-05-03 11:37:03 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2011-05-03 11:37:03 +0000
commitbd726c262eacb8675c29121f040452106671e929 (patch)
tree3d195e2a98d7d1d827a1d40f49e6529b3bfc6825 /run.c
parentd9859a0e4b8744c01f13cf391ee5cfbf57c5e818 (diff)
downloadsrc-bd726c262eacb8675c29121f040452106671e929.tar.gz
src-bd726c262eacb8675c29121f040452106671e929.zip
Vendor import of bwk's 1-May-2011 release.vendor/one-true-awk/20110501
Notes
Notes: svn path=/vendor/one-true-awk/dist/; revision=221379 svn path=/vendor/one-true-awk/20110501/; revision=221380; tag=vendor/one-true-awk/20110501
Diffstat (limited to 'run.c')
-rw-r--r--run.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/run.c b/run.c
index 72fc4d0f4172..e96379bbd265 100644
--- a/run.c
+++ b/run.c
@@ -66,6 +66,7 @@ void tempfree(Cell *p) {
jmp_buf env;
extern int pairstack[];
+extern Awkfloat srand_seed;
Node *winner = NULL; /* root of parse tree */
Cell *tmps; /* free temporary cells for execution */
@@ -1466,6 +1467,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis
Cell *x, *y;
Awkfloat u;
int t;
+ Awkfloat tmp;
char *p, *buf;
Node *nextarg;
FILE *fp;
@@ -1517,7 +1519,10 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis
u = time((time_t *)0);
else
u = getfval(x);
+ tmp = u;
srand((unsigned int) u);
+ u = srand_seed;
+ srand_seed = tmp;
break;
case FTOUPPER:
case FTOLOWER:
@@ -1887,9 +1892,10 @@ Cell *gsub(Node **a, int nnn) /* global substitute */
adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gsub");
while ((*pb++ = *sptr++) != 0)
;
- done: if (pb > buf + bufsz)
- FATAL("gsub result2 %.30s too big; can't happen", buf);
- *pb = '\0';
+ done: if (pb < buf + bufsz)
+ *pb = '\0';
+ else if (*(pb-1) != '\0')
+ FATAL("gsub result2 %.30s truncated; can't happen", buf);
setsval(x, buf); /* BUG: should be able to avoid copy + free */
pfa->initstat = tempstat;
}