From: Wolfgang (Blub) Bumiller Date: Mon, 29 Oct 2012 12:56:00 +0000 (+0100) Subject: digraphs X-Git-Tag: 0.1-rc1~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6126db10df2426fbc8919cafbd53ef62488a7f64;p=xonotic%2Fgmqcc.git digraphs --- diff --git a/lexer.c b/lexer.c index 3730093..e08a5f6 100644 --- a/lexer.c +++ b/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; }