diff options
| -rw-r--r-- | include/mruby.h | 3 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 7 | ||||
| -rw-r--r-- | mrbgems/mruby-test/driver.c | 3 | ||||
| -rw-r--r-- | mrblib/string.rb | 24 | ||||
| -rw-r--r-- | src/variable.c | 4 |
5 files changed, 22 insertions, 19 deletions
diff --git a/include/mruby.h b/include/mruby.h index 939601b4d..e567e1da4 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -1083,9 +1083,6 @@ MRB_API mrb_value mrb_Float(mrb_state *mrb, mrb_value val); MRB_API mrb_value mrb_inspect(mrb_state *mrb, mrb_value obj); MRB_API mrb_bool mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2); -static inline int mrb_gc_arena_save(mrb_state*); -static inline void mrb_gc_arena_restore(mrb_state*,int); - static inline int mrb_gc_arena_save(mrb_state *mrb) { diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index f6c77859a..cb62ec3f2 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -221,7 +221,7 @@ parser_strdup(parser_state *p, const char *s) #define strdup(s) parser_strdup(p, s) static void -itoa(short i, char *s) +dump_int(short i, char *s) { char *p = s; char *t = s; @@ -239,6 +239,7 @@ itoa(short i, char *s) *p-- = c; } } + /* xxx ----------------------------- */ static node* @@ -3191,7 +3192,7 @@ var_ref : variable { char buf[16]; - itoa(p->lineno, buf); + dump_int(p->lineno, buf); $$ = new_int(p, buf, 10); } | keyword__ENCODING__ @@ -6144,7 +6145,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c) char buf[256]; strcpy(buf, "line "); - itoa(p->error_buffer[0].lineno, buf+5); + dump_int(p->error_buffer[0].lineno, buf+5); strcat(buf, ": "); strcat(buf, p->error_buffer[0].message); mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, strlen(buf))); diff --git a/mrbgems/mruby-test/driver.c b/mrbgems/mruby-test/driver.c index fd180b1bb..fcbe15a56 100644 --- a/mrbgems/mruby-test/driver.c +++ b/mrbgems/mruby-test/driver.c @@ -51,9 +51,10 @@ t_print(mrb_state *mrb, mrb_value self) { mrb_value *argv; mrb_int argc; + mrb_int i; mrb_get_args(mrb, "*!", &argv, &argc); - for (mrb_int i = 0; i < argc; ++i) { + for (i = 0; i < argc; ++i) { mrb_value s = mrb_obj_as_string(mrb, argv[i]); fwrite(RSTRING_PTR(s), RSTRING_LEN(s), 1, stdout); } diff --git a/mrblib/string.rb b/mrblib/string.rb index 64e85c5b6..62c925885 100644 --- a/mrblib/string.rb +++ b/mrblib/string.rb @@ -242,25 +242,27 @@ class String end end + def _regexp(re, mid) + if String === re + if Object.const_defined?(:Regexp) + return Regexp.new(re) + else + raise NotImplementedError, "String##{mid} needs Regexp class" + end + end + re + end + ## # ISO 15.2.10.5.3 def =~(re) - re =~ self + _regexp(re, :=~) =~ self end ## # ISO 15.2.10.5.27 def match(re, &block) - if String === re - if Object.const_defined?(:Regexp) - r = Regexp.new(re) - r.match(self, &block) - else - raise NotImplementedError, "String#match needs Regexp class" - end - else - re.match(self, &block) - end + _regexp(re, :match).match(self, &block) end end diff --git a/src/variable.c b/src/variable.c index cf89a4a02..f97b09c52 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1114,7 +1114,9 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c) mrb_bool mrb_ident_p(const char *s, mrb_int len) { - for (mrb_int i = 0; i < len; i++) { + mrb_int i; + + for (i = 0; i < len; i++) { if (!identchar(s[i])) return FALSE; } return TRUE; |
