summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1993-06-02 20:56:37 +0000
committerRoland McGrath <roland@redhat.com>1993-06-02 20:56:37 +0000
commit9697738544405d409dede9e2dcce595a854e99be (patch)
tree8ecf148af0fcb3fb7ea4af421d7dbfd21a4b0bb8 /dir.c
parent4a9fdcd65f6a0b8fc0e3f646e4a5bb8de65ee3e3 (diff)
downloadgunmake-9697738544405d409dede9e2dcce595a854e99be.tar.gz
entered into RCS
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 8c27c51..1e1bcf1 100644
--- a/dir.c
+++ b/dir.c
@@ -242,19 +242,24 @@ dir_contents_file_exists_p (dir, filename)
{
/* Enter the file in the hash table. */
register unsigned int newhash = 0;
+ unsigned int len;
register unsigned int i;
if (!REAL_DIR_ENTRY (d))
continue;
- for (i = 0; i < D_NAMLEN(d); ++i)
+ len = D_NAMLEN (d);
+ while (d->d_name[len - 1] == '\0')
+ --len;
+
+ for (i = 0; i < len; ++i)
HASH (newhash, d->d_name[i]);
newhash %= DIRFILE_BUCKETS;
df = (struct dirfile *) xmalloc (sizeof (struct dirfile));
df->next = dir->files[newhash];
dir->files[newhash] = df;
- df->name = savestring (d->d_name, D_NAMLEN(d));
+ df->name = savestring (d->d_name, len);
df->impossible = 0;
/* Check if the name matches the one we're searching for. */