mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ext/json/parser/parser.rl: Use "signed" char to contain negative values
char is not always signed. In fact, it is unsigned in arm. https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-master/log/20191004T181708Z.log.html.gz ``` compiling parser.c parser.rl: In function ‘unescape_unicode’: parser.rl:50:5: warning: comparison is always false due to limited range of data type [-Wtype-limits] if (b < 0) return UNI_REPLACEMENT_CHAR; ^ ```
This commit is contained in:
parent
5717e55e9a
commit
417c64b9a8
2 changed files with 4 additions and 4 deletions
|
@ -28,7 +28,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
|
|||
|
||||
/* unicode */
|
||||
|
||||
static const char digit_values[256] = {
|
||||
static const signed char digit_values[256] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
|
||||
|
@ -47,7 +47,7 @@ static const char digit_values[256] = {
|
|||
|
||||
static UTF32 unescape_unicode(const unsigned char *p)
|
||||
{
|
||||
char b;
|
||||
signed char b;
|
||||
UTF32 result = 0;
|
||||
b = digit_values[p[0]];
|
||||
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
||||
|
|
|
@ -25,7 +25,7 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
|
|||
|
||||
/* unicode */
|
||||
|
||||
static const char digit_values[256] = {
|
||||
static const signed char digit_values[256] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
|
||||
|
@ -44,7 +44,7 @@ static const char digit_values[256] = {
|
|||
|
||||
static UTF32 unescape_unicode(const unsigned char *p)
|
||||
{
|
||||
char b;
|
||||
signed char b;
|
||||
UTF32 result = 0;
|
||||
b = digit_values[p[0]];
|
||||
if (b < 0) return UNI_REPLACEMENT_CHAR;
|
||||
|
|
Loading…
Reference in a new issue