]> git.sur5r.net Git - cc65/commitdiff
Added wide char literals, but treat them identical as normal strings.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 18 Sep 2009 14:28:52 +0000 (14:28 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 18 Sep 2009 14:28:52 +0000 (14:28 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@4185 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/declare.c
src/cc65/expr.c
src/cc65/scanner.c
src/cc65/scanner.h

index 9061eb838d989477a57b1821f6ac0c5c2732eaff..5b742a826edee40682dc9b66c31f67cbb3123f57 100644 (file)
@@ -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;
index 9eed43aea4bc05f10829f1ee47ac6700dbe88374..6bf80782698638992f6a96289fe43c9fde3c28e5 100644 (file)
@@ -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;
index 2f5bfecb09216c0e23c7b6074cc818d8f54889a3..49fd291d5a0932e3d3bc90081f6d4f6ce79db6dd 100644 (file)
@@ -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 */
index 0b5b19a3e30c6b674c31a58f8405bab28d6da1dc..6c3db2ed21423da04df1e849fe55e59e960f9c5b 100644 (file)
@@ -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,