codegen.c: fix integer size warnings.

along with repeated calls of `strlen()`.
parent 5764ff07
...@@ -592,7 +592,8 @@ pop_n_(codegen_scope *s, int n) ...@@ -592,7 +592,8 @@ pop_n_(codegen_scope *s, int n)
static int static int
new_litbn(codegen_scope *s, const char *p, int base, mrb_bool neg) new_litbn(codegen_scope *s, const char *p, int base, mrb_bool neg)
{ {
int i, plen; int i;
size_t plen;
mrb_pool_value *pv; mrb_pool_value *pv;
plen = strlen(p); plen = strlen(p);
...@@ -604,7 +605,7 @@ new_litbn(codegen_scope *s, const char *p, int base, mrb_bool neg) ...@@ -604,7 +605,7 @@ new_litbn(codegen_scope *s, const char *p, int base, mrb_bool neg)
pv = &s->pool[i]; pv = &s->pool[i];
if (pv->tt != IREP_TT_BIGINT) continue; if (pv->tt != IREP_TT_BIGINT) continue;
len = pv->u.str[0]; len = pv->u.str[0];
if (len == strlen(p) && pv->u.str[1] == base && memcmp(pv->u.str+2, p, len) == 0) if (len == plen && pv->u.str[1] == base && memcmp(pv->u.str+2, p, len) == 0)
return i; return i;
} }
...@@ -617,14 +618,13 @@ new_litbn(codegen_scope *s, const char *p, int base, mrb_bool neg) ...@@ -617,14 +618,13 @@ new_litbn(codegen_scope *s, const char *p, int base, mrb_bool neg)
i = s->irep->plen++; i = s->irep->plen++;
{ {
char *buf; char *buf;
mrb_int len = strlen(p);
pv->tt = IREP_TT_BIGINT; pv->tt = IREP_TT_BIGINT;
buf = (char*)codegen_realloc(s, NULL, len+3); buf = (char*)codegen_realloc(s, NULL, plen+3);
buf[0] = len; buf[0] = (char)plen;
buf[1] = base; buf[1] = base;
if (neg) buf[1] = 0x80; if (neg) buf[1] = 0x80;
memcpy(buf+2, p, len); memcpy(buf+2, p, plen);
buf[len+2] = '\0'; buf[plen+2] = '\0';
pv->u.str = buf; pv->u.str = buf;
} }
return i; return i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment