summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-02-17 22:13:22 +0900
committerGitHub <[email protected]>2019-02-17 22:13:22 +0900
commit3e0d29b7bed34a961ba991f581528078dedbe934 (patch)
tree2014d149ee3ddd5ef1299e2fc11353ce1c1a450f /src
parenta3e8b750ef5a7515e2a19b947c9b14261fff1e7a (diff)
parent5067a5cd584c4457934872d50cfb33735d55241d (diff)
downloadmruby-3e0d29b7bed34a961ba991f581528078dedbe934.tar.gz
mruby-3e0d29b7bed34a961ba991f581528078dedbe934.zip
Merge pull request #4279 from dearblue/fix-inline-packed-symbols
Fix destroyed "inline packed symbols" on 32 bit mode with `MRB_WORD_BOXING`
Diffstat (limited to 'src')
-rw-r--r--src/symbol.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/symbol.c b/src/symbol.c
index e09e9019d..8424cecd9 100644
--- a/src/symbol.c
+++ b/src/symbol.c
@@ -34,13 +34,16 @@ static const char pack_table[] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS
static mrb_sym
sym_inline_pack(const char *name, uint16_t len)
{
+ 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;
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<len; i++) {
uint32_t bits;
@@ -64,7 +67,7 @@ sym_inline_pack(const char *name, uint16_t len)
}
return sym | 3;
}
- if (len == 6) return 0;
+ if (len > mix_length_max) return 0;
return sym | 1;
}