Fix some bugs in variable pattern substitution (e.g. $(VAR:A=B)),

reported by Markus Mauhart <qwe123@chello.at>.  One was a simple typo; to
fix the other we call patsubst_expand() for all instances of variable
substitution, even when there is no '%'.  We used to call subst_expand()
with a special flag set in the latter case, but it didn't work properly
in all situations.  Easier to just use patsubst_expand() since that's
what it is.
This commit is contained in:
Paul Smith
2004-09-21 04:00:31 +00:00
parent 08c8105c54
commit 0799ce730d
9 changed files with 146 additions and 102 deletions

View File

@@ -1,3 +1,9 @@
2004-09-20 Paul D. Smith <psmith@gnu.org>
* scripts/functions/substitution: Rewrite to use run_make_test()
interface, and add test for substitution failures reported by
Markus Mauhart <qwe123@chello.at>.
2004-03-22 Paul D. Smith <psmith@gnu.org>
* test_driver.pl (run_each_test, toplevel, compare_output): Change

View File

@@ -64,6 +64,14 @@ sub run_make_test
$makefile = &get_tmpfile();
}
# If either the makestring or the answer don't end in newlines, add one In
# the future should we allow an option to disable this? For now if you
# want to test handling with no newline you have to call the underlying
# functions directly.
$makestring =~ /\n$/s or $makestring .= "\n";
$answer =~ /\n$/s or $answer .= "\n";
# Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to
# make in both $makestring and $answer.

View File

@@ -1,32 +1,33 @@
$description = "The following test creates a makefile to ...";
# -*-perl-*-
$description = "Test the subst and patsubst functions";
$details = "";
open(MAKEFILE,"> $makefile");
# Generic patsubst test: test both the function and variable form.
# The Contents of the MAKEFILE ...
run_make_test('
foo := a.o b.o c.o
bar := $(foo:.o=.c)
bar2:= $(foo:%.o=%.c)
bar3:= $(patsubst %.c,%.o,x.c.c bar.c)
all:;@echo $(bar); echo $(bar2); echo $(bar3)',
'',
'a.c b.c c.c
a.c b.c c.c
x.c.o bar.o');
print MAKEFILE "foo := a.o b.o c.o\n"
."bar := \$(foo:.o=.c)\n"
."bar2:= \$(foo:%.o=%.c)\n"
."bar3:= \$(patsubst %.c,%.o,x.c.c bar.c)\n"
."all:\n"
."\t\@echo \$(bar)\n"
."\t\@echo \$(bar2)\n"
."\t\@echo \$(bar3)\n";
# Patsubst without '%'--shouldn't match because the whole word has to match
# in patsubst. Based on a bug report by Markus Mauhart <qwe123@chello.at>
# END of Contents of MAKEFILE
run_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo');
close(MAKEFILE);
# Variable subst where a pattern matches multiple times in a single word.
# Based on a bug report by Markus Mauhart <qwe123@chello.at>
&run_make_with_options($makefile,"",&get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "a.c b.c c.c\n"
."a.c b.c c.c\n"
."x.c.o bar.o\n";
&compare_output($answer,&get_logfile(1));
run_make_test('
A := fooBARfooBARfoo
all:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL');
1;