diff options
author | ru <ru@FreeBSD.org> | 2011-05-03 11:47:19 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2011-05-03 11:47:19 +0000 |
commit | 169254209b0bd6089f3bef289d398b21882bac83 (patch) | |
tree | eb10e239bd7475967e0d02980aa01bd433651c71 /contrib/one-true-awk/run.c | |
parent | 582de70a4368320790784013e7b8897b0ae17b41 (diff) | |
download | FreeBSD-src-169254209b0bd6089f3bef289d398b21882bac83.zip FreeBSD-src-169254209b0bd6089f3bef289d398b21882bac83.tar.gz |
Update to a 1-May-2011 release (except for the isblank change).
Diffstat (limited to 'contrib/one-true-awk/run.c')
-rw-r--r-- | contrib/one-true-awk/run.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c index 20c08b1..82c29ce 100644 --- a/contrib/one-true-awk/run.c +++ b/contrib/one-true-awk/run.c @@ -69,6 +69,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 */ @@ -1469,6 +1470,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; @@ -1520,7 +1522,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: @@ -1890,9 +1895,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; } |