=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/lex.c,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** src/usr.bin/awk/lex.c 2011/09/28 19:27:18 1.12 --- src/usr.bin/awk/lex.c 2020/06/10 21:01:32 1.13 *************** *** 1,4 **** ! /* $OpenBSD: lex.c,v 1.12 2011/09/28 19:27:18 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved --- 1,4 ---- ! /* $OpenBSD: lex.c,v 1.13 2020/06/10 21:01:32 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved *************** *** 209,214 **** --- 209,215 ---- yylval.i = c; switch (c) { case '\n': /* {EOL} */ + lineno++; RET(NL); case '\r': /* assume \n is coming */ case ' ': /* {WS}+ */ *************** *** 224,229 **** --- 225,231 ---- case '\\': if (peek() == '\n') { input(); + lineno++; } else if (peek() == '\r') { input(); input(); /* \n */ lineno++; *************** *** 381,390 **** case '\n': case '\r': case 0: SYNTAX( "non-terminated string %.10s...", buf ); - lineno++; if (c == 0) /* hopeless */ FATAL( "giving up" ); break; case '\\': c = input(); --- 383,393 ---- case '\n': case '\r': case 0: + *bp = '\0'; SYNTAX( "non-terminated string %.10s...", buf ); if (c == 0) /* hopeless */ FATAL( "giving up" ); + lineno++; break; case '\\': c = input(); *************** *** 526,531 **** --- 529,535 ---- if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, "regexpr")) FATAL("out of space for reg expr %.10s...", buf); if (c == '\n') { + *bp = '\0'; SYNTAX( "newline in regular expression %.10s...", buf ); unput('\n'); break; *************** *** 568,586 **** lexprog++; } else /* awk -f ... */ c = pgetc(); ! if (c == '\n') ! lineno++; ! else if (c == EOF) c = 0; if (ep >= ebuf + sizeof ebuf) ep = ebuf; ! return *ep++ = c; } 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; --- 572,590 ---- lexprog++; } else /* awk -f ... */ c = pgetc(); ! if (c == EOF) c = 0; if (ep >= ebuf + sizeof ebuf) ep = ebuf; ! *ep = c; ! if (c != 0) { ! ep++; ! } ! return (c); } void unput(int c) /* put lexical character back on input */ { if (yysptr >= yysbuf + sizeof(yysbuf)) FATAL("pushed back too much: %.20s...", yysbuf); *yysptr++ = c;