# HG changeset patch # User John W. Eaton # Date 1390199666 18000 # Node ID b14cdae65abd9080c6320d0cf72e85fd8acdd07d # Parent 9a43d8d6e29ed1d9c29f3916f7064ebbbcb955f1 prevent lexer from matching patterns across CR line endings (bug #41281) * lex.ll: Use [^\r\n]*{NL} instead of .*{NL} to avoid matching patterns across lines that use CR only as line endings. diff -r 9a43d8d6e29e -r b14cdae65abd libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Wed Jan 15 15:22:03 2014 -0500 +++ b/libinterp/parse-tree/lex.ll Mon Jan 20 01:34:26 2014 -0500 @@ -256,6 +256,7 @@ EXPON ([DdEe][+-]?{D}+) NUMBER (({D}+\.?{D}*{EXPON}?)|(\.{D}+{EXPON}?)|(0[xX][0-9a-fA-F]+)) +ANY_EXCEPT_NL [^\r\n] ANY_INCLUDING_NL (.|{NL}) %% @@ -537,8 +538,8 @@ // Body of a block comment. %} -.*{NL} { - curr_lexer->lexer_debug (".*{NL}"); +{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("{ANY_EXCEPT_NL}*{NL}"); curr_lexer->input_line_number++; curr_lexer->current_input_column = 1; @@ -549,15 +550,15 @@ // Full-line or end-of-line comment. %} -{S}*{CCHAR}.*{NL} { - curr_lexer->lexer_debug ("{S}*{CCHAR}.*{NL}"); +{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); curr_lexer->push_start_state (LINE_COMMENT_START); yyless (0); } -{S}*{CCHAR}.*{NL} { - curr_lexer->lexer_debug ("{S}*{CCHAR}.*{NL}"); +{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); bool full_line_comment = curr_lexer->current_input_column == 1; curr_lexer->input_line_number++; @@ -770,8 +771,8 @@ } (\.\.\.){S}*{NL} | -(\.\.\.){S}*{CCHAR}.*{NL} { - curr_lexer->lexer_debug ("(\\.\\.\\.){S}*{NL}|(\\.\\.\\.){S}*{CCHAR}.*{NL}"); +(\.\.\.){S}*{CCHAR}{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("(\\.\\.\\.){S}*{NL}|(\\.\\.\\.){S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); static const char *msg = "'...' continuations in double-quoted character strings are obsolete and will not be allowed in a future version of Octave; please use '\\' instead"; @@ -788,8 +789,8 @@ } \\{S}+{NL} | -\\{S}*{CCHAR}.*{NL} { - curr_lexer->lexer_debug ("\\\\{S}+{NL}|\\\\{S}*{CCHAR}.*{NL}"); +\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("\\\\{S}+{NL}|\\\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); static const char *msg = "white space and comments after continuation markers in double-quoted character strings are obsolete and will not be allowed in a future version of Octave"; @@ -975,8 +976,8 @@ // Continuation lines. Allow arbitrary text after continuations. %} -\.\.\..*{NL} { - curr_lexer->lexer_debug ("\\.\\.\\..*{NL}"); +\.\.\.{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("\\.\\.\\.{ANY_EXCEPT_NL}*{NL}"); curr_lexer->handle_continuation (); } @@ -986,8 +987,8 @@ %} \\{S}*{NL} | -\\{S}*{CCHAR}.*{NL} { - curr_lexer->lexer_debug ("\\\\{S}*{NL}|\\\\{S}*{CCHAR}.*{NL}"); +\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("\\\\{S}*{NL}|\\\\{S}*{CCHAR}{ANY_EXCEPT_NL}*{NL}"); static const char *msg = "using continuation marker \\ outside of double quoted strings is deprecated and will be removed in a future version of Octave";