This was claimed to be fixed in 3.81, but wasn't, for some reason.
To detect this change search for 'nocomment' in the .FEATURES variable.
+* WARNING: Backward-incompatibility!
+ Previously appending using '+=' to an empty variable would result in a value
+ starting with a space. Now the initial space is only added if the variable
+ already contains some value. Similarly, appending an empty string does not
+ add a trailing space.
+
* The previous limit of 63 jobs under -jN on MS-Windows is now
increased to 4095. That limit includes the subprocess started by
the $(shell) function.
@noindent
This takes the value of the variable @code{objects}, and adds the text
-@samp{another.o} to it (preceded by a single space). Thus:
+@samp{another.o} to it (preceded by a single space, if it has a value
+already). Thus:
@example
objects = main.o foo.o bar.o utils.o
',
'', "Goodbye\n");
+# TEST 8: Append to empty
+run_make_test(q!
+recur =
+recur += foo
+simple :=
+simple += bar
+recur_empty = foo
+recur_empty +=
+simple_empty := bar
+simple_empty +=
+empty_recur =
+empty_recur +=
+empty_simple :=
+empty_simple +=
+
+all: ; @: $(info recur=/$(recur)/ simple=/$(simple)/ recure=/$(recur_empty)/ simplee=/$(simple_empty)/ erecur=/$(empty_recur)/ esimple=/$(empty_simple)/)
+!,
+ '', "recur=/foo/ simple=/bar/ recure=/foo/ simplee=/bar/ erecur=// esimple=//\n");
+
1;
The value is set IFF the variable is not defined yet. */
v = lookup_variable (varname, strlen (varname));
if (v)
- return v->special ? set_special_var (v) : v;
+ goto done;
conditional = 1;
flavor = f_recursive;
buffer if we're looking at a target-specific variable. */
val = tp = allocated_variable_expand (val);
- oldlen = strlen (v->value);
+ /* If the new value is empty, nothing to do. */
vallen = strlen (val);
+ if (!vallen)
+ {
+ alloc_value = tp;
+ goto done;
+ }
+
+ oldlen = strlen (v->value);
p = alloc_value = xmalloc (oldlen + 1 + vallen + 1);
- memcpy (alloc_value, v->value, oldlen);
- alloc_value[oldlen] = ' ';
- memcpy (&alloc_value[oldlen + 1], val, vallen + 1);
+
+ if (oldlen)
+ {
+ memcpy (alloc_value, v->value, oldlen);
+ alloc_value[oldlen] = ' ';
+ ++oldlen;
+ }
+
+ memcpy (&alloc_value[oldlen], val, vallen + 1);
free (tp);
}
+ break;
}
}
v->append = append;
v->conditional = conditional;
+ done:
free (alloc_value);
-
return v->special ? set_special_var (v) : v;
}
\f