diff options
author | nicm <nicm> | 2019-05-29 19:34:42 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2019-05-29 23:04:22 +0100 |
commit | 75d112c4842295daa6542064aede617b774e3ff7 (patch) | |
tree | d79dbefa441965b72c34c73bcf957d18f88080e9 /cmd-parse.y | |
parent | a05c3a7aa6071032bed8725b27dca8678b481dc6 (diff) | |
download | rtmux-75d112c4842295daa6542064aede617b774e3ff7.tar.gz rtmux-75d112c4842295daa6542064aede617b774e3ff7.tar.bz2 rtmux-75d112c4842295daa6542064aede617b774e3ff7.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 f347280b..d984b9d3 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'); } |