diff options
author | ru <ru@FreeBSD.org> | 2011-08-09 12:54:43 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2011-08-09 12:54:43 +0000 |
commit | d218e8cbbc531ecda2621a877543e58d0b03fe6c (patch) | |
tree | 079bb7a8384dfb47f51838c84776481fb07cf770 /contrib/one-true-awk/lib.c | |
parent | 95c58b7fb18fe9d1c2f2cfcb59238e78388050f6 (diff) | |
download | FreeBSD-src-d218e8cbbc531ecda2621a877543e58d0b03fe6c.zip FreeBSD-src-d218e8cbbc531ecda2621a877543e58d0b03fe6c.tar.gz |
Update to a 7-Aug-2011 release.
Approved by: re (kib)
Diffstat (limited to 'contrib/one-true-awk/lib.c')
-rw-r--r-- | contrib/one-true-awk/lib.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c index d7eee31..5da601a 100644 --- a/contrib/one-true-awk/lib.c +++ b/contrib/one-true-awk/lib.c @@ -124,7 +124,7 @@ int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */ dprintf( ("argno=%d, file=|%s|\n", argno, file) ); if (infile == NULL) { /* have to open a new file */ file = getargv(argno); - if (*file == '\0') { /* it's been zapped */ + if (file == NULL || *file == '\0') { /* deleted or zapped */ argno++; continue; } @@ -187,6 +187,7 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf * if (strlen(*FS) >= sizeof(inputFS)) FATAL("field separator %.10s... is too long", *FS); + /*fflush(stdout); avoids some buffering problem but makes it 25% slower*/ strcpy(inputFS, *FS); /* for subsequent field splitting */ if ((sep = **RS) == 0) { sep = '\n'; @@ -227,6 +228,8 @@ char *getargv(int n) /* get ARGV[n] */ extern Array *ARGVtab; sprintf(temp, "%d", n); + if (lookup(temp, ARGVtab) == NULL) + return NULL; x = setsymtab(temp, "", 0.0, STR, ARGVtab); s = getsval(x); dprintf( ("getargv(%d) returns |%s|\n", n, s) ); @@ -477,14 +480,14 @@ void recbld(void) /* create $0 from $1..$NF if necessary */ if (!adjbuf(&record, &recsize, 2+r-record, recsize, &r, "recbld 3")) FATAL("built giant record `%.30s...'", record); *r = '\0'; - dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) ); + dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); if (freeable(fldtab[0])) xfree(fldtab[0]->sval); fldtab[0]->tval = REC | STR | DONTFREE; fldtab[0]->sval = record; - dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) ); + dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) ); dprintf( ("recbld = |%s|\n", record) ); donerec = 1; } |