mirror of
https://github.com/mirror/make.git
synced 2025-01-27 21:00:22 +08:00
Fix PR/1831. See the ChangeLog.
This commit is contained in:
parent
1a82956eae
commit
8ddf04c627
@ -1,3 +1,12 @@
|
|||||||
|
2000-08-21 Paul D. Smith <paul@paulandlesley.org>
|
||||||
|
|
||||||
|
* variable.c (try_variable_definition): Change how we handle
|
||||||
|
target-specific append variable defns: instead of just setting the
|
||||||
|
value, expand it as an append _but_ only within the current
|
||||||
|
target's context. Otherwise we lose all but the last value if the
|
||||||
|
variable is appended more than once within the current target
|
||||||
|
context. Fixes PR/1831.
|
||||||
|
|
||||||
2000-07-25 Paul D. Smith <psmith@gnu.org>
|
2000-07-25 Paul D. Smith <psmith@gnu.org>
|
||||||
|
|
||||||
* job.c (construct_command_argv_internal): Add "~" to the list of
|
* job.c (construct_command_argv_internal): Add "~" to the list of
|
||||||
|
@ -126,6 +126,7 @@ $answer = "foo bar\n";
|
|||||||
|
|
||||||
# TEST #9
|
# TEST #9
|
||||||
# For PR/1380: Using += assignment in target-specific variables sometimes fails
|
# For PR/1380: Using += assignment in target-specific variables sometimes fails
|
||||||
|
# Also PR/1831
|
||||||
|
|
||||||
$makefile3 = &get_tmpfile;
|
$makefile3 = &get_tmpfile;
|
||||||
|
|
||||||
@ -138,18 +139,19 @@ all: one; @echo $(FOO)
|
|||||||
FOO = bar
|
FOO = bar
|
||||||
|
|
||||||
one: FOO += biz
|
one: FOO += biz
|
||||||
|
one: FOO += boz
|
||||||
one: ; @echo $(FOO)
|
one: ; @echo $(FOO)
|
||||||
EOF
|
EOF
|
||||||
close(MAKEFILE);
|
close(MAKEFILE);
|
||||||
|
|
||||||
&run_make_with_options("$makefile3", "", &get_logfile);
|
&run_make_with_options("$makefile3", "", &get_logfile);
|
||||||
$answer = "bar baz biz\nbar baz\n";
|
$answer = "bar baz biz boz\nbar baz\n";
|
||||||
&compare_output($answer, &get_logfile(1));
|
&compare_output($answer, &get_logfile(1));
|
||||||
|
|
||||||
# Test #10
|
# Test #10
|
||||||
|
|
||||||
&run_make_with_options("$makefile3", "one", &get_logfile);
|
&run_make_with_options("$makefile3", "one", &get_logfile);
|
||||||
$answer = "bar biz\n";
|
$answer = "bar biz boz\n";
|
||||||
&compare_output($answer, &get_logfile(1));
|
&compare_output($answer, &get_logfile(1));
|
||||||
|
|
||||||
# Test #11
|
# Test #11
|
||||||
|
105
variable.c
105
variable.c
@ -900,51 +900,56 @@ try_variable_definition (flocp, line, origin, target_var)
|
|||||||
value = p;
|
value = p;
|
||||||
break;
|
break;
|
||||||
case f_append:
|
case f_append:
|
||||||
/* If we have += but we're in a target variable context, defer the
|
{
|
||||||
append until the context expansion. */
|
struct variable_set_list *saved_next = current_variable_set_list->next;
|
||||||
if (target_var)
|
|
||||||
{
|
|
||||||
append = 1;
|
|
||||||
flavor = f_recursive;
|
|
||||||
value = p;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* An appending variable definition "var += value".
|
/* If we have += but we're in a target variable context, we want to
|
||||||
Extract the old value and append the new one. */
|
append only with other variables in the context of this target. */
|
||||||
v = lookup_variable (expanded_name, strlen (expanded_name));
|
if (target_var)
|
||||||
if (v == 0)
|
{
|
||||||
{
|
append = 1;
|
||||||
/* There was no old value.
|
current_variable_set_list->next = 0;
|
||||||
This becomes a normal recursive definition. */
|
}
|
||||||
value = p;
|
|
||||||
flavor = f_recursive;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Paste the old and new values together in VALUE. */
|
|
||||||
|
|
||||||
unsigned int oldlen, newlen;
|
/* An appending variable definition "var += value".
|
||||||
|
Extract the old value and append the new one. */
|
||||||
|
v = lookup_variable (expanded_name, strlen (expanded_name));
|
||||||
|
|
||||||
if (v->recursive)
|
current_variable_set_list->next = saved_next;
|
||||||
/* The previous definition of the variable was recursive.
|
|
||||||
The new value comes from the unexpanded old and new values. */
|
|
||||||
flavor = f_recursive;
|
|
||||||
else
|
|
||||||
/* The previous definition of the variable was simple.
|
|
||||||
The new value comes from the old value, which was expanded
|
|
||||||
when it was set; and from the expanded new value. Allocate
|
|
||||||
memory for the expansion as we may still need the rest of the
|
|
||||||
buffer if we're looking at a target-specific variable. */
|
|
||||||
p = alloc_value = allocated_variable_expand (p);
|
|
||||||
|
|
||||||
oldlen = strlen (v->value);
|
if (v == 0)
|
||||||
newlen = strlen (p);
|
{
|
||||||
value = (char *) alloca (oldlen + 1 + newlen + 1);
|
/* There was no old value.
|
||||||
bcopy (v->value, value, oldlen);
|
This becomes a normal recursive definition. */
|
||||||
value[oldlen] = ' ';
|
value = p;
|
||||||
bcopy (p, &value[oldlen + 1], newlen + 1);
|
flavor = f_recursive;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Paste the old and new values together in VALUE. */
|
||||||
|
|
||||||
|
unsigned int oldlen, newlen;
|
||||||
|
|
||||||
|
if (v->recursive)
|
||||||
|
/* The previous definition of the variable was recursive.
|
||||||
|
The new value is the unexpanded old and new values. */
|
||||||
|
flavor = f_recursive;
|
||||||
|
else
|
||||||
|
/* The previous definition of the variable was simple.
|
||||||
|
The new value comes from the old value, which was expanded
|
||||||
|
when it was set; and from the expanded new value. Allocate
|
||||||
|
memory for the expansion as we may still need the rest of the
|
||||||
|
buffer if we're looking at a target-specific variable. */
|
||||||
|
p = alloc_value = allocated_variable_expand (p);
|
||||||
|
|
||||||
|
oldlen = strlen (v->value);
|
||||||
|
newlen = strlen (p);
|
||||||
|
value = (char *) alloca (oldlen + 1 + newlen + 1);
|
||||||
|
bcopy (v->value, value, oldlen);
|
||||||
|
value[oldlen] = ' ';
|
||||||
|
bcopy (p, &value[oldlen + 1], newlen + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __MSDOS__
|
#ifdef __MSDOS__
|
||||||
@ -1032,21 +1037,23 @@ try_variable_definition (flocp, line, origin, target_var)
|
|||||||
#endif /* __MSDOS__ */
|
#endif /* __MSDOS__ */
|
||||||
#ifdef WINDOWS32
|
#ifdef WINDOWS32
|
||||||
if ((origin == o_file || origin == o_override)
|
if ((origin == o_file || origin == o_override)
|
||||||
&& strcmp (expanded_name, "SHELL") == 0) {
|
&& strcmp (expanded_name, "SHELL") == 0)
|
||||||
extern char* default_shell;
|
{
|
||||||
|
extern char* default_shell;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call shell locator function. If it returns TRUE, then
|
* Call shell locator function. If it returns TRUE, then
|
||||||
* set no_default_sh_exe to indicate sh was found and
|
* set no_default_sh_exe to indicate sh was found and
|
||||||
* set new value for SHELL variable.
|
* set new value for SHELL variable.
|
||||||
*/
|
*/
|
||||||
if (find_and_set_default_shell(value)) {
|
if (find_and_set_default_shell(value)) {
|
||||||
v = define_variable_loc (expanded_name, strlen (expanded_name),
|
v = define_variable_loc (expanded_name, strlen (expanded_name),
|
||||||
default_shell, origin, flavor == f_recursive,
|
default_shell, origin, flavor == f_recursive,
|
||||||
flocp);
|
flocp);
|
||||||
no_default_sh_exe = 0;
|
no_default_sh_exe = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
v = define_variable_loc (expanded_name, strlen (expanded_name), value,
|
v = define_variable_loc (expanded_name, strlen (expanded_name), value,
|
||||||
|
Loading…
Reference in New Issue
Block a user