# HG changeset patch # User John W. Eaton # Date 1292391850 18000 # Node ID b2191ebea12fba01e5a6694d8d483d73c640d49b # Parent ad8966096e274f45d559a3e05ceddbbec2567550 don't process input_event_hook when we are parsing a function diff -r ad8966096e27 -r b2191ebea12f src/ChangeLog --- a/src/ChangeLog Tue Dec 14 18:40:38 2010 -0800 +++ b/src/ChangeLog Wed Dec 15 00:44:10 2010 -0500 @@ -1,3 +1,14 @@ +2010-12-15 John W. Eaton + + * lex.h (lexical_feedback::defining_func): Now int instead of bool. + lex.ll (is_keyword_token): Increment lexer_flags.defining_func + instead of setting it to true. + (lexical_feedback::init): Set defining_func to 0 instead of false. + * oct-parse.yy (recover_from_parsing_function): Decrement + lexer_flags.defining_func here. + * input.cc (input_event_hook): Don't do anything if we are + lexer_flags.defining_func is nonzero. + 2010-12-13 Rik * ov-struct.cc (isfield): Additional test for cellstring of field names. diff -r ad8966096e27 -r b2191ebea12f src/input.cc --- a/src/input.cc Tue Dec 14 18:40:38 2010 -0800 +++ b/src/input.cc Wed Dec 15 00:44:10 2010 -0500 @@ -1247,29 +1247,32 @@ static int input_event_hook (void) { - hook_fcn_map_type::iterator p = hook_fcn_map.begin (); - - while (p != hook_fcn_map.end ()) + if (! lexer_flags.defining_func) { - std::string hook_fcn = p->first; - octave_value user_data = p->second; + hook_fcn_map_type::iterator p = hook_fcn_map.begin (); - p++; - - if (is_valid_function (hook_fcn)) + while (p != hook_fcn_map.end ()) { - if (user_data.is_defined ()) - feval (hook_fcn, user_data, 0); + std::string hook_fcn = p->first; + octave_value user_data = p->second; + + p++; + + if (is_valid_function (hook_fcn)) + { + if (user_data.is_defined ()) + feval (hook_fcn, user_data, 0); + else + feval (hook_fcn, octave_value_list (), 0); + } else - feval (hook_fcn, octave_value_list (), 0); + hook_fcn_map.erase (p); } - else - hook_fcn_map.erase (p); + + if (hook_fcn_map.empty ()) + command_editor::remove_event_hook (input_event_hook); } - if (hook_fcn_map.empty ()) - command_editor::remove_event_hook (input_event_hook); - return 0; } diff -r ad8966096e27 -r b2191ebea12f src/lex.h --- a/src/lex.h Tue Dec 14 18:40:38 2010 -0800 +++ b/src/lex.h Wed Dec 15 00:44:10 2010 -0500 @@ -79,8 +79,8 @@ // command name is possible. bool at_beginning_of_statement; - // TRUE means we're in the middle of defining a function. - bool defining_func; + // Nonzero means we're in the middle of defining a function. + int defining_func; // Nonzero means we are parsing a function handle. int looking_at_function_handle; diff -r ad8966096e27 -r b2191ebea12f src/lex.ll --- a/src/lex.ll Tue Dec 14 18:40:38 2010 -0800 +++ b/src/lex.ll Wed Dec 15 00:44:10 2010 -0500 @@ -1580,7 +1580,7 @@ case function_kw: promptflag--; - lexer_flags.defining_func = true; + lexer_flags.defining_func++; lexer_flags.parsed_function_name = false; if (! (reading_fcn_file || reading_script_file @@ -3332,7 +3332,7 @@ looping = 0; // Not initially defining a function. - defining_func = false; + defining_func = 0; parsed_function_name = false; parsing_class_method = false; diff -r ad8966096e27 -r b2191ebea12f src/oct-parse.yy --- a/src/oct-parse.yy Tue Dec 14 18:40:38 2010 -0800 +++ b/src/oct-parse.yy Wed Dec 15 00:44:10 2010 -0500 @@ -1378,7 +1378,6 @@ std::string id_name = $1->name (); lexer_flags.parsed_function_name = true; - lexer_flags.defining_func = false; lexer_flags.maybe_classdef_get_set_method = false; $$ = $1; @@ -3000,6 +2999,7 @@ current_function_depth--; + lexer_flags.defining_func--; lexer_flags.parsed_function_name = false; lexer_flags.looking_at_return_list = false; lexer_flags.looking_at_parameter_list = false;