summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--dir.c11
-rw-r--r--file.c3
-rw-r--r--job.c3
-rw-r--r--make.h20
5 files changed, 25 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 5391e16..58eb673 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-01-10 Paul Smith <psmith@gnu.org>
+
+ * make.h (patheq): Rename strieq() to patheq() for clarity.
+ * dir.c (dir_contents_file_exists_p): Use it.
+
+ * dir.c (file_impossible): Convert xmalloc/memset to xcalloc.
+ * file.c (enter_file): Ditto.
+ * job.c (new_job): Ditto.
+
2009-12-11 Eli Zaretskii <eliz@gnu.org>
* job.c (construct_command_argv_internal) <sh_cmds_dos>
diff --git a/dir.c b/dir.c
index e127fc1..4224abb 100644
--- a/dir.c
+++ b/dir.c
@@ -721,7 +721,7 @@ dir_contents_file_exists_p (struct directory_contents *dir,
hash_insert_at (&dir->dirfiles, df, dirfile_slot);
}
/* Check if the name matches the one we're searching for. */
- if (filename != 0 && strieq (d->d_name, filename))
+ if (filename != 0 && patheq (d->d_name, filename))
return 1;
}
@@ -872,12 +872,9 @@ 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. */
- dir->contents = xmalloc (sizeof (struct directory_contents));
- memset (dir->contents, '\0', sizeof (struct directory_contents));
- }
+ /* The directory could not be stat'd. We allocate a contents
+ structure for it, but leave it out of the contents hash table. */
+ dir->contents = xcalloc (sizeof (struct directory_contents));
if (dir->contents->dirfiles.ht_vec == 0)
{
diff --git a/file.c b/file.c
index d068b34..c3f7678 100644
--- a/file.c
+++ b/file.c
@@ -181,8 +181,7 @@ enter_file (const char *name)
if (! HASH_VACANT (f) && !f->double_colon)
return f;
- new = xmalloc (sizeof (struct file));
- memset (new, '\0', sizeof (struct file));
+ new = xcalloc (sizeof (struct file));
new->name = new->hname = name;
new->update_status = -1;
diff --git a/job.c b/job.c
index 1db7217..edbf569 100644
--- a/job.c
+++ b/job.c
@@ -1611,8 +1611,7 @@ new_job (struct file *file)
/* Start the command sequence, record it in a new
`struct child', and add that to the chain. */
- c = xmalloc (sizeof (struct child));
- memset (c, '\0', sizeof (struct child));
+ c = xcalloc (sizeof (struct child));
c->file = file;
c->command_lines = lines;
c->sh_batch_file = NULL;
diff --git a/make.h b/make.h
index 2841c7f..65faadc 100644
--- a/make.h
+++ b/make.h
@@ -264,23 +264,23 @@ char *strsignal (int signum);
host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
-#ifndef iAPX286
-# define streq(a, b) \
+/* Test if two strings are equal. Is this worthwhile? Should be profiled. */
+#define streq(a, b) \
((a) == (b) || \
(*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
-# ifdef HAVE_CASE_INSENSITIVE_FS
-# define strieq(a, b) \
+
+/* Test if two strings are equal, but match case-insensitively on systems
+ which have case-insensitive filesystems. Should only be used for
+ filenames! */
+#ifdef HAVE_CASE_INSENSITIVE_FS
+# define patheq(a, b) \
((a) == (b) \
|| (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
&& (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
-# else
-# define strieq(a, b) streq(a, b)
-# endif
#else
-/* Buggy compiler can't handle this. */
-# define streq(a, b) (strcmp ((a), (b)) == 0)
-# define strieq(a, b) (strcmp ((a), (b)) == 0)
+# define patheq(a, b) streq(a, b)
#endif
+
#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
#if defined(__GNUC__) || defined(ENUM_BITFIELDS)