Commit 8a611251 by Tom Tromey Committed by Tom Tromey

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
parent 0ae02efa
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.
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment