add function:check_const_name

This commit is contained in:
skandhas
2012-12-03 13:55:23 +08:00
parent 9754512716
commit fc89106792
+13
View File
@@ -7,6 +7,7 @@
#include "mruby.h"
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include "mruby/class.h"
#include "mruby/proc.h"
#include "mruby/string.h"
@@ -1442,6 +1443,18 @@ mrb_sym_value(mrb_state *mrb, mrb_value val)
return mrb_symbol(val);
}
static void
check_const_name(mrb_state *mrb, mrb_sym id)
{
const char *s;
int len;
s = mrb_sym2name_len(mrb, id, &len);
if (len < 1 || !ISUPPER(*s)) {
mrb_name_error(mrb, id, "wrong constant name %s", s);
}
}
mrb_value
mrb_mod_const_defined(mrb_state *mrb, mrb_value mod)
{