From 415816e4dc9b76cb52386fb4abbae94d45420f9a Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Thu, 1 Nov 2012 14:05:14 +0100 Subject: [PATCH] string-literals now do not treat digraphs as digraphs --- lexer.c | 4 +++- lexer.h | 1 + testsuite/ngraphs/expected | 4 ++-- testsuite/ngraphs/main.qc | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lexer.c b/lexer.c index e08a5f6..634f90c 100644 --- a/lexer.c +++ b/lexer.c @@ -259,7 +259,7 @@ static int lex_getch(lex_file *lex) lex->line++; else if (ch == '?') return lex_try_trigraph(lex, ch); - else if (ch == '<' || ch == ':' || ch == '%') + else if (!lex->flags.nodigraphs && (ch == '<' || ch == ':' || ch == '%')) return lex_try_digraph(lex, ch); return ch; } @@ -998,6 +998,7 @@ int lex_do(lex_file *lex) if (ch == '"') { + lex->flags.nodigraphs = true; lex->tok.ttype = lex_finish_string(lex, '"'); while (lex->tok.ttype == TOKEN_STRINGCONST) { @@ -1010,6 +1011,7 @@ int lex_do(lex_file *lex) lex->tok.ttype = lex_finish_string(lex, '"'); } + lex->flags.nodigraphs = false; if (!lex_endtoken(lex)) return (lex->tok.ttype = TOKEN_FATAL); return lex->tok.ttype; diff --git a/lexer.h b/lexer.h index c2a9a49..8d525a5 100644 --- a/lexer.h +++ b/lexer.h @@ -108,6 +108,7 @@ typedef struct { struct { bool noops; + bool nodigraphs; /* used when lexing string constants */ } flags; int framevalue; diff --git a/testsuite/ngraphs/expected b/testsuite/ngraphs/expected index 81a5e67..d51a1ba 100644 --- a/testsuite/ngraphs/expected +++ b/testsuite/ngraphs/expected @@ -1,2 +1,2 @@ -#^[]|{}~\ -#^[]|{}~\ +#^[]|{}~\%> +#^[]|{}~\%> diff --git a/testsuite/ngraphs/main.qc b/testsuite/ngraphs/main.qc index 91e4ab4..ef2d38b 100644 --- a/testsuite/ngraphs/main.qc +++ b/testsuite/ngraphs/main.qc @@ -1,6 +1,6 @@ void(string, string) print = %:1; void() main = ??< - print("??=??'??(??)??!????-??/??/", "??/n"); - print("#^[]|{}~\\", "\n"); + print("??=??'??(??)??!????-??/??/%>", "??/n"); + print("#^[]|{}~\\%>", "\n"); %>; -- 2.39.2