diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-19 04:52:55 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-19 04:52:55 +0000 |
commit | f4ff7ccddf1f7090e23234d6cb37c17c617b4cd2 (patch) | |
tree | 78b5f63a80951b6dd111eefdf3789bc5d95d7ac9 /array.c | |
parent | f50984366b923176b4e5f10efd87e0a85829afa8 (diff) | |
download | ruby-f4ff7ccddf1f7090e23234d6cb37c17c617b4cd2.tar.gz |
* array.c (get_inspect_tbl): check whether inspect_tbl value is a
valid array. (ruby-bugs-ja PR#65)
* array.c (inspect_ensure,rb_protect_inspect,rb_inspecting_p):
use get_inspect_tbl().
* eval.c (rb_f_abort): call exit(1) if exception is raised. This
patch was made by Nobuyoshi Nakada <nobu.nokada@softhome.net> on
2002-05-30. (ruby-bugs-ja PR#236)
* signal.c: disable Ruby's interrupt handler at the beginning.
(ruby-bugs-ja PR#236)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -930,13 +930,35 @@ inspect_call(arg) } static VALUE +get_inspect_tbl(create) + int create; +{ + VALUE inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key); + + if (create && NIL_P(inspect_tbl)) { + tbl_init: + inspect_tbl = rb_ary_new(); + rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl); + } + else if (TYPE(inspect_tbl) != T_ARRAY) { + rb_warn("invalid inspect_tbl value"); + if (create) goto tbl_init; + rb_thread_local_aset(rb_thread_current(), inspect_key, Qnil); + return Qnil; + } + return inspect_tbl; +} + +static VALUE inspect_ensure(obj) VALUE obj; { VALUE inspect_tbl; - inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key); - rb_ary_pop(inspect_tbl); + inspect_tbl = get_inspect_tbl(Qfalse); + if (!NIL_P(inspect_tbl)) { + rb_ary_pop(inspect_tbl); + } return 0; } @@ -949,11 +971,7 @@ rb_protect_inspect(func, obj, arg) VALUE inspect_tbl; VALUE id; - inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key); - if (NIL_P(inspect_tbl)) { - inspect_tbl = rb_ary_new(); - rb_thread_local_aset(rb_thread_current(), inspect_key, inspect_tbl); - } + inspect_tbl = get_inspect_tbl(Qtrue); id = rb_obj_id(obj); if (rb_ary_includes(inspect_tbl, id)) { return (*func)(obj, arg); @@ -972,7 +990,7 @@ rb_inspecting_p(obj) { VALUE inspect_tbl; - inspect_tbl = rb_thread_local_aref(rb_thread_current(), inspect_key); + inspect_tbl = get_inspect_tbl(Qfalse); if (NIL_P(inspect_tbl)) return Qfalse; return rb_ary_includes(inspect_tbl, rb_obj_id(obj)); } |