Skip to content

Commit

Permalink
Count line numbers correctly inside strings, reported by Pedro Navarro
Browse files Browse the repository at this point in the history
in GitHub issue 4325.
  • Loading branch information
nicm committed Jan 13, 2025
1 parent 97fe356 commit 31e8d46
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd-parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,7 @@ yylex_token_tilde(char **buf, size_t *len)
static char *
yylex_token(int ch)
{
struct cmd_parse_state *ps = &parse_state;
char *buf;
size_t len;
enum { START,
Expand All @@ -1650,9 +1651,12 @@ yylex_token(int ch)
ch = '\r';
}
}
if (state == NONE && ch == '\n') {
log_debug("%s: end at EOL", __func__);
break;
if (ch == '\n') {
if (state == NONE) {
log_debug("%s: end at EOL", __func__);
break;
}
ps->input->line++;
}

/* Whitespace or ; or } ends a token unless inside quotes. */
Expand Down

0 comments on commit 31e8d46

Please sign in to comment.