Patch: Improve demangling w.r.t. possible underscore prefix
Andrew Haley
aph@redhat.com
Mon Feb 17 15:01:00 GMT 2003
Ranjit Mathew writes:
> >It seems like it will break if ever __USER_LABEL_PREFIX__is not '_'.
>
> I'm guessing that you mean "...if ever __USER_LABEL_PREFIX__ is not '_'
> [and is not empty either]". Well, I checked for all instances of
> USER_LABEL_PREFIX in all files in "gcc/config" and its subfolders
> and every target either defines it to an underscore or an empty
> string. Besides, c++filt does not handle anything more complicated
> than an underscore. That way the patch looks fine to me, unless I've
> misunderstood your question completely.
>
>
> >Why can't you just cat __USER_LABEL_PREFIX__ to the start of the name?
> >Surround the whole thing by #ifdef __USER_LABEL_PREFIX__.
>
> By "cat" if you mean the "##" preprocessor operator, it does not work.
No, I mean that you can stringify __USER_LABEL_PREFIX__ by using the #
token.
So,
#define __USER_LABEL_PREFIX__ _
#define USER_LABEL_PREFIX_STRING0(s) #s
#define USER_LABEL_PREFIX_STRING(s) USER_LABEL_PREFIX_STRING0(s)
#define PREFIX USER_LABEL_PREFIX_STRING(__USER_LABEL_PREFIX__)
java::lang::String*
gnu::gcj::runtime::NameFinder::getExternalLabel (java::lang::String* name)
{
jsize nameLen = JvGetStringUTFLength (name);
char *newName = (char *) JvMalloc (strlen (PREFIX) + nameLen + 1);
strcpy (newName, PREFIX);
JvGetStringUTFRegion (name, 0, nameLen, newName + strlen (newName));
*(newName + strlen (PREFIX) + nameLen) = '\0';
return JvNewStringLatin1 (newName);
}
I haven't tested this, but you get the idea. It doesn't use gotos or
onstruct special symbols and it's won't break if ever
__USER_LABEL_PREFIX__ is "$" or somesuch.
Andrew.
More information about the Java
mailing list