string-literals now do not treat digraphs as digraphs

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-11-01 14:05:14 +01:00
parent 90419eb13c
commit 415816e4dc
4 changed files with 8 additions and 5 deletions

View file

@ -259,7 +259,7 @@ static int lex_getch(lex_file *lex)
lex->line++; lex->line++;
else if (ch == '?') else if (ch == '?')
return lex_try_trigraph(lex, 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 lex_try_digraph(lex, ch);
return ch; return ch;
} }
@ -998,6 +998,7 @@ int lex_do(lex_file *lex)
if (ch == '"') if (ch == '"')
{ {
lex->flags.nodigraphs = true;
lex->tok.ttype = lex_finish_string(lex, '"'); lex->tok.ttype = lex_finish_string(lex, '"');
while (lex->tok.ttype == TOKEN_STRINGCONST) while (lex->tok.ttype == TOKEN_STRINGCONST)
{ {
@ -1010,6 +1011,7 @@ int lex_do(lex_file *lex)
lex->tok.ttype = lex_finish_string(lex, '"'); lex->tok.ttype = lex_finish_string(lex, '"');
} }
lex->flags.nodigraphs = false;
if (!lex_endtoken(lex)) if (!lex_endtoken(lex))
return (lex->tok.ttype = TOKEN_FATAL); return (lex->tok.ttype = TOKEN_FATAL);
return lex->tok.ttype; return lex->tok.ttype;

View file

@ -108,6 +108,7 @@ typedef struct {
struct { struct {
bool noops; bool noops;
bool nodigraphs; /* used when lexing string constants */
} flags; } flags;
int framevalue; int framevalue;

View file

@ -1,2 +1,2 @@
#^[]|{}~\ #^[]|{}~\%>
#^[]|{}~\ #^[]|{}~\%>

View file

@ -1,6 +1,6 @@
void(string, string) print = %:1; void(string, string) print = %:1;
void() main = ??< void() main = ??<
print("??=??'??(??)??!??<??>??-??/??/", "??/n"); print("??=??'??(??)??!??<??>??-??/??/%>", "??/n");
print("#^[]|{}~\\", "\n"); print("#^[]|{}~\\%>", "\n");
%>; %>;