Skip to content

Commit c372dc9

Browse files
committed
generator.c: better fix for comparison of integers of different signs
1 parent 38d65e8 commit c372dc9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/json/ext/generator/generator.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE in_string, bool out_
4747

4848
for (pos = 0; pos < in_utf8_len;) {
4949
uint32_t ch;
50-
unsigned long ch_len;
50+
short ch_len;
5151
bool should_escape;
5252

5353
/* UTF-8 decoding */
5454
if (in_is_ascii_only) {
5555
ch = in_utf8_str[pos];
5656
ch_len = 1;
5757
} else {
58-
unsigned long i;
58+
short i;
5959
if ((in_utf8_str[pos] & 0x80) == 0x00) { ch_len = 1; ch = in_utf8_str[pos]; } /* leading 1 bit is 0b0 */
6060
else if ((in_utf8_str[pos] & 0xE0) == 0xC0) { ch_len = 2; ch = in_utf8_str[pos] & 0x1F; } /* leading 3 bits are 0b110 */
6161
else if ((in_utf8_str[pos] & 0xF0) == 0xE0) { ch_len = 3; ch = in_utf8_str[pos] & 0x0F; } /* leading 4 bits are 0b1110 */
@@ -109,7 +109,7 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE in_string, bool out_
109109
scratch[5] = hexdig[ch & 0xf];
110110
fbuffer_append(out_buffer, scratch, 6);
111111
} else {
112-
uint16_t hi, lo;
112+
uint16_t hi, lo;
113113
ch -= 0x10000;
114114
hi = 0xD800 + (uint16_t)(ch >> 10);
115115
lo = 0xDC00 + (uint16_t)(ch & 0x3FF);

0 commit comments

Comments
 (0)