diff --git a/libinterp/parse-tree/lex.ll b/libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -911,53 +911,47 @@ ANY_INCLUDING_NL (.|{NL}) curr_lexer->string_text += static_cast (result); } -"\\a" { - curr_lexer->lexer_debug ("\"\\\\a\""); - - curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\a'; - } - -"\\b" { - curr_lexer->lexer_debug ("\"\\\\b\""); - - curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\b'; - } - -"\\f" { - curr_lexer->lexer_debug ("\"\\\\f\""); +\\[abfnrtv] { + curr_lexer->lexer_debug ("\\\\[abfnrtv]"); + + static const char *msg = "the behavior of backslash escape sequences in double-quoted strings will change in a future version of Octave; please see the NEWS file for more information"; + + warning_with_id ("Octave:backslash-escape-compatibility", "%s", msg); curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\f'; - } - -"\\n" { - curr_lexer->lexer_debug ("\"\\\\n\""); - - curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\n'; - } - -"\\r" { - curr_lexer->lexer_debug ("\"\\\\r\""); - - curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\r'; - } - -"\\t" { - curr_lexer->lexer_debug ("\"\\\\t\""); - - curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\t'; - } - -"\\v" { - curr_lexer->lexer_debug ("\"\\\\v\""); - - curr_lexer->current_input_column += yyleng; - curr_lexer->string_text += '\v'; + switch (yytext[1]) + { + case 'a': + curr_lexer->string_text += '\a'; + break; + + case 'b': + curr_lexer->string_text += '\b'; + break; + + case 'f': + curr_lexer->string_text += '\f'; + break; + + case 'n': + curr_lexer->string_text += '\n'; + break; + + case 'r': + curr_lexer->string_text += '\r'; + break; + + case 't': + curr_lexer->string_text += '\t'; + break; + + case 'v': + curr_lexer->string_text += '\v'; + break; + + default: + panic_impossible (); + } } (\.\.\.){S}*{NL} {