Skip to content

Commit 9a76883

Browse files
committed
[ruby/prism] Fix a bug where we removed the \r warning
ruby/prism@559f24fae0
1 parent 0666cea commit 9a76883

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

prism/prism.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9908,12 +9908,17 @@ parser_lex(pm_parser_t *parser) {
99089908
// stores back to parser->current.end.
99099909
bool chomping = true;
99109910
while (parser->current.end < parser->end && chomping) {
9911-
if (pm_char_is_inline_whitespace(*parser->current.end)) {
9912-
const uint8_t *scan = parser->current.end + 1;
9913-
while (scan < parser->end && pm_char_is_inline_whitespace(*scan)) scan++;
9914-
parser->current.end = scan;
9915-
space_seen = true;
9916-
continue;
9911+
{
9912+
static const uint8_t inline_whitespace[256] = {
9913+
[' '] = 1, ['\t'] = 1, ['\f'] = 1, ['\v'] = 1
9914+
};
9915+
const uint8_t *scan = parser->current.end;
9916+
while (scan < parser->end && inline_whitespace[*scan]) scan++;
9917+
if (scan > parser->current.end) {
9918+
parser->current.end = scan;
9919+
space_seen = true;
9920+
continue;
9921+
}
99179922
}
99189923

99199924
switch (*parser->current.end) {

0 commit comments

Comments
 (0)