cp-demangle.c (demangle_identifier): Support extended Unicode characters.

* cp-demangle.c (demangle_identifier): Support extended Unicode
        characters.

From-SVN: r55354
This commit is contained in:
Jason Merrill 2002-07-09 19:57:09 -04:00 committed by Jason Merrill
parent abf92e2699
commit 28a34ec177
3 changed files with 48 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2002-07-10 Jason Merrill <jason@redhat.com>
* cp-demangle.c (demangle_identifier): Support extended Unicode
characters.
2002-07-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2002-07-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* cp-demangle.c (demangle_v3_with_details): Wrap in * cp-demangle.c (demangle_v3_with_details): Wrap in

View File

@ -51,6 +51,8 @@
#include <string.h> #include <string.h>
#endif #endif
#include <ctype.h>
#include "ansidecl.h" #include "ansidecl.h"
#include "libiberty.h" #include "libiberty.h"
#include "dyn-string.h" #include "dyn-string.h"
@ -1466,9 +1468,45 @@ demangle_identifier (dm, length, identifier)
while (length-- > 0) while (length-- > 0)
{ {
int ch;
if (end_of_name_p (dm)) if (end_of_name_p (dm))
return "Unexpected end of name in <identifier>."; return "Unexpected end of name in <identifier>.";
if (!dyn_string_append_char (identifier, next_char (dm))) ch = next_char (dm);
/* Handle extended Unicode characters. We encode them as __U{hex}_,
where {hex} omits leading 0's. For instance, '$' is encoded as
"__U24_". */
if (ch == '_'
&& peek_char (dm) == '_'
&& peek_char_next (dm) == 'U')
{
char buf[10];
int pos = 0;
advance_char (dm); advance_char (dm); length -= 2;
while (length-- > 0)
{
ch = next_char (dm);
if (!isxdigit (ch))
break;
buf[pos++] = ch;
}
if (ch != '_' || length < 0)
return STATUS_ERROR;
if (pos == 0)
{
/* __U_ just means __U. */
if (!dyn_string_append_cstr (identifier, "__U"))
return STATUS_ALLOCATION_FAILED;
continue;
}
else
{
buf[pos] = '\0';
ch = strtol (buf, 0, 16);
}
}
if (!dyn_string_append_char (identifier, ch))
return STATUS_ALLOCATION_FAILED; return STATUS_ALLOCATION_FAILED;
} }

View File

@ -2587,6 +2587,10 @@ JArray.t(JArray[])
_ZN4Prim1iEibcdfwPN4java4lang6StringEsx _ZN4Prim1iEibcdfwPN4java4lang6StringEsx
Prim.i(int, boolean, byte, double, float, char, java.lang.String, short, long) Prim.i(int, boolean, byte, double, float, char, java.lang.String, short, long)
# #
--format=java
_ZN4java4util14Map__U24_Entry11class__U24_E
java.util.Map$Entry.class$
#
--format=hp --format=hp
_Utf58_0_1__1_2147483647__2147483648 _Utf58_0_1__1_2147483647__2147483648
_Utf58_0_1__1_2147483647__2147483648 _Utf58_0_1__1_2147483647__2147483648