Fix Savannah bug #15913.
authorPaul Smith <psmith@gnu.org>
Wed, 15 Mar 2006 03:31:30 +0000 (03:31 +0000)
committerPaul Smith <psmith@gnu.org>
Wed, 15 Mar 2006 03:31:30 +0000 (03:31 +0000)
ChangeLog
NEWS
expand.c
tests/scripts/features/targetvars

index 04f467227bdd14e24b4db06d70bf6bcbc003652f..abe3b9b93cce07fd219f387f76ffa2a61d9bbdd2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-14  Paul D. Smith  <psmith@gnu.org>
+
+       * expand.c (variable_append): Instead of appending everything then
+       expanding the result, we expand (or not, if it's simple) each part
+       as we add it.
+       (allocated_variable_append): Don't expand the final result.
+       Fixes Savannah bug #15913.
+
 2006-03-09  Paul Smith  <psmith@gnu.org>
 
        * remake.c (update_file_1): Revert the change of 3 Jan 2006 which
@@ -7,7 +15,7 @@
        in the next release, to give them time to fix their build system.
        Fixes Savannah bug #16002.
        Introduces Savannah bug #16051.
-       
+
        * implicit.c (pattern_search) [DOS_PATHS]: Look for DOS paths if
        we *don't* find UNIX "/".
        Reported by David Ergo <david.ergo@alterface.com>
diff --git a/NEWS b/NEWS
index ffaa0f36d9d1bad741555df14b6e24c388290cbe..b720e0204672c9ab7cb2a8929f02f92bab22f4f7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,14 @@ Version 3.81rc2
   the build_w32.bat batch file; see the file README.W32 for more
   details.
 
+* WARNING: Future backward-incompatibility!
+  Up to and including this release, the '$?' variable does not contain
+  any prerequisite that does not exist, even though that prerequisite
+  might have caused the target to rebuild.  Starting with the _next_
+  release of GNU make, '$?' will contain all prerequisites that caused
+  the target to be considered out of date.  See this Savannah bug:
+  http://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=16051
+
 * WARNING: Backward-incompatibility!
   GNU make now implements a generic "second expansion" feature on the
   prerequisites of both explicit and implicit (pattern) rules.  In order
index 5c7934e9980a1b88b57b65471cc0b8f77be18c8d..993e6d4f08205b3e4de6a010b6b140b2d49bf4cd 100644 (file)
--- a/expand.c
+++ b/expand.c
@@ -501,14 +501,19 @@ variable_append (const char *name, unsigned int length,
   if (buf > variable_buffer)
     buf = variable_buffer_output (buf, " ", 1);
 
-  return variable_buffer_output (buf, v->value, strlen (v->value));
+  /* Either expand it or copy it, depending.  */
+  if (! v->recursive)
+    return variable_buffer_output (buf, v->value, strlen (v->value));
+
+  buf = variable_expand_string (buf, v->value, strlen (v->value));
+  return (buf + strlen (buf));
 }
 
 
 static char *
 allocated_variable_append (const struct variable *v)
 {
-  char *val, *retval;
+  char *val;
 
   /* Construct the appended variable value.  */
 
@@ -524,12 +529,7 @@ allocated_variable_append (const struct variable *v)
   variable_buffer = obuf;
   variable_buffer_length = olen;
 
-  /* Now expand it and return that.  */
-
-  retval = allocated_variable_expand (val);
-
-  free (val);
-  return retval;
+  return val;
 }
 
 /* Like variable_expand_for_file, but the returned string is malloc'd.
index 18dd0239698bb83c121ed20cfdb524afdd899e45..e2e9c9066f70c95581642a84124841d7e3b28540 100644 (file)
@@ -292,4 +292,16 @@ rules.mk : MYVAR = foo
 rmfiles('t1/rules.mk');
 rmdir('t1');
 
+# TEST #18
+
+# Test appending to a simple variable containing a "$": avoid a
+# double-expansion.  See Savannah bug #15913.
+
+run_make_test("
+VAR := \$\$FOO
+foo: VAR += BAR
+foo: ; \@echo '\$(VAR)'",
+              '',
+              '$FOO BAR');
+
 1;