diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2024-10-08 08:21:29 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-10-08 12:22:42 +0000 |
| commit | 613694734eeefa02eb828002b3c630c2a07dfda1 (patch) | |
| tree | 23091c89791cca483322883fdf6ee9987391771e /ext | |
| parent | dd4677cf0654a7512df0809a31f5eac6bce5b97d (diff) | |
[ruby/json] generator.c: better fix for comparison of integers of different signs
https://github.com/ruby/json/commit/c372dc9268
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/json/generator/generator.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c index fdada2df9d..50fcb77bdf 100644 --- a/ext/json/generator/generator.c +++ b/ext/json/generator/generator.c @@ -47,7 +47,7 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE in_string, bool out_ for (pos = 0; pos < in_utf8_len;) { uint32_t ch; - unsigned long ch_len; + short ch_len; bool should_escape; /* UTF-8 decoding */ @@ -55,7 +55,7 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE in_string, bool out_ ch = in_utf8_str[pos]; ch_len = 1; } else { - unsigned long i; + short i; if ((in_utf8_str[pos] & 0x80) == 0x00) { ch_len = 1; ch = in_utf8_str[pos]; } /* leading 1 bit is 0b0 */ else if ((in_utf8_str[pos] & 0xE0) == 0xC0) { ch_len = 2; ch = in_utf8_str[pos] & 0x1F; } /* leading 3 bits are 0b110 */ 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_ scratch[5] = hexdig[ch & 0xf]; fbuffer_append(out_buffer, scratch, 6); } else { - uint16_t hi, lo; + uint16_t hi, lo; ch -= 0x10000; hi = 0xD800 + (uint16_t)(ch >> 10); lo = 0xDC00 + (uint16_t)(ch & 0x3FF); |
