From: Paul Smith Date: Sun, 28 May 2017 04:33:29 +0000 (-0400) Subject: [SV 50823] Support filenames containing '$' in MAKEFILE_LIST X-Git-Tag: 4.2.90~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5345adf82f5d57b0d30a3e8ec8e1c68f91382f21;p=thirdparty%2Fmake.git [SV 50823] Support filenames containing '$' in MAKEFILE_LIST * 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 '$'. --- diff --git a/read.c b/read.c index 5e2bc5bd..d30727b3 100644 --- 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 */ diff --git a/tests/scripts/variables/MFILE_LIST b/tests/scripts/variables/MFILE_LIST index 076e42da..b75eea7e 100644 --- a/tests/scripts/variables/MFILE_LIST +++ b/tests/scripts/variables/MFILE_LIST @@ -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 < $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; diff --git a/variable.c b/variable.c index 15096b0b..ca66ecd7 100644 --- a/variable.c +++ b/variable.c @@ -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 diff --git a/variable.h b/variable.h index fe1d609d..a36e147e 100644 --- a/variable.h +++ b/variable.h @@ -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.