From a1b9ce96e9ffcfa97e6b95817261f7af461c86c2 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 30 Mar 2009 03:12:08 +0000 Subject: [PATCH] * eval.c (rb_eval): checks for interrupt, stack and finalizers too. [ruby-dev:38208], [Bug #1329] * eval.c (eval): replaces the message if frozen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ eval.c | 34 +++++++++++++++++++++++++--------- version.h | 6 +++--- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 294c7e4524..67372ba364 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Mar 30 12:12:07 2009 Nobuyoshi Nakada + + * eval.c (rb_eval): checks for interrupt, stack and finalizers too. + [ruby-dev:38208], [Bug #1329] + + * eval.c (eval): replaces the message if frozen. + Sat Mar 28 04:31:36 2009 Nobuyoshi Nakada * ext/dl/{mkcall,mkcallback,mkcbtable}.rb: no needs of mkmf. diff --git a/eval.c b/eval.c index 7004726bc4..ce63b8df03 100644 --- a/eval.c +++ b/eval.c @@ -233,6 +233,7 @@ static VALUE rb_f_binding _((VALUE)); static void rb_f_END _((void)); static VALUE rb_f_block_given_p _((void)); static VALUE block_pass _((VALUE,NODE*)); +static void eval_check_tick _((void)); VALUE rb_cMethod; static VALUE method_call _((int, VALUE*, VALUE)); @@ -2998,6 +2999,7 @@ rb_eval(self, n) goto finish; \ } while (0) + eval_check_tick(); again: if (!node) RETURN(Qnil); @@ -5660,6 +5662,17 @@ stack_check() } } +static void +eval_check_tick() +{ + static int tick; + if ((++tick & 0xff) == 0) { + CHECK_INTS; /* better than nothing */ + stack_check(); + rb_gc_finalize_deferred(); + } +} + static int last_call_status; #define CSTAT_PRIV 1 @@ -5891,7 +5904,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags) NODE *b2; /* OK */ volatile VALUE result = Qnil; int itr; - static int tick; TMP_PROTECT; volatile int safe = -1; @@ -5910,11 +5922,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags) break; } - if ((++tick & 0xff) == 0) { - CHECK_INTS; /* better than nothing */ - stack_check(); - rb_gc_finalize_deferred(); - } + eval_check_tick(); if (argc < 0) { VALUE tmp; VALUE *nargv; @@ -6650,14 +6658,22 @@ eval(self, src, scope, file, line) if (state == TAG_RAISE) { if (strcmp(file, "(eval)") == 0) { VALUE mesg, errat, bt2; + ID id_mesg; + id_mesg = rb_intern("mesg"); errat = get_backtrace(ruby_errinfo); - mesg = rb_attr_get(ruby_errinfo, rb_intern("mesg")); + mesg = rb_attr_get(ruby_errinfo, id_mesg); if (!NIL_P(errat) && TYPE(errat) == T_ARRAY && (bt2 = backtrace(-2), RARRAY_LEN(bt2) > 0)) { if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) { - rb_str_update(mesg, 0, 0, rb_str_new2(": ")); - rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]); + if (OBJ_FROZEN(mesg)) { + VALUE m = rb_str_cat(rb_str_dup(RARRAY_PTR(errat)[0]), ": ", 2); + rb_ivar_set(ruby_errinfo, id_mesg, rb_str_append(m, mesg)); + } + else { + rb_str_update(mesg, 0, 0, rb_str_new2(": ")); + rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]); + } } RARRAY_PTR(errat)[0] = RARRAY_PTR(bt2)[0]; } diff --git a/version.h b/version.h index e93363f376..3cb8d534f2 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.8.8" -#define RUBY_RELEASE_DATE "2009-03-28" +#define RUBY_RELEASE_DATE "2009-03-30" #define RUBY_VERSION_CODE 188 -#define RUBY_RELEASE_CODE 20090328 +#define RUBY_RELEASE_CODE 20090330 #define RUBY_PATCHLEVEL -1 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 8 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 28 +#define RUBY_RELEASE_DAY 30 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];