Merge branch 'fix-readrec' of https://github.com/mpinjr/awk into staging
This commit is contained in:
commit
3913329120
3
lib.c
3
lib.c
@ -242,6 +242,7 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one rec
|
|||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
setptr(patbeg, '\0');
|
setptr(patbeg, '\0');
|
||||||
|
isrec = (found == 0 && *buf == '\0') ? 0 : 1;
|
||||||
} else {
|
} else {
|
||||||
if ((sep = *rs) == 0) {
|
if ((sep = *rs) == 0) {
|
||||||
sep = '\n';
|
sep = '\n';
|
||||||
@ -271,10 +272,10 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf, bool newflag) /* read one rec
|
|||||||
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
|
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
|
||||||
FATAL("input record `%.30s...' too long", buf);
|
FATAL("input record `%.30s...' too long", buf);
|
||||||
*rr = 0;
|
*rr = 0;
|
||||||
|
isrec = (c == EOF && rr == buf) ? 0 : 1;
|
||||||
}
|
}
|
||||||
*pbuf = buf;
|
*pbuf = buf;
|
||||||
*pbufsize = bufsize;
|
*pbufsize = bufsize;
|
||||||
isrec = *buf || !feof(inf);
|
|
||||||
DPRINTF("readrec saw <%s>, returns %d\n", buf, isrec);
|
DPRINTF("readrec saw <%s>, returns %d\n", buf, isrec);
|
||||||
return isrec;
|
return isrec;
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,13 @@ BEGIN { RS = ""
|
|||||||
}' >foo1
|
}' >foo1
|
||||||
$awk 'END {print NR}' foo1 | grep 4 >/dev/null || echo 'BAD: T.misc abcdef fails'
|
$awk 'END {print NR}' foo1 | grep 4 >/dev/null || echo 'BAD: T.misc abcdef fails'
|
||||||
|
|
||||||
|
# Test for RS regex matching an empty record at EOF
|
||||||
|
echo a | $awk 1 RS='a\n' > foo1
|
||||||
|
cat << \EOF > foo2
|
||||||
|
|
||||||
|
EOF
|
||||||
|
diff foo1 foo2 || echo 'BAD: T.misc RS regex matching an empty record at EOF fails'
|
||||||
|
|
||||||
# Test for RS regex being reapplied
|
# Test for RS regex being reapplied
|
||||||
echo aaa1a2a | $awk 1 RS='^a' >foo1
|
echo aaa1a2a | $awk 1 RS='^a' >foo1
|
||||||
cat << \EOF > foo2
|
cat << \EOF > foo2
|
||||||
|
Loading…
Reference in New Issue
Block a user