mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ext/json/parser/prereq.mk: remove type-limit warning if char is unsigned
Ragel generates a code `0 <= (*p)` where `*p` is char. As char is unsigned by default on arm and RISC-V, it is warned by gcc: ``` compiling parser.c parser.c: In function ‘JSON_parse_string’: parser.c:1566:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] if ( 0 <= (*p) && (*p) <= 31 ) ^ parser.c:1596:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] if ( 0 <= (*p) && (*p) <= 31 ) ^ ``` This change removes the warning by substituting the condition with `0 <= (signed char)(*p)`.
This commit is contained in:
parent
87662134b5
commit
8bd27c547c
2 changed files with 3 additions and 2 deletions
|
@ -1563,7 +1563,7 @@ case 2:
|
|||
case 34: goto tr2;
|
||||
case 92: goto st3;
|
||||
}
|
||||
if ( 0 <= (*p) && (*p) <= 31 )
|
||||
if ( 0 <= (signed char)(*p) && (*p) <= 31 )
|
||||
goto st0;
|
||||
goto st2;
|
||||
tr2:
|
||||
|
@ -1593,7 +1593,7 @@ st3:
|
|||
case 3:
|
||||
if ( (*p) == 117 )
|
||||
goto st4;
|
||||
if ( 0 <= (*p) && (*p) <= 31 )
|
||||
if ( 0 <= (signed char)(*p) && (*p) <= 31 )
|
||||
goto st0;
|
||||
goto st2;
|
||||
st4:
|
||||
|
|
|
@ -6,6 +6,7 @@ RAGEL = ragel
|
|||
$(RAGEL) -G2 $<
|
||||
$(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' \
|
||||
-e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' \
|
||||
-e '$$_.sub!(/0 <= \(\*p\) && \(\*p\) <= 31/, "0 <= (signed char)(*p) && (*p) <= 31")' \
|
||||
-e '$$_ = "/* This file is automatically generated from parser.rl by using ragel */" + $$_ if $$. == 1' $@
|
||||
|
||||
parser.c:
|
||||
|
|
Loading…
Reference in a new issue