mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
digraphs
This commit is contained in:
parent
e6cebc3ea3
commit
6126db10df
1 changed files with 20 additions and 0 deletions
20
lexer.c
20
lexer.c
|
@ -225,6 +225,24 @@ static int lex_try_trigraph(lex_file *lex, int old)
|
|||
}
|
||||
}
|
||||
|
||||
static int lex_try_digraph(lex_file *lex, int ch)
|
||||
{
|
||||
int c2;
|
||||
c2 = fgetc(lex->file);
|
||||
if (ch == '<' && c2 == ':')
|
||||
return '[';
|
||||
else if (ch == ':' && c2 == '>')
|
||||
return ']';
|
||||
else if (ch == '<' && c2 == '%')
|
||||
return '{';
|
||||
else if (ch == '%' && c2 == '>')
|
||||
return '}';
|
||||
else if (ch == '%' && c2 == ':')
|
||||
return '#';
|
||||
lex_ungetch(lex, c2);
|
||||
return ch;
|
||||
}
|
||||
|
||||
static int lex_getch(lex_file *lex)
|
||||
{
|
||||
int ch;
|
||||
|
@ -241,6 +259,8 @@ static int lex_getch(lex_file *lex)
|
|||
lex->line++;
|
||||
else if (ch == '?')
|
||||
return lex_try_trigraph(lex, ch);
|
||||
else if (ch == '<' || ch == ':' || ch == '%')
|
||||
return lex_try_digraph(lex, ch);
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue