diff options
author | Paul Smith <psmith@gnu.org> | 1999-03-05 07:13:12 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 1999-03-05 07:13:12 +0000 |
commit | a6a9ebb54f67cb13a07dd3b815c258ae8c35b3ac (patch) | |
tree | cb34f435ff0d7400690485733f42e2335d4d163f | |
parent | 9e6ba6a148aa6e4a6aed496d91bac44323325445 (diff) | |
download | gunmake-a6a9ebb54f67cb13a07dd3b815c258ae8c35b3ac.tar.gz |
* Define and use xstrdup() instead of strdup().
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | dir.c | 2 | ||||
-rw-r--r-- | job.c | 4 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | make.h | 1 | ||||
-rw-r--r-- | misc.c | 23 | ||||
-rw-r--r-- | remake.c | 6 | ||||
-rw-r--r-- | rule.c | 2 |
9 files changed, 50 insertions, 12 deletions
@@ -1,5 +1,15 @@ 1999-03-05 Paul D. Smith <psmith@gnu.org> + * configure.in: Check for a system strdup(). + * misc.c (xstrdup): Created. Suggestion by Han-Wen Nienhuys + <hanwen@cs.uu.nl>. + * make.h: Prototype xstrdup(). + * remake.c (library_search): Use it. + * main.c (main): Use it. + (find_and_set_default_shell): Use it. + * job.c (construct_command_argv_internal): Use it. + * dir.c (find_directory): Use it. + * Makefile.am, configure.in: Use AC_SUBST_FILE to insert the maintMakefile instead of "include", to avoid automake 1.4 incompatibility. @@ -83,6 +93,10 @@ * read.c (record_files): Clean up some indentation. +1998-11-08 Han-Wen Nienhuys <hanwen@cs.uu.nl> + + * rule.c (print_rule_data_base): Fix arguments to fatal() call. + 1998-10-13 Paul D. Smith <psmith@gnu.org> * job.c (new_job): If the command list resolves to empty (through diff --git a/configure.in b/configure.in index 87d8062..651387e 100644 --- a/configure.in +++ b/configure.in @@ -55,7 +55,7 @@ AC_MSG_RESULT($ac_cv_check_symbol_$1)])dnl # clock_gettime is in -lposix4 in Solaris 2.6. AC_CHECK_LIB(posix4, clock_gettime) -AC_CHECK_FUNCS(memmove psignal mktemp pstat_getdynamic \ +AC_CHECK_FUNCS(memmove strdup psignal mktemp pstat_getdynamic \ clock_gettime dup2 getcwd sigsetmask getgroups setlinebuf \ seteuid setegid setreuid setregid strerror strsignal) AC_CHECK_SYMBOL(sys_siglist) @@ -385,7 +385,7 @@ find_directory (name) /* Enter it in the contents hash table. */ dc->dev = st.st_dev; #ifdef WINDOWS32 - dc->path_key = strdup(w32_path); + dc->path_key = xstrdup(w32_path); dc->mtime = st.st_mtime; /* @@ -2291,10 +2291,10 @@ construct_command_argv_internal (line, restp, shell, ifs, batch_filename_ptr) /* create argv */ new_argv = (char **) xmalloc(3 * sizeof(char *)); if (unixy_shell) { - new_argv[0] = strdup (shell); + new_argv[0] = xstrdup (shell); new_argv[1] = *batch_filename_ptr; /* only argv[0] gets freed later */ } else { - new_argv[0] = strdup (*batch_filename_ptr); + new_argv[0] = xstrdup (*batch_filename_ptr); new_argv[1] = NULL; } new_argv[2] = NULL; @@ -568,7 +568,7 @@ find_and_set_default_shell(char *token) } else if (file_exists_p(search_token)) { /* search token path was found */ sprintf(sh_path, "%s", search_token); - default_shell = strdup(w32ify(sh_path,0)); + default_shell = xstrdup(w32ify(sh_path,0)); if (debug_flag) printf("find_and_set_shell setting default_shell = %s\n", default_shell); sh_found = 1; @@ -590,7 +590,7 @@ find_and_set_default_shell(char *token) if (dir_file_exists_p(p, search_token)) { sprintf(sh_path, "%s/%s", p, search_token); - default_shell = strdup(w32ify(sh_path,0)); + default_shell = xstrdup(w32ify(sh_path,0)); sh_found = 1; *ep = PATH_SEPARATOR_CHAR; @@ -607,7 +607,7 @@ find_and_set_default_shell(char *token) /* be sure to check last element of Path */ if (p && *p && dir_file_exists_p(p, search_token)) { sprintf(sh_path, "%s/%s", p, search_token); - default_shell = strdup(w32ify(sh_path,0)); + default_shell = xstrdup(w32ify(sh_path,0)); sh_found = 1; } @@ -941,7 +941,7 @@ int main (int argc, char ** argv) if (strpbrk(argv[0], "/:\\") || strstr(argv[0], "..") || !strncmp(argv[0], "//", 2)) - argv[0] = strdup(w32ify(argv[0],1)); + argv[0] = xstrdup(w32ify(argv[0],1)); #else /* WINDOWS32 */ if (current_directory[0] != '\0' && argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0) @@ -374,6 +374,7 @@ extern char *savestring PARAMS ((char *, unsigned int)); extern char *concat PARAMS ((char *, char *, char *)); extern char *xmalloc PARAMS ((unsigned int)); extern char *xrealloc PARAMS ((char *, unsigned int)); +extern char *xstrdup PARAMS ((const char *)); extern char *find_next_token PARAMS ((char **, unsigned int *)); extern char *next_token PARAMS ((char *)); extern char *end_of_token PARAMS ((char *)); @@ -378,6 +378,29 @@ xrealloc (ptr, size) return result; } + +const char * +xstrdup (ptr) + const char *ptr; +{ + char *result; + +#ifdef HAVE_STRDUP + result = strdup (ptr); +#else + result = (char *) malloc (strlen (ptr) + 1); +#endif + + if (result == 0) + fatal (NILF, "virtual memory exhausted"); + +#ifdef HAVE_STRDUP + return result; +#else + return strcpy(result, ptr); +#endif +} + char * savestring (str, length) char *str; @@ -1208,7 +1208,7 @@ library_search (lib, mtime_ptr) int save = warn_undefined_variables_flag; warn_undefined_variables_flag = 0; - libpatterns = strdup (variable_expand ("$(strip $(.LIBPATTERNS))")); + libpatterns = xstrdup (variable_expand ("$(strip $(.LIBPATTERNS))")); warn_undefined_variables_flag = save; } @@ -1249,7 +1249,7 @@ library_search (lib, mtime_ptr) mtime = name_mtime (libbuf); if (mtime != (FILE_TIMESTAMP) -1) { - *lib = strdup (libbuf); + *lib = xstrdup (libbuf); if (mtime_ptr != 0) *mtime_ptr = mtime; return 1; @@ -1289,7 +1289,7 @@ library_search (lib, mtime_ptr) mtime = name_mtime (buf); if (mtime != (FILE_TIMESTAMP) -1) { - *lib = strdup (buf); + *lib = xstrdup (buf); if (mtime_ptr != 0) *mtime_ptr = mtime; return 1; @@ -669,7 +669,7 @@ print_rule_data_base () /* This can happen if a fatal error was detected while reading the makefiles and thus count_implicit_rule_limits wasn't called yet. */ if (num_pattern_rules != 0) - fatal ("BUG: num_pattern_rules wrong! %u != %u", + fatal (NILF, "BUG: num_pattern_rules wrong! %u != %u", num_pattern_rules, rules); } |