Skip to content

Commit 23b0b75

Browse files
committed
parser.c: use rb_isdigit
1 parent 8f39321 commit 23b0b75

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/json/ext/parser/parser.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,13 +1124,13 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11241124
if (*state->cursor == '-') {
11251125
signedM = true;
11261126
state->cursor++;
1127-
if (state->cursor >= state->end || *state->cursor < '0' || *state->cursor > '9') {
1127+
if (state->cursor >= state->end || !rb_isdigit(*state->cursor)) {
11281128
raise_parse_error_at("invalid number: %s", state, start);
11291129
}
11301130
}
11311131

11321132
// Parse integer part and extract mantissa digits
1133-
while ((state->cursor < state->end) && (*state->cursor >= '0') && (*state->cursor <= '9')) {
1133+
while ((state->cursor < state->end) && rb_isdigit(*state->cursor)) {
11341134
if (m10digits < 17) { // Only keep first 17 significant digits
11351135
m10 = m10 * 10 + (*state->cursor - '0');
11361136
}
@@ -1153,11 +1153,11 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11531153
decimal_point_pos = m10digits; // Remember position of decimal point
11541154
state->cursor++;
11551155

1156-
if (state->cursor == state->end || *state->cursor < '0' || *state->cursor > '9') {
1156+
if (state->cursor == state->end || !rb_isdigit(*state->cursor)) {
11571157
raise_parse_error("invalid number: %s", state);
11581158
}
11591159

1160-
while ((state->cursor < state->end) && (*state->cursor >= '0') && (*state->cursor <= '9')) {
1160+
while ((state->cursor < state->end) && rb_isdigit(*state->cursor)) {
11611161
if (m10digits < 17) { // Only keep first 17 significant digits
11621162
m10 = m10 * 10 + (*state->cursor - '0');
11631163
}
@@ -1177,12 +1177,12 @@ static VALUE json_parse_any(JSON_ParserState *state, JSON_ParserConfig *config)
11771177
state->cursor++;
11781178
}
11791179

1180-
if (state->cursor == state->end || *state->cursor < '0' || *state->cursor > '9') {
1180+
if (state->cursor == state->end || !rb_isdigit(*state->cursor)) {
11811181
raise_parse_error("invalid number: %s", state);
11821182
}
11831183

11841184
int32_t exp_value = 0;
1185-
while ((state->cursor < state->end) && (*state->cursor >= '0') && (*state->cursor <= '9')) {
1185+
while ((state->cursor < state->end) && rb_isdigit(*state->cursor)) {
11861186
exp_value = exp_value * 10 + (*state->cursor - '0');
11871187
state->cursor++;
11881188
}

0 commit comments

Comments
 (0)