# HG changeset patch # User John W. Eaton # Date 1362616788 18000 # Node ID 0467d68ca89138e2da38e35d2b0291c4872c7c46 # Parent 9ba5c5ed3aebe72c059031db12d8c2b4326507f3 move current_input_line to lexical_feedback class * input.h, input.cc, lex.h, lex.ll (current_input_line): Declare as member of lexical_feedback class. (octave_base_reader::octave_gets, octave_terminal_reader::get_input, octave_file_reader::get_input, octave_eval_string_reader::get_input): Don't set current_input_line. (octave_lexer::read): Set current_input_line. * oct-parse.in.yy (octave_parser::bison_error): Use curr_lexer->current_input_line. diff -r 9ba5c5ed3aeb -r 0467d68ca891 libinterp/interpfcn/input.cc --- a/libinterp/interpfcn/input.cc Wed Mar 06 15:10:22 2013 -0800 +++ b/libinterp/interpfcn/input.cc Wed Mar 06 19:39:48 2013 -0500 @@ -106,9 +106,6 @@ // Should we issue a prompt? int promptflag = 1; -// The current line of input, from wherever. -std::string current_input_line; - // TRUE after a call to completion_matches. bool octave_completion_matches_called = false; @@ -242,19 +239,17 @@ history_skip_auto_repeated_debugging_command = true; } - current_input_line = retval; - - if (! current_input_line.empty ()) + if (! retval.empty ()) { if (! history_skip_auto_repeated_debugging_command) - command_history::add (current_input_line); + command_history::add (retval); - octave_diary << current_input_line; + octave_diary << retval; - if (current_input_line[current_input_line.length () - 1] != '\n') + if (retval[retval.length () - 1] != '\n') octave_diary << "\n"; - do_input_echo (current_input_line); + do_input_echo (retval); } else octave_diary << "\n"; @@ -560,11 +555,7 @@ eof = false; - std::string retval = octave_gets (eof); - - current_input_line = retval; - - return retval; + return octave_gets (eof); } const std::string octave_file_reader::in_src ("file"); @@ -576,11 +567,7 @@ eof = false; - std::string retval = octave_fgets (file, eof); - - current_input_line = retval; - - return retval; + return octave_fgets (file, eof); } const std::string octave_eval_string_reader::in_src ("eval_string"); @@ -603,8 +590,6 @@ if (retval.empty ()) eof = true; - current_input_line = retval; - return retval; } diff -r 9ba5c5ed3aeb -r 0467d68ca891 libinterp/interpfcn/input.h --- a/libinterp/interpfcn/input.h Wed Mar 06 15:10:22 2013 -0800 +++ b/libinterp/interpfcn/input.h Wed Mar 06 19:39:48 2013 -0500 @@ -49,9 +49,6 @@ // Should we issue a prompt? extern int promptflag; -// A line of input. -extern std::string current_input_line; - // TRUE after a call to completion_matches. extern bool octave_completion_matches_called; diff -r 9ba5c5ed3aeb -r 0467d68ca891 libinterp/parse-tree/lex.h --- a/libinterp/parse-tree/lex.h Wed Mar 06 15:10:22 2013 -0800 +++ b/libinterp/parse-tree/lex.h Wed Mar 06 19:39:48 2013 -0500 @@ -177,9 +177,10 @@ bracketflag (0), braceflag (0), looping (0), defining_func (0), looking_at_function_handle (0), block_comment_nesting_level (0), token_count (0), - help_text (), fcn_file_name (), fcn_file_full_name (), - looking_at_object_index (), parsed_function_name (), - pending_local_variables (), nesting_level (), token_stack () + current_input_line (), help_text (), fcn_file_name (), + fcn_file_full_name (), looking_at_object_index (), + parsed_function_name (), pending_local_variables (), + nesting_level (), token_stack () { init (); } @@ -287,6 +288,9 @@ // since the last reset. size_t token_count; + // The current line of input. + std::string current_input_line; + // The current help text. std::string help_text; diff -r 9ba5c5ed3aeb -r 0467d68ca891 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Wed Mar 06 15:10:22 2013 -0800 +++ b/libinterp/parse-tree/lex.ll Wed Mar 06 19:39:48 2013 -0500 @@ -1337,6 +1337,7 @@ looking_at_function_handle = 0; block_comment_nesting_level = 0; token_count = 0; + current_input_line = ""; help_text = ""; fcn_file_name = ""; fcn_file_full_name = ""; @@ -1479,8 +1480,8 @@ if (input_buf.empty ()) { bool eof = false; - std::string input = input_reader.get_input (eof); - input_buf.fill (input, eof); + current_input_line = input_reader.get_input (eof); + input_buf.fill (current_input_line, eof); } if (! input_buf.empty ()) diff -r 9ba5c5ed3aeb -r 0467d68ca891 libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Wed Mar 06 15:10:22 2013 -0800 +++ b/libinterp/parse-tree/oct-parse.in.yy Wed Mar 06 19:39:48 2013 -0500 @@ -3101,16 +3101,18 @@ output_buf << "\n\n"; - if (! current_input_line.empty ()) + std::string curr_line = curr_lexer->current_input_line; + + if (! curr_line.empty ()) { - size_t len = current_input_line.length (); - - if (current_input_line[len-1] == '\n') - current_input_line.resize (len-1); + size_t len = curr_line.length (); + + if (curr_line[len-1] == '\n') + curr_line.resize (len-1); // Print the line, maybe with a pointer near the error token. - output_buf << ">>> " << current_input_line << "\n"; + output_buf << ">>> " << curr_line << "\n"; if (err_col == 0) err_col = len;