From 81cbc92513b82bf4ee173fab0a7779ac05a8ef04 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sat, 16 Feb 2019 21:26:45 +0900 Subject: Fix inline packed symbols on 32 bit mode with MRB_WORD_BOXING --- src/symbol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/symbol.c b/src/symbol.c index 620ae3418..1bc9f2676 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -34,13 +34,18 @@ static const char pack_table[] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS static mrb_sym sym_inline_pack(const char *name, uint16_t len) { + enum { + lower_length_max = (MRB_SYMBOL_BITSIZE - 2) / 5, + mix_length_max = (MRB_SYMBOL_BITSIZE - 2) / 6 + }; + char c; const char *p; int i; mrb_sym sym = 0; int lower = 1; - if (len > 6) return 0; /* too long */ + if (len > lower_length_max) return 0; /* too long */ for (i=0; i mix_length_max) return 0; return sym | 1; } -- cgit v1.2.3 From 5067a5cd584c4457934872d50cfb33735d55241d Mon Sep 17 00:00:00 2001 From: dearblue Date: Sat, 16 Feb 2019 22:13:16 +0900 Subject: Use `const int` instead of `enum` --- src/symbol.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/symbol.c b/src/symbol.c index 1bc9f2676..80437e39e 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -34,10 +34,8 @@ static const char pack_table[] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS static mrb_sym sym_inline_pack(const char *name, uint16_t len) { - enum { - lower_length_max = (MRB_SYMBOL_BITSIZE - 2) / 5, - mix_length_max = (MRB_SYMBOL_BITSIZE - 2) / 6 - }; + const int lower_length_max = (MRB_SYMBOL_BITSIZE - 2) / 5; + const int mix_length_max = (MRB_SYMBOL_BITSIZE - 2) / 6; char c; const char *p; -- cgit v1.2.3