diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 9061eb838..5b742a826 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -1758,8 +1758,9 @@ static unsigned ParseArrayInit (Type* T, int AllowFlexibleMembers) /* Special handling for a character array initialized by a literal */ if (IsTypeChar (ElementType) && - (CurTok.Tok == TOK_SCONST || - (CurTok.Tok == TOK_LCURLY && NextTok.Tok == TOK_SCONST))) { + (CurTok.Tok == TOK_SCONST || CurTok.Tok == TOK_WCSCONST || + (CurTok.Tok == TOK_LCURLY && + (NextTok.Tok == TOK_SCONST || NextTok.Tok == TOK_WCSCONST)))) { /* Char array initialized by string constant */ int NeedParen; diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 9eed43aea..6bf807826 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -740,6 +740,7 @@ static void Primary (ExprDesc* E) break; case TOK_SCONST: + case TOK_WCSCONST: /* String literal */ E->Type = GetCharArrayType (GetLiteralPoolOffs () - CurTok.IVal); E->Flags = E_LOC_LITERAL | E_RTYPE_RVAL; diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 2f5bfecb0..49fd291d5 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2008 Ullrich von Bassewitz */ -/* Roemerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -410,21 +410,36 @@ static void StringConst (void) NextTok.IVal = GetLiteralPoolOffs (); NextTok.Tok = TOK_SCONST; - /* Be sure to concatenate strings */ - while (CurC == '\"') { + /* Concatenate strings. If at least one of the concenated strings is a wide + * character literal, the whole string is a wide char literal, otherwise + * it's a normal string literal. + */ + while (1) { - /* Skip the quote char */ - NextChar (); + /* Check if this is a normal or a wide char string */ + if (CurC == 'L' && NextC == '\"') { + /* Wide character literal */ + NextTok.Tok = TOK_WCSCONST; + NextChar (); + NextChar (); + } else if (CurC == '\"') { + /* Skip the quote char */ + NextChar (); + } else { + /* No string */ + break; + } - while (CurC != '\"') { - if (CurC == '\0') { - Error ("Unexpected newline"); - break; - } - AddLiteralChar (ParseChar ()); - } + /* Read until end of string */ + while (CurC != '\"') { + if (CurC == '\0') { + Error ("Unexpected newline"); + break; + } + AddLiteralChar (ParseChar ()); + } - /* Skip closing quote char if there was one */ + /* Skip closing quote char if there was one */ NextChar (); /* Skip white space, read new input */ @@ -718,6 +733,13 @@ void NextToken (void) return; } + /* Check for wide character literals */ + if (CurC == 'L' && NextC == '\"') { + StringConst (); + return; + } + + /* Check for keywords and identifiers */ if (IsSym (token)) { /* Check for a keyword */ diff --git a/src/cc65/scanner.h b/src/cc65/scanner.h index 0b5b19a3e..6c3db2ed2 100644 --- a/src/cc65/scanner.h +++ b/src/cc65/scanner.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2004 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -169,6 +169,7 @@ typedef enum token_t { TOK_ICONST, TOK_CCONST, TOK_FCONST, + TOK_WCSCONST, TOK_ATTRIBUTE, TOK_FAR,