diff --git a/lib.c b/lib.c index 18adbd2..82b804b 100644 --- a/lib.c +++ b/lib.c @@ -176,6 +176,7 @@ int getrec(char **pbuf, int *pbufsize, bool isrecord) /* get next input record * infile = stdin; else if ((infile = fopen(file, "r")) == NULL) FATAL("can't open file %s", file); + innew = true; setfval(fnrloc, 0.0); } c = readrec(&buf, &bufsize, infile, innew); diff --git a/testdir/T.misc b/testdir/T.misc index dff57db..77e6dd1 100755 --- a/testdir/T.misc +++ b/testdir/T.misc @@ -195,6 +195,24 @@ aa1a2a EOF diff foo1 foo2 || echo 'BAD: T.misc ^regex reapplied fails' +# ^-anchored RS matching should be active at the start of each input file +tee foo1 foo2 >foo3 << \EOF +aaa +EOF +$awk 1 RS='^a' foo1 foo2 foo3 >foo4 +cat << \EOF > foo5 + +aa + + +aa + + +aa + +EOF +diff foo4 foo5 || echo 'BAD: T.misc ^RS matches the start of every input file fails' + # The following should not produce a warning about changing a constant # nor about a curdled tempcell list $awk 'function f(x) { x = 2 }