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.
* 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
# 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)
/* 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;
/*
/* 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;
} 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;
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;
/* 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;
}
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)
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 *));
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;
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;
}
mtime = name_mtime (libbuf);
if (mtime != (FILE_TIMESTAMP) -1)
{
- *lib = strdup (libbuf);
+ *lib = xstrdup (libbuf);
if (mtime_ptr != 0)
*mtime_ptr = mtime;
return 1;
mtime = name_mtime (buf);
if (mtime != (FILE_TIMESTAMP) -1)
{
- *lib = strdup (buf);
+ *lib = xstrdup (buf);
if (mtime_ptr != 0)
*mtime_ptr = mtime;
return 1;
/* 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);
}