From 8a611251a92c9932e6cbe3d8953ac573075d2c3b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 12 Mar 2002 23:37:11 +0000 Subject: 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 --- gcc/java/jcf-parse.c | 48 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) (limited to 'gcc/java/jcf-parse.c') diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index c4faa8e..b19b9e9 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; -- cgit v1.1