OSDN Git Service

* jcf-parse.c (get_constant) [CONSTANT_String]: String values are
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Mar 2002 23:37:11 +0000 (23:37 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Mar 2002 23:37:11 +0000 (23:37 +0000)
UTF-8, not UCS-2.  Fixes PR java/5923.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50695 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/jcf-parse.c

index e8b67fc..4267207 100644 (file)
@@ -1,5 +1,8 @@
 2002-03-12  Tom Tromey  <tromey@redhat.com>
 
+       * jcf-parse.c (get_constant) [CONSTANT_String]: String values are
+       UTF-8, not UCS-2.  Fixes PR java/5923.
+
        * parse.y (qualify_ambiguous_name): Handle case where QUAL_WFL is
        a call_expr wrapped in a convert.  Fixes PR java/5848.
 
index c4faa8e..b19b9e9 100644 (file)
@@ -350,13 +350,11 @@ get_constant (jcf, index)
        unsigned char *str_ptr;
        unsigned char *str;
        const unsigned char *utf8;
-       int i, str_len;
+       int i;
 
-       /* Count the number of Unicode characters in the string,
-          while checking for a malformed Utf8 string. */
+       /* Check for a malformed Utf8 string.  */
        utf8 = (const unsigned char *) utf8_ptr;
        i = utf8_len;
-       str_len = 0;
        while (i > 0)
          {
            int char_len = UT8_CHAR_LENGTH (*utf8);
@@ -365,48 +363,10 @@ get_constant (jcf, index)
 
            utf8 += char_len;
            i -= char_len;
-           str_len++;
          }
 
-       /* Allocate a scratch buffer, convert the string to UCS2, and copy it
-          into the new space.  */
-       str_ptr = (unsigned char *) alloca (2 * str_len);
-       str = str_ptr;
-       utf8 = (const unsigned char *)utf8_ptr;
-
-       for (i = 0; i < str_len; i++)
-         {
-           int char_value;
-           int char_len = UT8_CHAR_LENGTH (*utf8);
-           switch (char_len)
-             {
-             case 1:
-               char_value = *utf8++;
-               break;
-             case 2:
-               char_value = *utf8++ & 0x1F;
-               char_value = (char_value << 6) | (*utf8++ & 0x3F);
-               break;
-             case 3:
-               char_value = *utf8++ & 0x0F;
-               char_value = (char_value << 6) | (*utf8++ & 0x3F);
-               char_value = (char_value << 6) | (*utf8++ & 0x3F);
-               break;
-             default:
-               goto bad;
-             }
-           if (BYTES_BIG_ENDIAN)
-             {
-               *str++ = char_value >> 8;
-               *str++ = char_value & 0xFF;
-             }
-           else
-             {
-               *str++ = char_value & 0xFF;
-               *str++ = char_value >> 8;
-             }
-         }
-       value = build_string (str - str_ptr, str_ptr);
+       /* Allocate a new string value.  */
+       value = build_string (utf8_len, utf8_ptr);
        TREE_TYPE (value) = build_pointer_type (string_type_node);
       }
       break;