|
From: | Jaroslav Hajek |
Subject: | Re: keyboard does not provide local context |
Date: | Thu, 26 Nov 2009 14:21:40 +0100 |
OK, here is a changeset that is appropriate for 3.2.x. It seems toOn 25-Nov-2009, John W. Eaton wrote:
| On 24-Nov-2009, Jaroslav Hajek wrote:
|
| | > http://hg.savannah.gnu.org/hgweb/octave/rev/fb22dd5d6242
| | > http://hg.savannah.gnu.org/hgweb/octave/rev/25c2e92ee03c
| | > http://hg.savannah.gnu.org/hgweb/octave/rev/bbe033dcfe13
| | >
| | > Jaroslav, I think it is safe to apply the first two to the 3.2.x
| | > branch. I'm not so sure about the third one though as it removes some
| | > variables from a class and changes at least one function signature,
| | > which might cause some binary compatibility problems.
| | >
| |
| | These don't apply due to unwind_protect changes. I think the second one
| | reverts the first one, so maybe it would suffice to adapt the second one for
| | 3.2.x. Does it make sense without also taking the third one?
|
| I'll try to make a patch for 3.2.x today.
work correctly for me.
jwe
# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1259173915 18000
# Node ID 1ad2c6c73d1983b0b71b19ed81ccf371eaf07bec
# Parent 8294629109eb2965f723499ebedabc71ee255902
keyboard: fix stack manipulation
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
+2009-08-04 John W. Eaton <address@hidden>
+
+ * toplev.cc (octave_call_stack::do_goto_frame_relative): Allow
+ NSKIP to be 0. Set current scope and context.
+ * input.cc (Fkeyboard): Use octave_call_stack::goto_frame_relative
+ to set scope in user code that called the keyboard function.
+
+2009-08-04 Jaroslav Hajek <address@hidden>
+
+ * input.cc (Fkeyboard): Only call do_keyboard, don't fiddle with
+ stack.
+
2009-09-30 John W. Eaton <address@hidden>
* error.cc (error_1, pr_where_2, handle_message):
diff --git a/src/input.cc b/src/input.cc
--- a/src/input.cc
+++ b/src/input.cc
@@ -956,7 +956,7 @@
unwind_protect_size_t (saved_frame);
// Skip the frame assigned to the keyboard function.
- octave_call_stack::goto_frame (1);
+ octave_call_stack::goto_frame_relative (0, true);
do_keyboard (args);
diff --git a/src/toplev.cc b/src/toplev.cc
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -366,65 +366,67 @@
{
bool retval = false;
- if (nskip == 0)
- retval = true;
- else
+ int incr = 0;
+
+ if (nskip < 0)
+ incr = -1;
+ else if (nskip > 0)
+ incr = 1;
+
+ // Start looking with the caller of dbup/dbdown/keyboard.
+ size_t frame = cs[curr_frame].prev;
+
+ while (true)
{
- int incr = nskip < 0 ? -1 : 1;
+ if ((incr < 0 && frame == 0) || (incr > 0 && frame == cs.size () - 1))
+ break;
- // Start looking with the caller of dbup/dbdown.
- size_t frame = cs[curr_frame].prev;
+ frame += incr;
- while (true)
+ const call_stack_elt& elt = cs[frame];
+
+ octave_function *f = elt.fcn;
+
+ if (f && f->is_user_code ())
{
- if ((incr < 0 && frame == 0) || (incr > 0 && frame == cs.size () - 1))
- break;
+ if (nskip > 0)
+ nskip--;
+ else if (nskip < 0)
+ nskip++;
- frame += incr;
+ if (nskip == 0)
+ {
+ curr_frame = frame;
+ cs[cs.size () - 1].prev = curr_frame;
- const call_stack_elt& elt = cs[frame];
+ symbol_table::set_scope_and_context (elt.scope, elt.context);
- octave_function *f = elt.fcn;
-
- if (f && f->is_user_code ())
- {
- if (nskip > 0)
- nskip--;
- else if (nskip < 0)
- nskip++;
-
- if (nskip == 0)
+ if (verbose)
{
- curr_frame = frame;
- cs[cs.size () - 1].prev = curr_frame;
-
- if (verbose)
+ tree_statement *s = elt.stmt;
+ int l = -1;
+ int c = -1;
+ if (s)
{
- tree_statement *s = elt.stmt;
- int l = -1;
- int c = -1;
- if (s)
- {
- l = s->line ();
- c = s->column ();
- }
-
- std::ostringstream buf;
- buf << f->name () << ": " << " line " << l
- << ", column " << c << std::endl;
-
- octave_stdout << buf.str ();
+ l = s->line ();
+ c = s->column ();
}
- retval = true;
- break;
+ std::ostringstream buf;
+ buf << f->name () << ": " << " line " << l
+ << ", column " << c << std::endl;
+
+ octave_stdout << buf.str ();
}
+
+ retval = true;
+ break;
}
}
// There is no need to set scope and context here. That will
- // happen when the dbup/dbdown frame is popped and we jump to
- // the new "prev" frame set above.
+ // happen when the dbup/dbdown/keyboard frame is popped and we
+ // jump to the new "prev" frame set above.
}
return retval;
[Prev in Thread] | Current Thread | [Next in Thread] |