Skip to content

Commit 71b3c1a

Browse files
committed
lex: fix bare CR handling
1 parent 42766f2 commit 71b3c1a

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

src/lex/lex.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,28 +1775,17 @@ css_error consumeEscape(css_lexer *lexer, bool nl)
17751775
if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF)
17761776
return css_error_from_parserutils_error(perror);
17771777

1778-
if (perror == PARSERUTILS_EOF) {
1779-
c = '\n';
1780-
APPEND(lexer, &c, 1);
1781-
1782-
lexer->currentCol = 1;
1783-
lexer->currentLine++;
1784-
1785-
return CSS_OK;
1786-
}
1787-
1788-
c = *cptr;
1778+
c = '\n';
1779+
APPEND(lexer, &c, 1);
1780+
lexer->currentCol = 1;
1781+
lexer->currentLine++;
17891782

1790-
if (c == '\n') {
1791-
APPEND(lexer, &c, 1);
1792-
/* And skip the '\r' in the input */
1783+
if (perror == PARSERUTILS_OK && *cptr == '\n') {
1784+
/* Skip the '\n' in the input */
17931785
lexer->bytesReadForToken += clen;
1794-
1795-
lexer->currentCol = 1;
1796-
lexer->currentLine++;
1797-
1798-
return CSS_OK;
17991786
}
1787+
1788+
return CSS_OK;
18001789
} else if (nl && (c == '\n' || c == '\f')) {
18011790
/* APPEND will increment this appropriately */
18021791
lexer->currentCol = 0;

0 commit comments

Comments
 (0)