Skip to content

Commit 94d679f

Browse files
authored
Merge pull request #690 from nobu/right-shift-uchar
Fix right shift warnings
2 parents 35324a1 + fb82373 commit 94d679f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/json/ext/generator/generator.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE str, const char esca
118118
case '\r': fbuffer_append(out_buffer, "\\r", 2); break;
119119
case '\t': fbuffer_append(out_buffer, "\\t", 2); break;
120120
default: {
121-
scratch[2] = hexdig[ch >> 12];
122-
scratch[3] = hexdig[(ch >> 8) & 0xf];
121+
scratch[2] = '0';
122+
scratch[3] = '0';
123123
scratch[4] = hexdig[(ch >> 4) & 0xf];
124124
scratch[5] = hexdig[ch & 0xf];
125125
fbuffer_append(out_buffer, scratch, 6);
@@ -240,8 +240,8 @@ static void convert_ASCII_to_JSON(FBuffer *out_buffer, VALUE str, const char esc
240240
case '\r': fbuffer_append(out_buffer, "\\r", 2); break;
241241
case '\t': fbuffer_append(out_buffer, "\\t", 2); break;
242242
default:
243-
scratch[2] = hexdig[ch >> 12];
244-
scratch[3] = hexdig[(ch >> 8) & 0xf];
243+
scratch[2] = '0';
244+
scratch[3] = '0';
245245
scratch[4] = hexdig[(ch >> 4) & 0xf];
246246
scratch[5] = hexdig[ch & 0xf];
247247
fbuffer_append(out_buffer, scratch, 6);
@@ -288,8 +288,8 @@ static void convert_UTF8_to_ASCII_only_JSON(FBuffer *out_buffer, VALUE str, cons
288288
case '\r': fbuffer_append(out_buffer, "\\r", 2); break;
289289
case '\t': fbuffer_append(out_buffer, "\\t", 2); break;
290290
default: {
291-
scratch[2] = hexdig[ch >> 12];
292-
scratch[3] = hexdig[(ch >> 8) & 0xf];
291+
scratch[2] = '0';
292+
scratch[3] = '0';
293293
scratch[4] = hexdig[(ch >> 4) & 0xf];
294294
scratch[5] = hexdig[ch & 0xf];
295295
fbuffer_append(out_buffer, scratch, 6);

0 commit comments

Comments
 (0)