diff options
| -rw-r--r-- | include/mruby.h | 4 | ||||
| -rw-r--r-- | include/mruby/compile.h | 1 | ||||
| -rw-r--r-- | include/mruby/hash.h | 3 | ||||
| -rw-r--r-- | include/mruby/string.h | 1 | ||||
| -rw-r--r-- | src/hash.c | 5 | ||||
| -rw-r--r-- | src/string.c | 12 |
6 files changed, 15 insertions, 11 deletions
diff --git a/include/mruby.h b/include/mruby.h index 1085756fd..fb73b60b9 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -307,10 +307,6 @@ typedef enum call_type { CALL_TYPE_MAX } call_type; -/* compar.c */ -void mrb_cmperr(mrb_state *mrb, mrb_value x, mrb_value y); -int mrb_cmpint(mrb_state *mrb, mrb_value val, mrb_value a, mrb_value b); - #ifndef ANYARGS # ifdef __cplusplus # define ANYARGS ... diff --git a/include/mruby/compile.h b/include/mruby/compile.h index e035b9e02..5bdc7ccea 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -101,7 +101,6 @@ struct mrb_parser_state { struct mrb_parser_state* mrb_parser_new(mrb_state*); void mrb_parser_free(struct mrb_parser_state*); -const char *mrb_parser_filename(struct mrb_parser_state*, const char*); void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*); /* utility functions */ diff --git a/include/mruby/hash.h b/include/mruby/hash.h index acb9de93b..ac28f13fd 100644 --- a/include/mruby/hash.h +++ b/include/mruby/hash.h @@ -27,7 +27,6 @@ void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val); mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key); mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def); mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key); -mrb_value mrb_hash(mrb_state *mrb, mrb_value obj); mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash); mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash); @@ -41,8 +40,6 @@ struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash); #define MRB_HASH_PROC_DEFAULT 256 #define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT) -mrb_value mrb_obj_is_proc(mrb_value proc); - /* GC functions */ void mrb_gc_mark_ht(mrb_state*, struct RHash*); size_t mrb_gc_mark_ht_size(mrb_state*, struct RHash*); diff --git a/include/mruby/string.h b/include/mruby/string.h index 4ff0f1ee1..38e8f930d 100644 --- a/include/mruby/string.h +++ b/include/mruby/string.h @@ -72,7 +72,6 @@ mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck) double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck); mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str); mrb_int mrb_str_hash(mrb_state *mrb, mrb_value str); -int mrb_str_hash_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2); mrb_value mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2); mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str); int mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2); diff --git a/src/hash.c b/src/hash.c index 26d9b78b0..b7ac59ada 100644 --- a/src/hash.c +++ b/src/hash.c @@ -821,8 +821,9 @@ mrb_hash_empty_p(mrb_state *mrb, mrb_value self) if (h) { if (kh_size(h) == 0) return mrb_true_value(); + return mrb_false_value(); } - return mrb_false_value(); + return mrb_true_value(); } /* 15.2.13.4.11 */ @@ -1123,7 +1124,7 @@ hash_equal(mrb_state *mrb, mrb_value hash1, mrb_value hash2, int eql) } h1 = RHASH_TBL(hash1); h2 = RHASH_TBL(hash2); - if (!h2) { + if (!h1) { if (!h2) return mrb_true_value(); return mrb_false_value(); } diff --git a/src/string.c b/src/string.c index df74bb3c8..99ea9753e 100644 --- a/src/string.c +++ b/src/string.c @@ -2141,6 +2141,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) end = beg; while (ptr < eptr) { + int ai = mrb_gc_arena_save(mrb); c = (unsigned char)*ptr++; if (skip) { if (ascii_isspace(c)) { @@ -2154,6 +2155,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) } else if (ascii_isspace(c)) { mrb_ary_push(mrb, result, mrb_str_subseq(mrb, str, beg, end-beg)); + mrb_gc_arena_restore(mrb, ai); skip = 1; beg = ptr - bptr; if (lim >= 0) ++i; @@ -2170,18 +2172,22 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) long slen = RSTRING_LEN(spat); if (slen == 0) { + int ai = mrb_gc_arena_save(mrb); while (ptr < eptr) { mrb_ary_push(mrb, result, mrb_str_subseq(mrb, str, ptr-temp, 1)); + mrb_gc_arena_restore(mrb, ai); ptr++; if (lim >= 0 && lim <= ++i) break; } } else { char *sptr = RSTRING_PTR(spat); + int ai = mrb_gc_arena_save(mrb); while (ptr < eptr && (end = mrb_memsearch(sptr, slen, ptr, eptr - ptr)) >= 0) { mrb_ary_push(mrb, result, mrb_str_subseq(mrb, str, ptr - temp, end)); + mrb_gc_arena_restore(mrb, ai); ptr += end + slen; if (lim >= 0 && lim <= ++i) break; } @@ -2198,14 +2204,18 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) struct re_registers *regs; while ((end = mrb_reg_search(mrb, spat, str, start, 0)) >= 0) { + int ai; regs = RMATCH_REGS(mrb_backref_get(mrb)); + ai = mrb_gc_arena_save(mrb); if (start == end && BEG(0) == END(0)) { if (!ptr) { mrb_ary_push(mrb, result, mrb_str_new_empty(mrb, str)); + mrb_gc_arena_restore(mrb, ai); break; } else if (last_null == 1) { mrb_ary_push(mrb, result, mrb_str_subseq(mrb, str, beg, len)); + mrb_gc_arena_restore(mrb, ai); beg = start; } else { @@ -2219,6 +2229,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) } else { mrb_ary_push(mrb, result, mrb_str_subseq(mrb, str, beg, end-beg)); + mrb_gc_arena_restore(mrb, ai); beg = start = END(0); } last_null = 0; @@ -2230,6 +2241,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str) else tmp = mrb_str_subseq(mrb, str, BEG(idx), END(idx)-BEG(idx)); mrb_ary_push(mrb, result, tmp); + mrb_gc_arena_restore(mrb, ai); } if (lim >= 0 && lim <= ++i) break; } |
