Commit cf070b64 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2792 from cremno/let-the-c-compiler-validate-the-identifier

let the C compiler validate the identifier
parents 0cae5eaf 406fb9c8
......@@ -1019,22 +1019,6 @@ mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE* fp)
return result;
}
static mrb_bool
is_valid_c_symbol_name(const char *name)
{
const char *c = NULL;
if (name == NULL || name[0] == '\0') return FALSE;
if (!ISALPHA(name[0]) && name[0] != '_') return FALSE;
c = &name[1];
for (; *c != '\0'; ++c) {
if (!ISALNUM(*c) && *c != '_') return FALSE;
}
return TRUE;
}
static mrb_bool
dump_bigendian_p(uint8_t flags)
{
......@@ -1056,7 +1040,7 @@ mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep *irep, uint8_t flags, FILE *fp, con
size_t bin_size = 0, bin_idx = 0;
int result;
if (fp == NULL || initname == NULL || !is_valid_c_symbol_name(initname)) {
if (fp == NULL || initname == NULL || initname[0] == '\0') {
return MRB_DUMP_INVALID_ARGUMENT;
}
flags = dump_flags(flags, FLAG_BYTEORDER_NATIVE);
......
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