]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
jcf-io.c: Don't include fnmatch.h.
authorTom Tromey <tromey@redhat.com>
Sun, 6 Jul 2008 13:33:05 +0000 (13:33 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Sun, 6 Jul 2008 13:33:05 +0000 (13:33 +0000)
* jcf-io.c: Don't include fnmatch.h.  Don't use JCF_USE_SCANDIR.
(compare_path): Remove.
(java_or_class_file): Likewise.
(memoized_dirlist_entry): Likewise.
(memoized_dirlist_hash): Likewise.
(memoized_dirlist_lookup_eq): Likewise.
(memoized_dirlists): Likewise.
(caching_stat): Likewise.
(find_class): Use stat.
* jcf.h (JCF_USE_SCANDIR): Remove.

From-SVN: r137523

gcc/java/ChangeLog
gcc/java/jcf-io.c
gcc/java/jcf.h

index 33ac01f7a7c5649a3254998e14b343dc6fdc9cb0..a8ae772a66e1033bea6ca6c1d32fb2d9740a153d 100644 (file)
@@ -1,3 +1,16 @@
+2008-07-05  Tom Tromey  <tromey@redhat.com>
+
+       * jcf-io.c: Don't include fnmatch.h.  Don't use JCF_USE_SCANDIR.
+       (compare_path): Remove.
+       (java_or_class_file): Likewise.
+       (memoized_dirlist_entry): Likewise.
+       (memoized_dirlist_hash): Likewise.
+       (memoized_dirlist_lookup_eq): Likewise.
+       (memoized_dirlists): Likewise.
+       (caching_stat): Likewise.
+       (find_class): Use stat.
+       * jcf.h (JCF_USE_SCANDIR): Remove.
+
 2008-06-30  Joshua Sumali  <jsumali@redhat.com>
 
        * Make-lang.in (JAVA_MANFILES): Add doc/aot-compile.1 and
index 52120971fa2b0afca82356e24409a5ffbca0e845..b968214e50904866a035462cd19eb8d0913e26e0 100644 (file)
@@ -34,10 +34,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "toplev.h"
 #include "java-tree.h"
 #include "hashtab.h"
-#if JCF_USE_SCANDIR
 #include <dirent.h>
-#include <fnmatch.h>
-#endif
 
 #include "zlib.h"
 
@@ -283,145 +280,6 @@ find_classfile (char *filename, JCF *jcf, const char *dep_name)
   return open_class (filename, jcf, fd, dep_name);
 }
 
