Mercurial > hg > octave-kai
changeset 9483:25c2e92ee03c
correctly skip frame assigned to keyboard function
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 04 Aug 2009 12:59:16 -0400 |
parents | fb22dd5d6242 |
children | bbe033dcfe13 |
files | src/ChangeLog src/input.cc src/toplev.cc |
diffstat | 3 files changed, 60 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2009-08-04 John W. Eaton <jwe@octave.org> + + * 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 <highegg@gmail.com> * input.cc (Fkeyboard): Only call do_keyboard, don't fiddle with
--- a/src/input.cc +++ b/src/input.cc @@ -940,7 +940,15 @@ if (nargin == 0 || nargin == 1) { + unwind_protect::add_fcn (octave_call_stack::restore_frame, + octave_call_stack::current_frame ()); + + // Skip the frame assigned to the keyboard function. + octave_call_stack::goto_frame_relative (0, true); + do_keyboard (args); + + unwind_protect::run (); } else print_usage ();
--- 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; + + frame += incr; - // Start looking with the caller of dbup/dbdown. - size_t frame = cs[curr_frame].prev; + const call_stack_elt& elt = cs[frame]; - while (true) + octave_function *f = elt.fcn; + + if (f && f->is_user_code ()) { - if ((incr < 0 && frame == 0) || (incr > 0 && frame == cs.size () - 1)) - break; - - frame += incr; + if (nskip > 0) + nskip--; + else if (nskip < 0) + nskip++; - const call_stack_elt& elt = cs[frame]; - - octave_function *f = elt.fcn; - - if (f && f->is_user_code ()) + if (nskip == 0) { - if (nskip > 0) - nskip--; - else if (nskip < 0) - nskip++; + curr_frame = frame; + cs[cs.size () - 1].prev = curr_frame; + + symbol_table::set_scope_and_context (elt.scope, elt.context); - 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;