From 15b31e7dc5ddef02acd22d0256cbfffe9df09b5c Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Fri, 17 Oct 2014 19:37:01 -0400 Subject: [PATCH] Support text type escape sequences \b and \s. --- lexer.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lexer.c b/lexer.c index 1a8c17a..7137325 100644 --- a/lexer.c +++ b/lexer.c @@ -681,7 +681,7 @@ static bool lex_finish_frames(lex_file *lex) static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) { utf8ch_t chr = 0; - int ch = 0; + int ch = 0, texttype = 0; int nextch; bool hex; bool oct; @@ -716,13 +716,12 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) case '\\': break; case '\'': break; case '"': break; - case 'a': ch = '\a'; break; - case 'b': ch = '\b'; break; - case 'r': ch = '\r'; break; - case 'n': ch = '\n'; break; - case 't': ch = '\t'; break; - case 'f': ch = '\f'; break; - case 'v': ch = '\v'; break; + case 'a': ch = '\a'; break; + case 'r': ch = '\r'; break; + case 'n': ch = '\n'; break; + case 't': ch = '\t'; break; + case 'f': ch = '\f'; break; + case 'v': ch = '\v'; break; case 'x': case 'X': /* same procedure as in fteqcc */ @@ -825,7 +824,15 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) else ch = chr; break; - case '\n': ch = '\n'; break; + + /* high bit text */ + case 'b': case 's': + texttype ^= 128; + continue; + + case '\n': + ch = '\n'; + break; default: lexwarn(lex, WARN_UNKNOWN_CONTROL_SEQUENCE, "unrecognized control sequence: \\%c", ch); @@ -833,7 +840,7 @@ static int GMQCC_WARN lex_finish_string(lex_file *lex, int quote) lex_tokench(lex, '\\'); } /* add the character finally */ - lex_tokench(lex, ch); + lex_tokench(lex, ch | texttype); } else lex_tokench(lex, ch); -- 2.39.2