mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-27 23:06:53 +00:00
* Define and use xstrdup() instead of strdup().
This commit is contained in:
parent
9e6ba6a148
commit
a6a9ebb54f
9 changed files with 50 additions and 12 deletions
14
ChangeLog
14
ChangeLog
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
2
dir.c
2
dir.c
|
@ -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;
|
||||
|
||||
/*
|
||||
|
|
4
job.c
4
job.c
|
@ -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;
|
||||
|
|
8
main.c
8
main.c
|
@ -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)
|
||||
|
|
1
make.h
1
make.h
|
@ -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 *));
|
||||
|
|
23
misc.c
23
misc.c
|
@ -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;
|
||||
|
|
6
remake.c
6
remake.c
|
@ -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;
|
||||
|
|
2
rule.c
2
rule.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue