summaryrefslogtreecommitdiff
path: root/perly.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2020-12-08 09:50:47 +0000
committerDavid Mitchell <davem@iabyn.com>2020-12-08 09:50:47 +0000
commitbc13a79e197e191d2c6cb0ec76217e27e0932575 (patch)
tree039297c7f52f878df3ffa7b1a1ba2513d594ec0a /perly.c
parent54e31e2485e0fb4822dfa38ac496790a2d877f3c (diff)
downloadperl-bc13a79e197e191d2c6cb0ec76217e27e0932575.tar.gz
perly.y: avoid <0 test on unsigned value
Coverity CID 313707 Moving to a newer version of Bison has changed how the YYTRANSLATE() macro is defined: in particular it now has a <0 test, which Coverity is complaining about, since the arg is an unsigned value. This commit just casts the arg back to a signed value. In more detail: we formerly had: yytoken = YYTRANSLATE(NATIVE_TO_UNI(parser->yychar)); yychar is of type int, but NATIVE_TO_UNI returns a UV. So just cast the result back to an int: yytoken = YYTRANSLATE((int)NATIVE_TO_UNI(parser->yychar));
Diffstat (limited to 'perly.c')
-rw-r--r--perly.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/perly.c b/perly.c
index 091371937d..ad79c49c49 100644
--- a/perly.c
+++ b/perly.c
@@ -297,7 +297,7 @@ Perl_yyparse (pTHX_ int gramtype)
/* initialise state for this parse */
parser->yychar = gramtype;
- yytoken = YYTRANSLATE(NATIVE_TO_UNI(parser->yychar));
+ yytoken = YYTRANSLATE((int)NATIVE_TO_UNI(parser->yychar));
parser->yyerrstatus = 0;
parser->yylen = 0;
@@ -369,11 +369,11 @@ Perl_yyparse (pTHX_ int gramtype)
* characters in that range, but all tokens it returns are
* either 0, or above 255. There could be a problem if NULs
* weren't 0, or were ever returned as raw chars by yylex() */
- yytoken = YYTRANSLATE(NATIVE_TO_UNI(parser->yychar));
+ yytoken = YYTRANSLATE((int)NATIVE_TO_UNI(parser->yychar));
}
/* make sure no-one's changed yychar since the last call to yylex */
- assert(yytoken == YYTRANSLATE(NATIVE_TO_UNI(parser->yychar)));
+ assert(yytoken == YYTRANSLATE((int)NATIVE_TO_UNI(parser->yychar)));
YYDSYMPRINTF("lookahead token is", yytoken, &parser->yylval);