Skip to content

Commit c787d2e

Browse files
committed
Fix parsing other encodings bytes >= 0x80
1 parent 4f71d3b commit c787d2e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/prism.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5793,7 +5793,16 @@ pm_parser_scope_pop(pm_parser_t *parser) {
57935793
static inline size_t
57945794
char_is_identifier_start(pm_parser_t *parser, const uint8_t *b) {
57955795
if (parser->encoding_changed) {
5796-
return parser->encoding.alpha_char(b, parser->end - b) || (*b == '_') || (*b >= 0x80);
5796+
size_t width;
5797+
if ((width = parser->encoding.alpha_char(b, parser->end - b)) != 0) {
5798+
return width;
5799+
} else if (*b == '_') {
5800+
return 1;
5801+
} else if (*b >= 0x80) {
5802+
return parser->encoding.char_width(b, parser->end - b);
5803+
} else {
5804+
return 0;
5805+
}
57975806
} else if (*b < 0x80) {
57985807
return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHABETIC_BIT ? 1 : 0) || (*b == '_');
57995808
} else {
@@ -5809,7 +5818,16 @@ char_is_identifier_start(pm_parser_t *parser, const uint8_t *b) {
58095818
static inline size_t
58105819
char_is_identifier(pm_parser_t *parser, const uint8_t *b) {
58115820
if (parser->encoding_changed) {
5812-
return parser->encoding.alnum_char(b, parser->end - b) || (*b == '_') || (*b >= 0x80);
5821+
size_t width;
5822+
if ((width = parser->encoding.alnum_char(b, parser->end - b)) != 0) {
5823+
return width;
5824+
} else if (*b == '_') {
5825+
return 1;
5826+
} else if (*b >= 0x80) {
5827+
return parser->encoding.char_width(b, parser->end - b);
5828+
} else {
5829+
return 0;
5830+
}
58135831
} else if (*b < 0x80) {
58145832
return (pm_encoding_unicode_table[*b] & PRISM_ENCODING_ALPHANUMERIC_BIT ? 1 : 0) || (*b == '_');
58155833
} else {

0 commit comments

Comments
 (0)