mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 22:31:36 +00:00
string-literals now do not treat digraphs as digraphs
This commit is contained in:
parent
90419eb13c
commit
415816e4dc
4 changed files with 8 additions and 5 deletions
4
lexer.c
4
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;
|
||||
|
|
1
lexer.h
1
lexer.h
|
@ -108,6 +108,7 @@ typedef struct {
|
|||
|
||||
struct {
|
||||
bool noops;
|
||||
bool nodigraphs; /* used when lexing string constants */
|
||||
} flags;
|
||||
|
||||
int framevalue;
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#^[]|{}~\
|
||||
#^[]|{}~\
|
||||
#^[]|{}~\%>
|
||||
#^[]|{}~\%>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
void(string, string) print = %:1;
|
||||
|
||||
void() main = ??<
|
||||
print("??=??'??(??)??!??<??>??-??/??/", "??/n");
|
||||
print("#^[]|{}~\\", "\n");
|
||||
print("??=??'??(??)??!??<??>??-??/??/%>", "??/n");
|
||||
print("#^[]|{}~\\%>", "\n");
|
||||
%>;
|
||||
|
|
Loading…
Reference in a new issue