Mercurial > projects > ddmd
diff dmd/Lexer.d @ 49:0aa7d1437ada
AttribDeclaration.oneMember
Lexer.decodeUTF
WithStatement.ctor
StructDeclaration.syntaxCopy
CtorDeclaration.syntaxCopy
ConditionalStatement.syntaxCopy
ProtDeclaration.syntaxCopy
ArrayScopeSymbol.this
TemplateDeclaration.toChars
author | korDen |
---|---|
date | Sat, 21 Aug 2010 07:53:20 +0400 |
parents | 544b922227c7 |
children | b7d29f613539 |
line wrap: on
line diff
--- a/dmd/Lexer.d Sat Aug 21 07:39:45 2010 +0400 +++ b/dmd/Lexer.d Sat Aug 21 07:53:20 2010 +0400 @@ -2466,9 +2466,36 @@ assert(false); } + /******************************************** + * Decode UTF character. + * Issue error messages for invalid sequences. + * Return decoded character, advance p to last character in UTF sequence. + */ uint decodeUTF() { - assert(false); + dchar u; + ubyte c; + ubyte* s = p; + size_t len; + size_t idx; + string msg; + + c = *s; + assert(c & 0x80); + + // Check length of remaining string up to 6 UTF-8 characters + for (len = 1; len < 6 && s[len]; len++) { + ; + } + + idx = 0; + msg = utf_decodeChar(cast(string)s[0..len], &idx, &u); + p += idx - 1; + if (msg) + { + error("%s", msg); + } + return u; } void getDocComment(Token* t, uint lineComment)