summaryrefslogtreecommitdiffstats
path: root/cmd-parse.y
diff options
context:
space:
mode:
authornicm <nicm>2019-05-29 19:34:42 +0000
committernicm <nicm>2019-05-29 19:34:42 +0000
commitc17edd594e8088d2355102a8ca58f4b256c59397 (patch)
tree2773211f194ab36a80521ce247983aa466be4c02 /cmd-parse.y
parenta4424fbebf929f4ad742200365fc330a26a65d7f (diff)
The line number needs to be updated only after the \n is processed by
the parser, so store a flag and update it next time around. Also each new line needs its own shared data.
Diffstat (limited to 'cmd-parse.y')
-rw-r--r--cmd-parse.y7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd-parse.y b/cmd-parse.y
index 739ca56c..a235fde1 100644
--- a/cmd-parse.y
+++ b/cmd-parse.y
@@ -58,6 +58,7 @@ struct cmd_parse_state {
size_t len;
size_t off;
+ int eol;
int eof;
struct cmd_parse_input *input;
u_int escapes;
@@ -933,6 +934,10 @@ yylex(void)
char *token, *cp;
int ch, next;
+ if (ps->eol)
+ ps->input->line++;
+ ps->eol = 0;
+
for (;;) {
ch = yylex_getc();
@@ -959,7 +964,7 @@ yylex(void)
/*
* End of line. Update the line number.
*/
- ps->input->line++;
+ ps->eol = 1;
return ('\n');
}