Tue 25 Mar 2003 04:16:24 AM UTC, comment #1:
Actually, the problem is in your quoting function. It does not correctly handle strings like "\\%"; these are left unquoted. Your case #3 works by accident: because the pattern in this version matches something (the "%") in the original it's deemed a match; but it's still considered a pattern where I assume you are trying to quote the pattern so that it's a simple string match.
If you use $(warning ...) you can see that the quoting is wrong:
quoted = $(subst \\%,\\\%,$(subst %,\%,test\\%test))
$(warning quoted is $(quoted))
Gives:
$ make
Makefile:2: quoted is test\\\\%test
Note how this is wrong: there are four backslashes, which collapses to "\\%", but this is wrong for a quoted string; you want 5 backslashes, so it collapses to "\\\%", and escapes the percent.
Right?
The problem is you first subst \% for %:
test\\%test -> test\\\%test
Then you subst \\\% for \\%:
test\\\%test -> test\\\\%test
Not right. Unfortunately I don't believe there is a way to correctly write this function using GNU make capabilities. You'll have to use a $(shell ...) call to some more comprehensive scripting language.
|