From: Tom Tromey Date: Tue, 12 Mar 2002 23:37:11 +0000 (+0000) Subject: re PR java/5923 (gcj -C generates incorrect bytecode) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8a611251a92c9932e6cbe3d8953ac573075d2c3b;p=gcc.git re PR java/5923 (gcj -C generates incorrect bytecode) * jcf-parse.c (get_constant) [CONSTANT_String]: String values are UTF-8, not UCS-2. Fixes PR java/5923. From-SVN: r50695 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index e8b67fc0973..426720770cb 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,5 +1,8 @@ 2002-03-12 Tom Tromey + * 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. diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index c4faa8e3711..b19b9e9d84d 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -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;