mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-25 14:50:18 +02:00
Merge DMD r292: bugzilla 3455 Some Unicode characters not allowed...
bugzilla 3455 Some Unicode characters not allowed in identifiers. --- dmd/lexer.c | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-)
This commit is contained in:
+22
-12
@@ -634,15 +634,25 @@ void Lexer::scan(Token *t)
|
|||||||
case '_':
|
case '_':
|
||||||
case_ident:
|
case_ident:
|
||||||
{ unsigned char c;
|
{ unsigned char c;
|
||||||
StringValue *sv;
|
|
||||||
Identifier *id;
|
|
||||||
|
|
||||||
do
|
while (1)
|
||||||
{
|
{
|
||||||
c = *++p;
|
c = *++p;
|
||||||
} while (isidchar(c) || (c & 0x80 && isUniAlpha(decodeUTF())));
|
if (isidchar(c))
|
||||||
sv = stringtable.update((char *)t->ptr, p - t->ptr);
|
continue;
|
||||||
id = (Identifier *) sv->ptrvalue;
|
else if (c & 0x80)
|
||||||
|
{ unsigned char *s = p;
|
||||||
|
unsigned u = decodeUTF();
|
||||||
|
if (isUniAlpha(u))
|
||||||
|
continue;
|
||||||
|
error("char 0x%04x not allowed in identifier", u);
|
||||||
|
p = s;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringValue *sv = stringtable.update((char *)t->ptr, p - t->ptr);
|
||||||
|
Identifier *id = (Identifier *) sv->ptrvalue;
|
||||||
if (!id)
|
if (!id)
|
||||||
{ id = new Identifier(sv->lstring.string,TOKidentifier);
|
{ id = new Identifier(sv->lstring.string,TOKidentifier);
|
||||||
sv->ptrvalue = id;
|
sv->ptrvalue = id;
|
||||||
@@ -1177,23 +1187,23 @@ void Lexer::scan(Token *t)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{ unsigned char c = *p;
|
{ unsigned c = *p;
|
||||||
|
|
||||||
if (c & 0x80)
|
if (c & 0x80)
|
||||||
{ unsigned u = decodeUTF();
|
{ c = decodeUTF();
|
||||||
|
|
||||||
// Check for start of unicode identifier
|
// Check for start of unicode identifier
|
||||||
if (isUniAlpha(u))
|
if (isUniAlpha(c))
|
||||||
goto case_ident;
|
goto case_ident;
|
||||||
|
|
||||||
if (u == PS || u == LS)
|
if (c == PS || c == LS)
|
||||||
{
|
{
|
||||||
loc.linnum++;
|
loc.linnum++;
|
||||||
p++;
|
p++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isprint(c))
|
if (c < 0x80 && isprint(c))
|
||||||
error("unsupported char '%c'", c);
|
error("unsupported char '%c'", c);
|
||||||
else
|
else
|
||||||
error("unsupported char 0x%02x", c);
|
error("unsupported char 0x%02x", c);
|
||||||
@@ -1455,7 +1465,7 @@ TOK Lexer::hexStringConstant(Token *t)
|
|||||||
if (u == PS || u == LS)
|
if (u == PS || u == LS)
|
||||||
loc.linnum++;
|
loc.linnum++;
|
||||||
else
|
else
|
||||||
error("non-hex character \\u%x", u);
|
error("non-hex character \\u%04x", u);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
error("non-hex character '%c'", c);
|
error("non-hex character '%c'", c);
|
||||||
|
|||||||
Reference in New Issue
Block a user