* eval.c (eval): check if backtrace is empty. [ruby-core:15040]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-01-14 18:41:44 +00:00
parent 45a5455d7a
commit 1c5640855f
2 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,7 @@
Tue Jan 15 03:41:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (eval): check if backtrace is empty. [ruby-core:15040]
Tue Jan 15 01:28:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Jan 15 01:28:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* common.mk: simplified dummy objects dependencies. * common.mk: simplified dummy objects dependencies.

9
eval.c
View File

@ -1757,16 +1757,17 @@ eval(VALUE self, VALUE src, VALUE scope, const char *file, int line)
if (state == TAG_RAISE) { if (state == TAG_RAISE) {
VALUE errinfo = th->errinfo; VALUE errinfo = th->errinfo;
if (strcmp(file, "(eval)") == 0) { if (strcmp(file, "(eval)") == 0) {
VALUE mesg, errat; VALUE mesg, errat, bt2;
errat = get_backtrace(errinfo); errat = get_backtrace(errinfo);
mesg = rb_attr_get(errinfo, rb_intern("mesg")); mesg = rb_attr_get(errinfo, rb_intern("mesg"));
if (!NIL_P(errat) && TYPE(errat) == T_ARRAY) { if (!NIL_P(errat) && TYPE(errat) == T_ARRAY &&
if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) { (bt2 = backtrace(-2), RARRAY_LEN(bt2) > 0)) {
if (!NIL_P(mesg) && TYPE(mesg) == T_STRING && !RSTRING_LEN(mesg)) {
rb_str_update(mesg, 0, 0, rb_str_new2(": ")); rb_str_update(mesg, 0, 0, rb_str_new2(": "));
rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]); rb_str_update(mesg, 0, 0, RARRAY_PTR(errat)[0]);
} }
RARRAY_PTR(errat)[0] = RARRAY_PTR(backtrace(-2))[0]; RARRAY_PTR(errat)[0] = RARRAY_PTR(bt2)[0];
} }
} }
rb_exc_raise(errinfo); rb_exc_raise(errinfo);