aboutsummaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2011-08-09 12:23:27 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2011-08-09 12:23:27 +0000
commit9cb3faa6600faf227157090f70a6ec850ac1ef75 (patch)
treea1dbab506adcf1ed332e9b7f6440e5df5b5ab3ee /lib.c
parente2f76e526c9828f75cb69d51857e9efd1ed0684f (diff)
downloadsrc-9cb3faa6600faf227157090f70a6ec850ac1ef75.tar.gz
src-9cb3faa6600faf227157090f70a6ec850ac1ef75.zip
Vendor import of bwk's 7-Aug-2011 release.vendor/one-true-awk/20110807
Notes
Notes: svn path=/vendor/one-true-awk/dist/; revision=224729 svn path=/vendor/one-true-awk/20110807/; revision=224730; tag=vendor/one-true-awk/20110807
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index d7eee31db43f..5da601aa8e7e 100644
--- a/lib.c
+++ b/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;
}