mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #2792 from cremno/let-the-c-compiler-validate-the-identifier
let the C compiler validate the identifier
This commit is contained in:
+1
-17
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user