-#if JCF_USE_SCANDIR
-
-/* A comparison function (as for qsort) that compares KEY (a char *
-   giving the basename of a file) with the name stored in ENTRY (a
-   dirent **).  */
-
-static int
-compare_path (const void *key, const void *entry)
-{
-  return strcmp ((const char *) key, 
-                (*((const struct dirent *const*) entry))->d_name);
-}
-
-/* Returns nonzero if ENTRY names a .java or .class file.  */
-
-static int
-java_or_class_file (const struct dirent *entry)
-{
-  const char *base = lbasename (entry->d_name);
-  return (fnmatch ("*.java", base, 0) == 0 || 
-         fnmatch ("*.class", base, 0) == 0);
-}
-
-/* Information about the files present in a particular directory.  */
-typedef struct memoized_dirlist_entry 
-{
-  /* The name of the directory.  */
-  const char *dir;
-  /* The number of .java and .class files present, or -1 if we could
-     not, for some reason, obtain the list.  */
-  int num_files;
-  /* The .java and .class files in the directory, in alphabetical
-     order.  */
-  struct dirent **files;
-} memoized_dirlist_entry;
-
-/* A hash function for a memoized_dirlist_entry.  */
-static hashval_t
-memoized_dirlist_hash (const void *entry)
-{
-  const memoized_dirlist_entry *mde = (const memoized_dirlist_entry *) entry;
-  return htab_hash_string (mde->dir);
-}
-
-/* Returns true if ENTRY (a memoized_dirlist_entry *) corresponds to
-   the directory given by KEY (a char *) giving the directory 
-   name.  */
-
-static int
-memoized_dirlist_lookup_eq (const void *entry, const void *key)
-{
-  return strcmp ((const char *) key,
-                ((const memoized_dirlist_entry *) entry)->dir) == 0;
-}
-
-/* A hash table mapping directory names to the lists of .java and
-   .class files in that directory.  */
-
-static htab_t memoized_dirlists;
-
-#endif
-
-/* Like stat, but avoids actually making the stat system call if we
-   know that it cannot succeed.  FILENAME and BUF are as for stat.  */
-
-static int
-caching_stat (char *filename, struct stat *buf)
-{
-#if JCF_USE_SCANDIR
-  char *sep;
-  char origsep = 0;
-  char *base;
-  memoized_dirlist_entry *dent;
-  void **slot;
-  struct memoized_dirlist_entry temp;
-  
-  /* If the hashtable has not already been created, create it now.  */
-  if (!memoized_dirlists)
-    memoized_dirlists = htab_create (37,
-                                    memoized_dirlist_hash,
-                                    memoized_dirlist_lookup_eq,
-                                    NULL);
-
-  /* Get the name of the directory.  */
-  sep = strrchr (filename, DIR_SEPARATOR);
-#ifdef DIR_SEPARATOR_2
-  if (! sep)
-    sep = strrchr (filename, DIR_SEPARATOR_2);
-#endif
-  if (sep)
-    {
-      origsep = *sep;
-      *sep = '\0';
-      base = sep + 1;
-    }
-  else
-    base = filename;
-
-  /* Obtain the entry for this directory from the hash table.  This
-     approach is ok since we know that the hash function only looks at
-     the directory name.  */
-  temp.dir = filename;
-  temp.num_files = 0;
-  temp.files = NULL;
-  slot = htab_find_slot (memoized_dirlists, &temp, INSERT);
-  if (!*slot)
-    {
-      /* We have not already scanned this directory; scan it now.  */
-      dent = XNEW (memoized_dirlist_entry);
-      dent->dir = xstrdup (filename);
-      /* Unfortunately, scandir is not fully standardized.  In
-        particular, the type of the function pointer passed as the
-        third argument sometimes takes a "const struct dirent *"
-        parameter, and sometimes just a "struct dirent *".  We cast
-        to (void *) and use __extension__ so that either way it is
-        quietly accepted.  FIXME: scandir is not in POSIX.  */
-      dent->num_files = __extension__ scandir (filename, &dent->files, 
-                                              (void *) java_or_class_file, 
-                                              alphasort);
-      *slot = dent;
-    }
-  else
-    dent = *((memoized_dirlist_entry **) slot);
-
-  /* Put the separator back.  */
-  if (sep)
-    *sep = origsep;
-
-  /* If the file is not in the list, there is no need to stat it; it
-     does not exist.  */
-  if (dent->num_files != -1
-      && !bsearch (base, dent->files, dent->num_files,
-                  sizeof (struct dirent *), compare_path))
-    return -1;
-#endif
-  
-  return stat (filename, buf);
-}
-
 /* Returns 1 if the CLASSNAME (really a char *) matches the name
    stored in TABLE_ENTRY (also a char *).  */
 
@@ -521,7 +379,7 @@ find_class (const char *classname, int classname_length, JCF *jcf)
              else
                continue;
            }
-         klass = caching_stat(buffer, &class_buf);
+         klass = stat (buffer, &class_buf);
        }
     }
 
index d4de2c57d542c61b0489b33255ec2ef76cc5ac34..40bbd725d45b36df4613b79349b3798a8791c8ed 100644 (file)
@@ -1,6 +1,6 @@
 /* Utility macros to read Java(TM) .class files and byte codes.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2006, 2007 Free Software Foundation, Inc.
+   2006, 2007, 2008 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -45,14 +45,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #define JCF_word JCF_u4
 #endif
 
-/* If we have both "scandir" and "alphasort", we can cache directory
-   listings to reduce the time taken to search the classpath.  */
-#if defined(HAVE_SCANDIR) && defined(HAVE_ALPHASORT)
-#define JCF_USE_SCANDIR 1
-#else
-#define JCF_USE_SCANDIR 0
-#endif 
-
 /* On case-insensitive file systems, we need to ensure that a request
    to open a .java or .class file is honored only if the file to be
    opened is of the exact case we are asking for. In other words, we