summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index aa97595cf1..0655cadc5e 100644
--- a/eval.c
+++ b/eval.c
@@ -7267,6 +7267,7 @@ rb_thread_save_context(th)
{
VALUE *pos;
int len;
+ static VALUE tval;
len = stack_length(&pos);
th->stk_len = 0;
@@ -7294,8 +7295,12 @@ rb_thread_save_context(th)
th->tracing = tracing;
th->errinfo = ruby_errinfo;
th->last_status = rb_last_status;
- th->last_line = rb_lastline_get();
- th->last_match = rb_backref_get();
+ tval = rb_lastline_get();
+ rb_lastline_set(th->last_line);
+ th->last_line = tval;
+ tval = rb_backref_get();
+ rb_backref_set(th->last_match);
+ th->last_match = tval;
th->safe = ruby_safe_level;
th->file = ruby_sourcefile;
@@ -7359,6 +7364,7 @@ rb_thread_restore_context(th, exit)
VALUE v;
static rb_thread_t tmp;
static int ex;
+ static VALUE tval;
if (!th->stk_ptr) rb_bug("unsaved context");
@@ -7395,8 +7401,12 @@ rb_thread_restore_context(th, exit)
FLUSH_REGISTER_WINDOWS;
MEMCPY(tmp->stk_pos, tmp->stk_ptr, VALUE, tmp->stk_len);
+ tval = rb_lastline_get();
rb_lastline_set(tmp->last_line);
+ tmp->last_line = tval;
+ tval = rb_backref_get();
rb_backref_set(tmp->last_match);
+ tmp->last_match = tval;
longjmp(tmp->context, ex);
}