summaryrefslogtreecommitdiff
path: root/eval_error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-10 06:34:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-10 06:34:28 +0000
commit222d028808b839f911db718d34ff8c133a57c8ea (patch)
treea715468e1b027b8773192278581d989bad3cb38b /eval_error.c
parentc2b4f88fcb8c981ee8a0b7cf88b54e71036bf555 (diff)
eval_error.c: reduce setjmp
* eval_error.c (error_print): reduce calling setjmp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/eval_error.c b/eval_error.c
index 8a5ef27..bd691fc 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -78,11 +78,11 @@ set_backtrace(VALUE info, VALUE bt)
static void
error_print(void)
{
- volatile VALUE errat = Qnil; /* OK */
+ volatile VALUE errat = Qundef;
rb_thread_t *th = GET_THREAD();
VALUE errinfo = th->errinfo;
int raised_flag = th->raised_flag;
- volatile VALUE eclass, e;
+ volatile VALUE eclass = Qundef, e = Qundef;
const char *volatile einfo;
volatile long elen;
@@ -94,11 +94,15 @@ error_print(void)
if (TH_EXEC_TAG() == 0) {
errat = get_backtrace(errinfo);
}
- else {
+ else if (errat == Qundef) {
errat = Qnil;
}
- if (TH_EXEC_TAG())
+ else if (eclass == Qundef || e != Qundef) {
goto error;
+ }
+ else {
+ goto no_message;
+ }
if (NIL_P(errat)) {
const char *file = rb_sourcefile();
int line = rb_sourceline();
@@ -123,18 +127,17 @@ error_print(void)
}
eclass = CLASS_OF(errinfo);
- if (TH_EXEC_TAG() == 0) {
+ if (eclass != Qundef) {
e = rb_funcall(errinfo, rb_intern("message"), 0, 0);
StringValue(e);
einfo = RSTRING_PTR(e);
elen = RSTRING_LEN(e);
}
else {
+ no_message:
einfo = "";
elen = 0;
}
- if (TH_EXEC_TAG())
- goto error;
if (eclass == rb_eRuntimeError && elen == 0) {
warn_print(": unhandled exception\n");
}