# HG changeset patch # User John W. Eaton # Date 1583704183 14400 # Node ID 9e983eb1749d984ed587ad32d4de18a868f3c991 # Parent c31c9eaa1f28598e2fdf59623e6866cbaaaf1cdd display code and error location when input is from terminal (bug #57536) * parse.yy (base_parser::bison_error): Use the current input line from the lexer if input is not coming from a file. Adjust error column to account for the use of 1-based column position in the lexer and for the position already being advanced to the position of the next token. diff -r c31c9eaa1f28 -r 9e983eb1749d libinterp/parse-tree/oct-parse.yy --- a/libinterp/parse-tree/oct-parse.yy Thu Feb 27 13:45:53 2020 -0500 +++ b/libinterp/parse-tree/oct-parse.yy Sun Mar 08 17:49:43 2020 -0400 @@ -4561,6 +4561,13 @@ if (m_lexer.m_reading_fcn_file || m_lexer.m_reading_script_file || m_lexer.m_reading_classdef_file) curr_line = get_file_line (m_lexer.m_fcn_file_full_name, err_line); + else + curr_line = m_lexer.m_current_input_line; + + // Adjust the error column for display because it is 1-based in the + // lexer for easier reporting and it has already been advanced to + // one past the end of the most recently read token. + err_col -= 2; if (! curr_line.empty ()) {