OSDN Git Service

PR java/17575:
[pf3gnuchains/gcc-fork.git] / gcc / java / gjavah.c
index b4e6ca3..d62e585 100644 (file)
@@ -636,6 +636,22 @@ name_is_method_p (const unsigned char *name, int length)
   return 0;
 }
 
+/* Free the method name list.  */
+static void
+free_method_name_list ()
+{
+  struct method_name *p = method_name_list;
+  while (p != NULL)
+    {
+      struct method_name *next = p->next;
+      free (p->name);
+      free (p->signature);
+      free (p);
+      p = next;
+    }
+  method_name_list = NULL;
+}
+
 /* If there is already a native method named NAME, whose signature is not
    SIGNATURE, then return true.  Otherwise return false.  */
 static int
@@ -719,11 +735,10 @@ print_field_info (FILE *stream, JCF* jcf, int name_index, int sig_index,
 
   fputs ("  ", out);
   if ((flags & ACC_STATIC))
-    fputs ("static ", out);
-
-  if ((flags & ACC_FINAL))
     {
-      if (current_field_value > 0)
+      fputs ("static ", out);
+
+      if ((flags & ACC_FINAL) && current_field_value > 0)
        {
          char buffer[25];
          int done = 1;
@@ -1145,11 +1160,11 @@ throwable_p (const unsigned char *clname)
                                    (htab_del) free);
 
       /* Make sure the root classes show up in the tables.  */
-      str = xstrdup ("java.lang.Throwable");
+      str = (unsigned char *) xstrdup ("java.lang.Throwable");
       slot = htab_find_slot (throw_hash, str, INSERT);
       *slot = str;
 
-      str = xstrdup ("java.lang.Object");
+      str = (unsigned char *) xstrdup ("java.lang.Object");
       slot = htab_find_slot (non_throw_hash, str, INSERT);
       *slot = str;
 
@@ -1176,7 +1191,7 @@ throwable_p (const unsigned char *clname)
       void **slot;
       unsigned char *super, *tmp;
       int super_length = -1;
-      const char *classfile_name = find_class (current, strlen (current),
+      const char *classfile_name = find_class ((char *) current, strlen ((const char *) current),
                                               &jcf, 0);
 
       if (! classfile_name)
@@ -1322,10 +1337,10 @@ decode_signature_piece (FILE *stream, const unsigned char *signature,
       if (flag_jni)
        {
          /* We know about certain types and special-case their names.  */
-         if (! strncmp (signature, "Ljava/lang/String;",
+         if (! strncmp ((const char *) signature, "Ljava/lang/String;",
                         sizeof ("Ljava/lang/String;") -1))
            ctype = "jstring";
-         else if (! strncmp (signature, "Ljava/lang/Class;",
+         else if (! strncmp ((const char *) signature, "Ljava/lang/Class;",
                              sizeof ("Ljava/lang/Class;") - 1))
            ctype = "jclass";
          /* Skip leading 'L' for throwable_p call.  */
@@ -1470,7 +1485,7 @@ print_full_cxx_name (FILE* stream, JCF* jcf, int name_index,
       int sig_len = JPOOL_UTF_LENGTH (jcf, signature_index);
       if (overloaded_jni_method_exists_p (JPOOL_UTF_DATA (jcf, name_index),
                                          JPOOL_UTF_LENGTH (jcf, name_index),
-                                         signature, sig_len))
+                                         (const char *) signature, sig_len))
        {
          /* If this method is overloaded by another native method,
             then include the argument information in the mangled
@@ -1744,19 +1759,19 @@ print_include (FILE *out, const unsigned char *utf8, int len)
     return;
 
   if (len == -1)
-    len = strlen (utf8);
+    len = strlen ((const char *) utf8);
 
   for (incl = all_includes; incl; incl = incl->next)
     {
       /* We check the length because we might have a proper prefix.  */
       if (len == (int) strlen (incl->name)
-         && ! strncmp (incl->name, utf8, len))
+         && ! strncmp (incl->name, (const char *) utf8, len))
        return;
     }
 
   incl = xmalloc (sizeof (struct include));
   incl->name = xmalloc (len + 1);
-  strncpy (incl->name, utf8, len);
+  strncpy (incl->name, (const char *) utf8, len);
   incl->name[len] = '\0';
   incl->next = all_includes;
   all_includes = incl;
@@ -1815,11 +1830,11 @@ add_namelet (const unsigned char *name, const unsigned char *name_limit,
 #define JAVAIO "java/io/"
 #define JAVAUTIL "java/util/"
       if ((name_limit - name >= (int) sizeof (JAVALANG) - 1
-          && ! strncmp (name, JAVALANG, sizeof (JAVALANG) - 1))
+          && ! strncmp ((const char *) name, JAVALANG, sizeof (JAVALANG) - 1))
          || (name_limit - name >= (int) sizeof (JAVAUTIL) - 1
-             && ! strncmp (name, JAVAUTIL, sizeof (JAVAUTIL) - 1))
+             && ! strncmp ((const char *) name, JAVAUTIL, sizeof (JAVAUTIL) - 1))
          || (name_limit - name >= (int) sizeof (JAVAIO) - 1
-             && ! strncmp (name, JAVAIO, sizeof (JAVAIO) - 1)))
+             && ! strncmp ((const char *) name, JAVAIO, sizeof (JAVAIO) - 1)))
        return;
     }
 
@@ -1831,7 +1846,7 @@ add_namelet (const unsigned char *name, const unsigned char *name_limit,
     {
       /* We check the length because we might have a proper prefix.  */
       if ((int) strlen (np->name) == p - name &&
-         ! strncmp (name, np->name, p - name))
+         ! strncmp ((const char *) name, np->name, p - name))
        {
          n = np;
          break;
@@ -1842,7 +1857,7 @@ add_namelet (const unsigned char *name, const unsigned char *name_limit,
     {
       n = xmalloc (sizeof (struct namelet));
       n->name = xmalloc (p - name + 1);
-      strncpy (n->name, name, p - name);
+      strncpy (n->name, (const char *) name, p - name);
       n->name[p - name] = '\0';
       n->is_class = (p == name_limit);
       n->subnamelets = NULL;
@@ -1924,7 +1939,7 @@ add_class_decl (FILE *out, JCF *jcf, JCF_u2 signature)
       /* If we see an array, then we include the array header.  */
       if (s[i] == '[')
        {
-         print_include (out, "gcj/array", -1);
+         print_include (out, (const unsigned char *) "gcj/array", -1);
          continue;
        }
 
@@ -2095,13 +2110,13 @@ process_file (JCF *jcf, FILE *out)
          for (i = 0; i < len; ++i)
            name[i] = jcf->classname[i] == '.' ? '/' : jcf->classname[i];
          name[i] = '\0';
-         print_include (out, name, len);
+         print_include (out, (const unsigned char *) name, len);
          free (name);
 
          if (! flag_jni)
            {
-             print_include (out, "gcj/cni", -1);
-             print_include (out, "java/lang/UnsupportedOperationException",
+             print_include (out, (const unsigned char *) "gcj/cni", -1);
+             print_include (out, (const unsigned char *) "java/lang/UnsupportedOperationException",
                             -1);
            }
        }
@@ -2531,6 +2546,7 @@ main (int argc, char** argv)
                }
            }
        }
+      free_method_name_list ();
       process_file (&jcf, out);
       JCF_FINISH (&jcf);
       if (current_output_file != output_file)