bugmake - Bugs: bug #46995, Within 'define' newline is treated...

 
 

bug #46995: Within 'define' newline is treated as non whitespace

Submitter:  Gur Stavi <gstavi>
Submitted:  Thu 28 Jan 2016 09:17:10 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.1 Operating System:  None
Fixed Release:  4.2 Triage Status:  Medium Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 24 Mar 2016 01:51:33 PM UTC, comment #4: 

I've fixed the larger issue in Git and it will be available in the next release.

Paul D. Smith <psmith>
Group administrator
Tue 15 Mar 2016 03:29:11 PM UTC, comment #3: 

My apologies for the double-post.  I responded to the mailing list and that didn't add it to the bug history.


> So I understand that the problem actually is that
> foreach adds whitespace into variable name.
>
>   $(foreach var , $(LIST), do something with $(var ))
>
> while in contrast for example 'call' knows to strip
> whitespace from a var name so this:
>
>   $(call var ,$(ARG))
>
> will actually invoke $(var) and not $(var ).


Yes, that's the jist of it.

> Don't think I can change the bug topic.
> Is that a known issue with an already open bug?


I don't know of one, but this is probably sufficient.

I can't think of a valid situation where someone would want leading/trailing whitespace as part of a variable name, so it's probably safe to just call strip( gmk_expand( argv[0] ) ) inside the C function backing $(foreach) and have done with it.

It would still allow the temporary variable to use whitespace between non-whitespace characters, and that seems like the most obscure case that should be supported.

For clarity: this can be reproduced /without/ the define like so:

> $(foreach variable_name \
> , list of values \
> , expression \
> )


In that case the name of the variable has a space + newline at the end.

Brian Vandenberg <phantal>
Tue 15 Mar 2016 09:44:13 AM UTC, comment #2: 

Thanks for the extra info Brian.
So I understand that the problem actually is that foreach adds whitespace into variable name.

$(foreach var , $(LIST), do something with $(var ))

while in contrast for example 'call' knows to strip whitespace from a var name so this:

$(call var ,$(ARG))
will actually invoke $(var) and not $(var ).

Don't think I can change the bug topic.
Is that a known issue with an already open bug?

Gur Stavi <gstavi>
Mon 14 Mar 2016 06:08:00 PM UTC, comment #1: 

I don't know whether they'll want to fix this, but this is the pattern I use for situations like that:


define SOMETHING =
$(foreach variable,
  list of values
, expression
)
endef


I would prefer leading commas as in:

define SOMETHING =
$(foreach variable
, list of values
, expression
)
endef


... because it's both readable and easier on the eyes in peer reviews, but the way $(foreach) reads its 1st argument makes that unworkable.

Brian Vandenberg <phantal>
Thu 28 Jan 2016 09:17:10 AM UTC, original submission:  

Observe the following example:
When 'function' is expended (into 'dummy') the foreach works on a variable made of NEWLINE. This may be very confusing.

Makefile
------------------------
define function
$(foreach
, $1,$(info $(
)))
endef

dummy := $(call function, aaa bbb ccc)

all:


Output
------------------------
aaa
bbb
ccc
make: Nothing to be done for 'all'.

Gur Stavi <gstavi>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by phantal (Posted a comment)
  • -email is unavailable- added by gstavi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-24 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Component VersionNone 4.1
        Fixed ReleaseNone 4.2
        Triage StatusNone Medium Effort

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code