bugmake - Bugs: bug #2465, Quoting percent signs and...

 
 

bug #2465: Quoting percent signs and backslashes in patterns

Submitted by:  Stefan Merten <smerten>
Submitted on:  Tue 04 Feb 2003 11:24:49 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 3.79.1Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 01 Apr 2003 09:20:55 AM UTC, comment #2:

Thanks for your answer. So after all I know there probably is no good solution.

Unfortunately `$(shell ...)' won't be a solution because it'll get executed far too often. Ok. So percent signs in file names are a bit dangerous. One should not use them anyway ;-) .

Stefan Merten <smerten>
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.

Paul D. Smith <psmith>
Project Administrator
Tue 04 Feb 2003 11:24:49 AM UTC, original submission:

Hi!

I defined a `$(call)'-able variable which quotes a string so it is not used as a pattern for `$(patsubst)' etc. While test ing such a function I found what I think is a bug.

In the attached example case 1 and 2 work as expected: The quoted version of `$(original?)' matches `$(original?)'. This is what should happen.

Case 3 also works as exptected. However, case 4 unexpectedly fails. Note, that case 4 just reverses the placements of the quoted percent signs relative to case 3.

I can't see a possible logical explanation for that and so I think it is a bug.

Anyway the quoting mechanism for percent signs is somewhat weird :-( . Is the first backslash in '\\%' "in danger of quoting the percent sign" as the documentation expresses it? Need it be quoted? Does it still need to be quoted if the second backslash is quoted - which clearly is in danger of quoting the percent sign?

Stefan Merten <smerten>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #274:  Makefile added by smerten (701B - application/octet-stream - Makefile exposing the bug)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 01 Apr 2003 02:48:21 PM UTCpsmithStatusNone=>(Error - Not Found)
  Open/ClosedOpen=>(Error - Not Found)

Back to the top


Powered by Savane 3.1-cleanup1