bugmake - Bugs: bug #5798, "if" built-in does not...

 
 

bug #5798: "if" built-in does not strip conditional as documented

Submitted by:  Robert Mecklenburg <mecklen>
Submitted on:  Wed 08 Oct 2003 04:28:30 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 3.78Operating System: Any
Fixed Release: 3.81Triage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sat 22 Nov 2003 03:12:58 PM UTC, comment #3:

Noel writes:

> At first I was thinking that it would be more useful if
> steps b and c were swapped. Then I thought that would
> make it impossible, or at least more difficult, to perform
> a switch on a variable whose value contained only spaces.


Robert is correct: the stripping, as with all functions in GNU make, is done BEFORE the variables are expanded. In other words, a variable that expands to nothing but spaces is still considered "true", because it's not empty. If you want to avoid that you can always use $(strip ...) around the variable.

Now the question becomes, does this show a bug in $(call ...) instead? I would think that the whitespace in the first argument would be stripped before the function "fn" was invoked. Hm.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Thu 20 Nov 2003 05:17:32 PM UTC, comment #2:

Noel, I'm not sure we are talking about the same thing. I think that the algorithm goes:

a) grab the text between 'if ' and ','
b) strip extra leading and trailing whitespace
c) expand any variables in the remaining text
d) if the expanded text is not zero length it is true

If I understand correctly, your code should be correct because the second call does contain characters.

Of course, Paul is the source of all wisdom here.

Robert Mecklenburg <mecklen>
Sun 02 Nov 2003 09:38:46 PM UTC, comment #1:

You're right, this is a bug. Please try the attached patch.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Wed 08 Oct 2003 04:28:30 AM UTC, original submission:

The docs say: "$(if CONDITION,THEN-PART[,ELSE-PART]) The first argument, CONDITION, first has all preceding and trailing
whitespace stripped, then is expanded." But 3.80 doesn't seem to strip condition:

make -f- <<< 'x:;echo $(if $(empty) ,true,false)'

Yields "true". Shouldn't it strip the blank before and after $(empty), then evaluate $(empty) and return false?
Or is this a documentation bug?

Robert Mecklenburg <mecklen>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #790:  if-strip.diff added by psmith (674B - text/plain - Proposed official solution)

 

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 6 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sat 01 Apr 2006 07:08:57 AM UTCpsmithFixed Release4.0=>3.81
Sun 02 Nov 2003 09:38:46 PM UTCpsmithStatusNone=>(Error - Not Found)
  Assigned toNone=>NA
  Open/ClosedOpen=>(Error - Not Found)
  Component VersionNone=>(Error - Not Found)
  Fixed ReleaseNone=>(Error - Not Found)

Back to the top


Powered by Savane 3.1-cleanup1