summaryrefslogtreecommitdiff
path: root/src/kmk/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kmk/dir.c')
-rw-r--r--src/kmk/dir.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/src/kmk/dir.c b/src/kmk/dir.c
index f55b2a5..fae0a7b 100644
--- a/src/kmk/dir.c
+++ b/src/kmk/dir.c
@@ -1,7 +1,7 @@
/* Directory hashing for GNU Make.
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-Foundation, Inc.
+1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+2010 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
@@ -23,7 +23,8 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
# ifdef VMS
-char *vmsify (char *name, int type);
+/* its prototype is in vmsdir.h, which is not needed for HAVE_DIRENT_H */
+const char *vmsify (const char *name, int type);
# endif
#else
# define dirent direct
@@ -131,14 +132,11 @@ downcase (const char *filename)
{
static PATH_VAR (new_filename);
char *df;
- int i;
if (filename == 0)
return 0;
df = new_filename;
-
- /* First, transform the name part. */
while (*filename != '\0')
{
*df++ = tolower ((unsigned char)*filename);
@@ -154,7 +152,7 @@ downcase (const char *filename)
#ifdef VMS
static int
-vms_hash (char *name)
+vms_hash (const char *name)
{
int h = 0;
int g;
@@ -180,7 +178,7 @@ vms_hash (char *name)
/* fake stat entry for a directory */
static int
-vmsstat_dir (char *name, struct stat *st)
+vmsstat_dir (const char *name, struct stat *st)
{
char *s;
int h;
@@ -193,6 +191,7 @@ vmsstat_dir (char *name, struct stat *st)
s = strchr (name, ':'); /* find device */
if (s)
{
+ /* to keep the compiler happy we said "const char *name", now we cheat */
*s++ = 0;
st->st_dev = (char *)vms_hash (name);
h = vms_hash (s);
@@ -201,8 +200,7 @@ vmsstat_dir (char *name, struct stat *st)
else
{
st->st_dev = 0;
- s = name;
- h = vms_hash (s);
+ h = vms_hash (name);
}
st->st_ino[0] = h & 0xff;
@@ -492,7 +490,11 @@ find_directory (const char *name)
dir_slot = (struct directory **) hash_find_slot (&directories, &dir_key);
#else
p = name + strlen (name);
+# if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
+ dir_key.name = strcache_add_len (downcase(name), p - name);
+# else
dir_key.name = strcache_add_len (name, p - name);
+# endif
dir_slot = (struct directory **) hash_find_slot_strcached (&directories, &dir_key);
#endif
dir = *dir_slot;
@@ -512,10 +514,14 @@ find_directory (const char *name)
dir = alloccache_alloc (&directories_cache);
#endif
#ifndef CONFIG_WITH_STRCACHE2
- dir->name = strcache_add_len (name, p - name);
+#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
+ dir->name = strcache_add_len (downcase(name), p - name);
#else
- dir->name = dir_key.name;
+ dir->name = strcache_add_len (name, p - name);
#endif
+#else /* CONFIG_WITH_STRCACHE2 */
+ dir->name = dir_key.name;
+#endif /* CONFIG_WITH_STRCACHE2 */
hash_insert_at (&directories, dir, dir_slot);
/* The directory is not in the name hash table.
Find its device and inode numbers, and look it up by them. */
@@ -821,7 +827,11 @@ dir_contents_file_exists_p (struct directory_contents *dir,
dirfile_key.length = len;
dirfile_slot = (struct dirfile **) hash_find_slot (&dir->dirfiles, &dirfile_key);
#else
+# if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
+ dirfile_key.name = strcache_add_len (downcase(d->d_name), len);
+# else
dirfile_key.name = strcache_add_len (d->d_name, len);
+# endif
dirfile_key.length = len;
dirfile_slot = (struct dirfile **) hash_find_slot_strcached (&dir->dirfiles, &dirfile_key);
#endif
@@ -839,17 +849,21 @@ dir_contents_file_exists_p (struct directory_contents *dir,
df = alloccache_alloc (&dirfile_cache);
#endif
#ifndef CONFIG_WITH_STRCACHE2
- df->name = strcache_add_len (d->d_name, len);
+#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
+ df->name = strcache_add_len (downcase(d->d_name), len);
#else
- df->name = dirfile_key.name;
+ df->name = strcache_add_len (d->d_name, len);
#endif
+#else /* CONFIG_WITH_STRCACHE2 */
+ df->name = dirfile_key.name;
+#endif /* CONFIG_WITH_STRCACHE2 */
df->length = len;
df->impossible = 0;
hash_insert_at (&dir->dirfiles, df, dirfile_slot);
}
/* Check if the name matches the one we're searching for. */
#ifndef CONFIG_WITH_STRCACHE2
- if (filename != 0 && strieq (d->d_name, filename))
+ if (filename != 0 && patheq (d->d_name, filename))
#else
if (filename != 0 && dirfile_key.name == filename)
#endif
@@ -1003,16 +1017,13 @@ file_impossible (const char *filename)
}
if (dir->contents == 0)
- {
- /* The directory could not be stat'd. We allocate a contents
- structure for it, but leave it out of the contents hash table. */
+ /* The directory could not be stat'd. We allocate a contents
+ structure for it, but leave it out of the contents hash table. */
#ifndef CONFIG_WITH_ALLOC_CACHES
- dir->contents = xmalloc (sizeof (struct directory_contents));
+ dir->contents = xcalloc (sizeof (struct directory_contents));
#else
- dir->contents = alloccache_alloc (&directory_contents_cache);
+ dir->contents = alloccache_calloc (&directory_contents_cache);
#endif
- memset (dir->contents, '\0', sizeof (struct directory_contents));
- }
if (dir->contents->dirfiles.ht_vec == 0)
{
@@ -1033,7 +1044,11 @@ file_impossible (const char *filename)
new = alloccache_alloc (&dirfile_cache);
#endif
new->length = strlen (filename);
+#if defined(HAVE_CASE_INSENSITIVE_FS) && defined(VMS)
+ new->name = strcache_add_len (downcase(filename), new->length);
+#else
new->name = strcache_add_len (filename, new->length);
+#endif
new->impossible = 1;
#ifndef CONFIG_WITH_STRCACHE2
hash_insert (&dir->contents->dirfiles, new);