changeset 28145:9e983eb1749d stable

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.
author John W. Eaton <jwe@octave.org>
date Sun, 08 Mar 2020 17:49:43 -0400
parents c31c9eaa1f28
children 27c0b26e5a9f 648202bebcb0
files libinterp/parse-tree/oct-parse.yy
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 ())
       {