mirror of
https://salsa.debian.org/srivasta/make-dfsg.git
synced 2024-12-26 14:00:56 +00:00
- Memory cleanups, found with valgrind.
- Fix handling of special targets like .SUFFIX for VMS insensitive targets. - Don't make temporary batch files for -n. Make sure batch files are created in text mode.
This commit is contained in:
parent
bde826b18a
commit
6e0527913c
6 changed files with 71 additions and 47 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2006-02-19 Paul D. Smith <psmith@gnu.org>
|
||||
|
||||
* commands.c (set_file_variables): Realloc, not malloc, the static
|
||||
string values to avoid memory leaks.
|
||||
|
||||
* expand.c (recursively_expand_for_file): Only set reading_file to
|
||||
an initialized value.
|
||||
|
||||
* implicit.c (pattern_search): We need to make a copy of the stem
|
||||
if we get it from an intermediate dep, since those get freed.
|
||||
|
||||
* file.c (lookup_file) [VMS]: Don't lowercase special targets that
|
||||
begin with ".".
|
||||
(enter_file) [VMS]: Ditto.
|
||||
Patch provided by Hartmut Becker <Hartmut.Becker@hp.com>.
|
||||
|
||||
2006-02-18 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* job.c (construct_command_argv_internal): Don't create a temporary
|
||||
script/batch file if we are under -n. Call _setmode to switch the
|
||||
script file stream to text mode.
|
||||
|
||||
2006-02-17 Paul D. Smith <psmith@gnu.org>
|
||||
|
||||
* variable.c (merge_variable_set_lists): Don't try to merge the
|
||||
|
|
|
@ -157,7 +157,7 @@ set_file_variables (struct file *file)
|
|||
plus_len++;
|
||||
|
||||
if (plus_len > plus_max)
|
||||
plus_value = (char *) xmalloc (plus_max = plus_len);
|
||||
plus_value = xrealloc (plus_value, plus_max = plus_len);
|
||||
cp = plus_value;
|
||||
|
||||
qmark_len = plus_len + 1; /* Will be this or less. */
|
||||
|
@ -206,11 +206,11 @@ set_file_variables (struct file *file)
|
|||
cp = caret_value = plus_value; /* Reuse the buffer; it's big enough. */
|
||||
|
||||
if (qmark_len > qmark_max)
|
||||
qmark_value = (char *) xmalloc (qmark_max = qmark_len);
|
||||
qmark_value = xrealloc (qmark_value, qmark_max = qmark_len);
|
||||
qp = qmark_value;
|
||||
|
||||
if (bar_len > bar_max)
|
||||
bar_value = (char *) xmalloc (bar_max = bar_len);
|
||||
bar_value = xrealloc (bar_value, bar_max = bar_len);
|
||||
bp = bar_value;
|
||||
|
||||
for (d = file->deps; d != 0; d = d->next)
|
||||
|
|
16
expand.c
16
expand.c
|
@ -113,11 +113,18 @@ recursively_expand_for_file (struct variable *v, struct file *file)
|
|||
expanding_var = &this_var;
|
||||
}
|
||||
|
||||
/* If we have no other file-reading context, use the variable's context. */
|
||||
if (!reading_file)
|
||||
{
|
||||
set_reading = 1;
|
||||
reading_file = &v->fileinfo;
|
||||
}
|
||||
|
||||
if (v->expanding)
|
||||
{
|
||||
if (!v->exp_count)
|
||||
/* Expanding V causes infinite recursion. Lose. */
|
||||
fatal (this_var,
|
||||
fatal (*expanding_var,
|
||||
_("Recursive variable `%s' references itself (eventually)"),
|
||||
v->name);
|
||||
--v->exp_count;
|
||||
|
@ -129,13 +136,6 @@ recursively_expand_for_file (struct variable *v, struct file *file)
|
|||
current_variable_set_list = file->variables;
|
||||
}
|
||||
|
||||
/* If we have no other file-reading context, use the variable's context. */
|
||||
if (!reading_file)
|
||||
{
|
||||
set_reading = 1;
|
||||
reading_file = this_var;
|
||||
}
|
||||
|
||||
v->expanding = 1;
|
||||
if (v->append)
|
||||
value = allocated_variable_append (v);
|
||||
|
|
54
file.c
54
file.c
|
@ -88,14 +88,15 @@ lookup_file (char *name)
|
|||
on the command line. */
|
||||
#ifdef VMS
|
||||
# ifndef WANT_CASE_SENSITIVE_TARGETS
|
||||
{
|
||||
register char *n;
|
||||
lname = (char *) malloc (strlen (name) + 1);
|
||||
for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
|
||||
*ln = isupper ((unsigned char)*n) ? tolower ((unsigned char)*n) : *n;
|
||||
*ln = '\0';
|
||||
name = lname;
|
||||
}
|
||||
if (*name != '.')
|
||||
{
|
||||
register char *n;
|
||||
lname = (char *) malloc (strlen (name) + 1);
|
||||
for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
|
||||
*ln = isupper ((unsigned char)*n) ? tolower ((unsigned char)*n) : *n;
|
||||
*ln = '\0';
|
||||
name = lname;
|
||||
}
|
||||
# endif
|
||||
|
||||
while (name[0] == '[' && name[1] == ']' && name[2] != '\0')
|
||||
|
@ -124,7 +125,8 @@ lookup_file (char *name)
|
|||
file_key.hname = name;
|
||||
f = (struct file *) hash_find_item (&files, &file_key);
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
free (lname);
|
||||
if (*name != '.')
|
||||
free (lname);
|
||||
#endif
|
||||
return f;
|
||||
}
|
||||
|
@ -143,22 +145,23 @@ enter_file (char *name)
|
|||
assert (*name != '\0');
|
||||
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
{
|
||||
register char *n;
|
||||
lname = (char *) malloc (strlen (name) + 1);
|
||||
for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
|
||||
{
|
||||
if (isupper ((unsigned char)*n))
|
||||
*ln = tolower ((unsigned char)*n);
|
||||
else
|
||||
*ln = *n;
|
||||
}
|
||||
if (*name != '.')
|
||||
{
|
||||
register char *n;
|
||||
lname = (char *) malloc (strlen (name) + 1);
|
||||
for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
|
||||
{
|
||||
if (isupper ((unsigned char)*n))
|
||||
*ln = tolower ((unsigned char)*n);
|
||||
else
|
||||
*ln = *n;
|
||||
}
|
||||
|
||||
*ln = 0;
|
||||
/* Creates a possible leak, old value of name is unreachable, but I
|
||||
currently don't know how to fix it. */
|
||||
name = lname;
|
||||
}
|
||||
*ln = 0;
|
||||
/* Creates a possible leak, old value of name is unreachable, but I
|
||||
currently don't know how to fix it. */
|
||||
name = lname;
|
||||
}
|
||||
#endif
|
||||
|
||||
file_key.hname = name;
|
||||
|
@ -167,7 +170,8 @@ enter_file (char *name)
|
|||
if (! HASH_VACANT (f) && !f->double_colon)
|
||||
{
|
||||
#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
|
||||
free(lname);
|
||||
if (*name != '.')
|
||||
free (lname);
|
||||
#endif
|
||||
return f;
|
||||
}
|
||||
|
|
13
implicit.c
13
implicit.c
|
@ -90,14 +90,9 @@ free_idep_chain (struct idep *p)
|
|||
free (p->name);
|
||||
|
||||
f = p->intermediate_file;
|
||||
if (f != 0)
|
||||
{
|
||||
/* if (f->variables)
|
||||
free_variable_set (f->variables); */
|
||||
if (f->stem < f->name
|
||||
|| f->stem > f->name + strlen (f->name))
|
||||
free (f->stem);
|
||||
}
|
||||
if (f != 0
|
||||
&& (f->stem < f->name || f->stem > f->name + strlen (f->name)))
|
||||
free (f->stem);
|
||||
|
||||
free (p);
|
||||
}
|
||||
|
@ -841,7 +836,7 @@ pattern_search (struct file *file, int archive,
|
|||
|
||||
f->deps = imf->deps;
|
||||
f->cmds = imf->cmds;
|
||||
f->stem = imf->stem;
|
||||
f->stem = xstrdup (imf->stem);
|
||||
f->also_make = imf->also_make;
|
||||
f->is_target = 1;
|
||||
|
||||
|
|
7
job.c
7
job.c
|
@ -2770,6 +2770,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
|
|||
/* Some shells do not work well when invoked as 'sh -c xxx' to run a
|
||||
command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems). In these
|
||||
cases, run commands via a script file. */
|
||||
if (just_print_flag)
|
||||
; /* Do nothing here. */
|
||||
if ((no_default_sh_exe || batch_mode_shell) && batch_filename_ptr) {
|
||||
int temp_fd;
|
||||
FILE* batch = NULL;
|
||||
|
@ -2784,8 +2786,9 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
|
|||
*batch_filename_ptr));
|
||||
|
||||
/* Create a FILE object for the batch file, and write to it the
|
||||
commands to be executed. */
|
||||
batch = _fdopen (temp_fd, "w");
|
||||
commands to be executed. Put the batch file in TEXT mode. */
|
||||
_setmode (temp_fd, _O_TEXT);
|
||||
batch = _fdopen (temp_fd, "wt");
|
||||
if (!unixy_shell)
|
||||
fputs ("@echo off\n", batch);
|
||||
fputs (command_ptr, batch);
|
||||
|
|
Loading…
Reference in a new issue