[gcjx] Patch: FYI: decode utf8 correctly

Tom Tromey tromey@redhat.com
Sun Apr 17 16:16:00 GMT 2005


I'm checking this in on the gcjx branch.

We now correctly compute the hash code of utf8consts containing
non-ascii data.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* builtins.cc: Include util.h.
	(hash_utf8): Use UTF8_GET.
	* util.h (append_gpp_mangled_name): Wrap in 'extern "C"'.

Index: builtins.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.cc,v
retrieving revision 1.1.2.30
diff -u -r1.1.2.30 builtins.cc
--- builtins.cc 4 Apr 2005 00:52:42 -0000 1.1.2.30
+++ builtins.cc 17 Apr 2005 16:15:36 -0000
@@ -25,6 +25,7 @@
 // This include must come first.
 #include "java/glue.hh"
 #include "aot/mangle.hh"
+#include "java/util.h"
 
 tree_builtins::tree_builtins ()
   : aot_class_factory (),
@@ -442,9 +443,7 @@
   int hash = 0;
   while (ptr < limit)
     {
-      // FIXME
-      // int ch = UTF8_GET (ptr, limit);
-      int ch = *ptr++;
+      int ch = UTF8_GET (ptr, limit);
       /* Updated specification from
 	 http://www.javasoft.com/docs/books/jls/clarify.html. */
       hash = (31 * hash) + ch;
Index: util.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/util.h,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 util.h
--- util.h 4 Apr 2005 04:30:32 -0000 1.1.2.2
+++ util.h 17 Apr 2005 16:15:36 -0000
@@ -42,6 +42,13 @@
    ? (((PTR)[-3]&0x0F) << 12) + (((PTR)[-2]&0x3F) << 6) + ((PTR)[-1]&0x3F) \
    : ((PTR)++, -1))
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
 extern void append_gpp_mangled_name (const char *name, int len);
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* GCC_JAVA_UTIL_H */



More information about the Java-patches mailing list