]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 50823] Support filenames containing '$' in MAKEFILE_LIST
authorPaul Smith <psmith@gnu.org>
Sun, 28 May 2017 04:33:29 +0000 (00:33 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 4 Jun 2017 22:37:21 +0000 (18:37 -0400)
* variable.h (enum variable_flavor: Add a new flavor for appended
values that shouldn't be expanded.
* variable.c (do_variable_definition): If given this new flavor,
do not expand the value before appending it.
* read.c (eval_makefile): Use this new flavor for MAKEFILE_LIST
* tests/scripts/variables/MFILE_LIST: Test filenames containing '$'.

read.c
tests/scripts/variables/MFILE_LIST
variable.c
variable.h

diff --git a/read.c b/read.c
index 5e2bc5bdb21fce2d282ab0eaecbcfb54d6efc33e..d30727b36a578182e05a5c8bad663eb64845cde9 100644 (file)
--- a/read.c
+++ b/read.c
@@ -421,7 +421,7 @@ eval_makefile (const char *filename, int flags)
 
   /* Add this makefile to the list. */
   do_variable_definition (&ebuf.floc, "MAKEFILE_LIST", filename, o_file,
-                          f_append, 0);
+                          f_append_value, 0);
 
   /* Evaluate the makefile */
 
index 076e42da33165a1ede598d991fdb6933d05a5279..b75eea7e8fd398b514905f8abee762311136ee36 100644 (file)
@@ -2,29 +2,39 @@
 
 $description = "Test the MAKEFILE_LIST variable.";
 
-$makefile2 = &get_tmpfile;
+create_file('incl2', "m2 := \$(MAKEFILE_LIST)\n");
 
-open(MAKEFILE,"> $makefile");
-print MAKEFILE <<EOF;
+run_make_test(qq!
 m1 := \$(MAKEFILE_LIST)
-include $makefile2
+include incl2
 m3 := \$(MAKEFILE_LIST)
 
 all:
 \t\@echo \$(m1)
 \t\@echo \$(m2)
 \t\@echo \$(m3)
-EOF
-close(MAKEFILE);
+!,
+              '', "#MAKEFILE#\n#MAKEFILE# incl2\n#MAKEFILE# incl2\n");
 
+unlink('incl2');
 
-open(MAKEFILE,"> $makefile2");
-print MAKEFILE "m2 := \$(MAKEFILE_LIST)\n";
-close(MAKEFILE);
+# SV 50823 -- makefiles containing '$' chars
 
+create_file('foo$bar', "m2 := \$(MAKEFILE_LIST)\n");
 
-&run_make_with_options($makefile, "", &get_logfile);
-$answer = "$makefile\n$makefile $makefile2\n$makefile $makefile2\n";
-&compare_output($answer,&get_logfile(1));
+run_make_test(qq!
+m1 := \$(MAKEFILE_LIST)
+include foo\$\$bar
+m3 := \$(MAKEFILE_LIST)
+
+all:
+\t\@echo '\$(m1)'
+\t\@echo '\$(m2)'
+\t\@echo '\$(m3)'
+\t\@echo '\$(value MAKEFILE_LIST)'
+!,
+              '', "#MAKEFILE#\n#MAKEFILE# foo\$bar\n#MAKEFILE# foo\$bar\n#MAKEFILE# foo\$bar\n");
+
+unlink('foo$bar');
 
 1;
index 15096b0b75500d0741139ca57bf1671e19b3fd13..ca66ecd7d2d76a2cca20eaa26684f22d6b37eaf7 100644 (file)
@@ -1208,6 +1208,7 @@ do_variable_definition (const floc *flocp, const char *varname,
       p = value;
       break;
     case f_append:
+    case f_append_value:
       {
         /* If we have += but we're in a target variable context, we want to
            append only with other variables in the context of this target.  */
@@ -1243,9 +1244,9 @@ do_variable_definition (const floc *flocp, const char *varname,
             val = value;
             if (v->recursive)
               /* The previous definition of the variable was recursive.
-                 The new value is the unexpanded old and new values. */
+                 The new value is the unexpanded old and new values.  */
               flavor = f_recursive;
-            else
+            else if (flavor != f_append_value)
               /* 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
index fe1d609da8ab3a4d14f425ec59ff83347c4fa42a..a36e147ea90a0f0a3ad4292356c42ab45ff8f5e4 100644 (file)
@@ -37,7 +37,8 @@ enum variable_flavor
     f_recursive,        /* Recursive definition (=) */
     f_append,           /* Appending definition (+=) */
     f_conditional,      /* Conditional definition (?=) */
-    f_shell             /* Shell assignment (!=) */
+    f_shell,            /* Shell assignment (!=) */
+    f_append_value      /* Append unexpanded value */
   };
 
 /* Structure that represents one variable definition.