Commit 0b4f3321 authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

merge conflict resolution

parents b2e6a0fc f06eceaa
......@@ -332,9 +332,10 @@ mrb_value mrb_funcall(mrb_state*, mrb_value, const char*, int,...);
mrb_value mrb_funcall_argv(mrb_state*, mrb_value, const char*, int, mrb_value*);
mrb_value mrb_funcall_with_block(mrb_state*, mrb_value, const char*, int, mrb_value*, mrb_value);
mrb_sym mrb_intern(mrb_state*,const char*);
mrb_sym mrb_intern2(mrb_state*,const char*, int);
mrb_sym mrb_intern2(mrb_state*,const char*,int);
mrb_sym mrb_intern_str(mrb_state*,mrb_value);
const char *mrb_sym2name(mrb_state*,mrb_sym);
const char *mrb_sym2name_len(mrb_state*,mrb_sym,int*);
mrb_value mrb_str_format(mrb_state *, int, const mrb_value *, mrb_value);
void *mrb_malloc(mrb_state*, size_t);
......
......@@ -268,8 +268,10 @@ get_syms_block_size(mrb_state *mrb, mrb_irep *irep, int type)
size += DUMP_SIZE(MRB_DUMP_SIZE_OF_SHORT, type); /* snl(n) */
if (irep->syms[sym_no] != 0) {
name = mrb_sym2name(mrb, irep->syms[sym_no]);
nlen = str_dump_len((char*)name, strlen(name), type);
int len;
name = mrb_sym2name_len(mrb, irep->syms[sym_no], &len);
nlen = str_dump_len((char*)name, len, type);
size += nlen; /* sn(n) */
}
}
......
......@@ -477,7 +477,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
memcpy(buf, src, snl); //symbol name
src += snl;
buf[snl] = '\0';
irep->syms[i] = mrb_intern(mrb, buf);
irep->syms[i] = mrb_intern2(mrb, buf, snl);
}
}
crc = calc_crc_16_ccitt((unsigned char*)pStart, src - pStart); //Calculate CRC
......
......@@ -34,7 +34,7 @@ sym_hash_func(mrb_state *mrb, const symbol_name s)
}
return h;
}
#define sym_hash_equal(mrb,a, b) (a.len == b.len && strcmp(a.name, b.name) == 0)
#define sym_hash_equal(mrb,a, b) (a.len == b.len && memcmp(a.name, b.name, a.len) == 0)
KHASH_INIT(n2s, symbol_name, mrb_sym, 1, sym_hash_func, sym_hash_equal)
/* ------------------------------------------------------ */
......@@ -76,8 +76,8 @@ mrb_intern_str(mrb_state *mrb, mrb_value str)
return mrb_intern2(mrb, RSTRING_PTR(str), RSTRING_LEN(str));
}
static const char*
sym2name_len(mrb_state *mrb, mrb_sym sym, int *lenp)
const char*
mrb_sym2name_len(mrb_state *mrb, mrb_sym sym, int *lenp)
{
khash_t(n2s) *h = mrb->name2sym;
khiter_t k;
......@@ -185,7 +185,7 @@ mrb_sym_to_s(mrb_state *mrb, mrb_value sym)
const char *p;
int len;
p = sym2name_len(mrb, id, &len);
p = mrb_sym2name_len(mrb, id, &len);
return mrb_str_new(mrb, p, len);
}
......@@ -290,7 +290,9 @@ symname_p(const char *name)
case '*':
if (*++m == '*') ++m;
break;
case '!':
if (*++m == '=') ++m;
break;
case '+': case '-':
if (*++m == '@') ++m;
break;
......@@ -327,7 +329,7 @@ sym_inspect(mrb_state *mrb, mrb_value sym)
int len;
mrb_sym id = SYM2ID(sym);
name = sym2name_len(mrb, id, &len);
name = mrb_sym2name_len(mrb, id, &len);
str = mrb_str_new(mrb, 0, len+1);
RSTRING(str)->buf[0] = ':';
memcpy(RSTRING(str)->buf+1, name, len);
......@@ -342,7 +344,7 @@ const char*
mrb_sym2name(mrb_state *mrb, mrb_sym sym)
{
int len;
const char *name = sym2name_len(mrb, sym, &len);
const char *name = mrb_sym2name_len(mrb, sym, &len);
if (!name) return NULL;
if (symname_p(name) && strlen(name) == len) {
......@@ -354,7 +356,6 @@ mrb_sym2name(mrb_state *mrb, mrb_sym sym)
}
}
void
mrb_init_symbols(mrb_state *mrb)
{
......
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