summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-04-14 20:34:14 +0900
committerGitHub <[email protected]>2019-04-14 20:34:14 +0900
commitec41262e22738c5166a485d5b4b5631fb60e9160 (patch)
tree51f4a5eedc7c514518396abdd5436ae1207e6425
parent4d8ff2fba436708a349c858674088542a126cab1 (diff)
parentdac0f3f5e85d067b15c44a933b151acefb2d5598 (diff)
downloadmruby-ec41262e22738c5166a485d5b4b5631fb60e9160.tar.gz
mruby-ec41262e22738c5166a485d5b4b5631fb60e9160.zip
Merge pull request #4374 from dearblue/hexdump
Fix hexdigits convertion
-rw-r--r--mrbgems/mruby-compiler/core/parse.y7
1 files changed, 4 insertions, 3 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index ca4c90770..7838b6dfb 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -5712,11 +5712,12 @@ parser_yylex(parser_state *p)
if (!identchar(c)) {
char buf[36];
const char s[] = "Invalid char in expression: 0x";
+ const char hexdigits[] = "0123456789ABCDEF";
strcpy(buf, s);
- buf[sizeof(s)] = (c & 0xff00) >> 8;
- buf[sizeof(s)+1] = (c & 0xff);
- buf[sizeof(s)+2] = 0;
+ buf[sizeof(s)-1] = hexdigits[(c & 0xf0) >> 4];
+ buf[sizeof(s)] = hexdigits[(c & 0x0f)];
+ buf[sizeof(s)+1] = 0;
yyerror(p, buf);
goto retry;
}