diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-30 03:12:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-30 03:12:48 +0000 |
commit | b49e57970f205c0faa0548beab49c001d2accb79 (patch) | |
tree | 4297ee2d46e688f352ee22acb24b8a9e599b6b27 /vm_eval.c | |
parent | 10f06f5536cd7a37bcc073521f2273b3d61ab7a2 (diff) | |
download | ruby-b49e57970f205c0faa0548beab49c001d2accb79.tar.gz ruby-b49e57970f205c0faa0548beab49c001d2accb79.tar.xz ruby-b49e57970f205c0faa0548beab49c001d2accb79.zip |
* vm_eval.c (eval_string_with_cref): replaces the message if
frozen. [ruby-dev:38208]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -773,14 +773,22 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char if (strcmp(file, "(eval)") == 0) { VALUE mesg, errat, bt2; extern VALUE rb_get_backtrace(VALUE info); + ID id_mesg; + CONST_ID(id_mesg, "mesg"); errat = rb_get_backtrace(errinfo); - mesg = rb_attr_get(errinfo, rb_intern("mesg")); + mesg = rb_attr_get(errinfo, id_mesg); if (!NIL_P(errat) && TYPE(errat) == T_ARRAY && (bt2 = vm_backtrace(th, -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, RARRAY_PTR(errat)[0]); + if (OBJ_FROZEN(mesg)) { + VALUE m = rb_str_cat(rb_str_dup(RARRAY_PTR(errat)[0]), ": ", 2); + rb_ivar_set(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]; } |