Mercurial > jwe > octave
changeset 28117:1db62b2d6c39
in push lexer, don't insert NL with ASCII 1 marker (bug #57859)
* lex.ll (push_lexer::fill_flex_buffer): Avoid inserting newline
character in buffer after ASCII 1 marker used to tell lexer to get
more input.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 19 Feb 2020 15:21:28 -0500 |
parents | 7fa1d6f670f5 |
children | 34a3d005e2ad |
files | libinterp/parse-tree/lex.ll |
diffstat | 1 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll Wed Feb 19 10:45:31 2020 -0800 +++ b/libinterp/parse-tree/lex.ll Wed Feb 19 15:21:28 2020 -0500 @@ -3798,19 +3798,30 @@ { int status = 0; - // If the input buffer is empty or we are at the end of the buffer, - // insert ASCII 1 as a marker for subsequent rules. - if (m_input_buf.empty () && ! m_input_buf.at_eof ()) - m_input_buf.fill (std::string (1, static_cast<char> (1)), false); - - // Note that the copy_chunk function may append a newline character - // to the input. - - if (! m_input_buf.empty ()) - status = m_input_buf.copy_chunk (buf, max_size); + { + // If the input buffer is empty or we are at the end of the + // buffer, insert ASCII 1 as a marker for subsequent rules. + // Don't insert a newline character in this case. Instead of + // calling input_buffer::fill followed immediately by + // input_buffer::copy_chunk, simply insert the marker directly + // in BUF. + + assert (max_size > 0); + + buf[0] = static_cast<char> (1); + status = 1; + } else - status = YY_NULL; + { + // Note that the copy_chunk function may append a newline + // character to the input. + + if (! m_input_buf.empty ()) + status = m_input_buf.copy_chunk (buf, max_size); + else + status = YY_NULL; + } return status; }