diff options
author | nicm <nicm> | 2019-05-29 19:34:42 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-05-29 19:34:42 +0000 |
commit | c17edd594e8088d2355102a8ca58f4b256c59397 (patch) | |
tree | 2773211f194ab36a80521ce247983aa466be4c02 /cmd-parse.y | |
parent | a4424fbebf929f4ad742200365fc330a26a65d7f (diff) | |
download | rtmux-c17edd594e8088d2355102a8ca58f4b256c59397.tar.gz rtmux-c17edd594e8088d2355102a8ca58f4b256c59397.tar.bz2 rtmux-c17edd594e8088d2355102a8ca58f4b256c59397.zip |
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.y | 7 |
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'); } |