ref: a212ffa41ce5f177f9486fed31c971d83ef958da
parent: 91f35d25cdc9e46efb740c51e2a8b0b0a4dec91a
author: ozan yigit <ozan.yigit@gmail.com>
date: Thu Jan 16 09:21:57 EST 2025
fix error line number mismatch: remove an attempt to manage lineno (decrement if char is newline) in unput, and a hack in yylex to compensate for this behaviour. additional test in T.misc.
--- a/lex.c
+++ b/lex.c
@@ -215,11 +215,6 @@
while ((c = input()) != '\n' && c != 0)
;
unput(c);
- /*
- * Next line is a hack, it compensates for
- * unput's treatment of \n.
- */
- lineno++;
break;
case ';':
RET(';');@@ -619,8 +614,6 @@
void unput(int c) /* put lexical character back on input */
{- if (c == '\n')
- lineno--;
if (yysptr >= yysbuf + sizeof(yysbuf))
FATAL("pushed back too much: %.20s...", yysbuf);*yysptr++ = c;
--- a/testdir/T.misc
+++ b/testdir/T.misc
@@ -415,8 +415,14 @@
print "hello, world"
}
}}}' >foo1 2>foo2
-grep 'source line 4' foo2 >/dev/null 2>&1 || echo 'BAD: T.misc continuation line number'
+grep 'source line 5' foo2 >/dev/null 2>&1 || echo 'BAD: T.misc continuation line number'
+$awk 'BEGIN {+ if () {+ print "foo"
+ }
+}' >foo1 2>foo2
+grep 'syntax error at source line 2' foo2 >/dev/null 2>&1 || echo 'BAD: T.misc syntax error line number'
echo 111 222 333 >foo
$awk '{ f[1]=1; f[2]=2; print $f[1], $f[1]++, $f[2], f[1], f[2] }' foo >foo2--
⑨