[bug #64339] $(filter) and $(filter-out) interpret "match" in surprising ways

2024-01-07 Thread Paul D. Smith
Update of bug#64339 (group make):

  Item Group:None => Documentation  
  Status:None => Fixed  
 Assigned to:None => psmith 
 Open/Closed:Open => Closed 
   Fixed Release:None => SCM
   Triage Status:None => Small Effort   

___

Follow-up Comment #2:

I updated the documentation, thanks Eli.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #64339] $(filter) and $(filter-out) interpret "match" in surprising ways

2023-06-22 Thread Paul D. Smith
Follow-up Comment #1, bug #64339 (project make):

I believe that the use of PATTERN here is intended to make you understand that
it's the same matching rules as with pattern rules or other uses of patterns,
such as the patsubst function; patterns that don't contain a "%" always
require the entire word to match identically, everywhere in GNU Make.

However it's not an excuse: definitely the docs could be more clear here.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #64339] $(filter) and $(filter-out) interpret "match" in surprising ways

2023-06-22 Thread Eli Zaretskii
URL:
  

 Summary: $(filter) and $(filter-out) interpret "match" in
surprising ways
   Group: make
   Submitter: eliz
   Submitted: Thu 22 Jun 2023 10:07:13 PM IDT
Severity: 3 - Normal
  Item Group: None
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: SCM
Operating System: Any
   Fixed Release: None
   Triage Status: None


___

Follow-up Comments:


---
Date: Thu 22 Jun 2023 10:07:13 PM IDT By: Eli Zaretskii 
The GNU Make Manual says:

'$(filter-out PATTERN...,TEXT)'
 Returns all whitespace-separated words in TEXT that _do not_ match
 any of the PATTERN words, removing the words that _do_ match one or
 more.  This is the exact opposite of the 'filter' function.

 For example, given:

  objects=main1.o foo.o main2.o bar.o
  mains=main1.o main2.o

 the following generates a list which contains all the object files
 not in 'mains':

  $(filter-out $(mains),$(objects))

Note that the text doesn't really say what it means to "match" in this
context, nor what exactly is PATTERN. The example might make you believe the
"match" means "substring". That is A "matches" B if A is some substring of B.
But this is not the case. Observe:

$ make -f-
ORIG=foo123 bar-xyz baz-yes
EXCLUDE=bar foo
all:
@echo "$(filter-out $(EXCLUDE),$(ORIG))"
^D
=> foo123 bar-xyz baz-yes

That is, "foo123" does NOT match "foo", and "bar-xyz" does NOT match "bar".
The following does work, though:

$ make -f-
ORIG=./foo ./bar ./baz
EXCLUDE=%bar %foo
all:
@echo "$(filter-out $(EXCLUDE),$(ORIG))"
^D
=> ./baz

So now we perhaps understand that PATTERN is something that includes the %
wildcard somewhere. This should be explained in the manual, and the manual
should also somehow justify the special case of exact string equality, in
which case the % wildcard is not required.

IOW, having the exact string equality as the only example in this case is
misleading and confusing. I learned this the hard way, having just spent an
hour debugging my Makefile where $(filter-out) didn't do its job, because I
thought "./foo" should match "foo", based on what the manual says.








___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/