diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | dir.c | 11 | ||||
-rw-r--r-- | file.c | 3 | ||||
-rw-r--r-- | job.c | 3 | ||||
-rw-r--r-- | make.h | 20 |
5 files changed, 25 insertions, 21 deletions
@@ -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> @@ -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) { @@ -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; @@ -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; @@ -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) |