bugmake - Bugs: bug #35410, [patch] Fix a bug with...

 
 

bug #35410: [patch] Fix a bug with filter/filter-out functions when pattern contains only quoted percents

Submitter:  Eldar Abusalimov <abusalimov>
Submitted:  Mon 30 Jan 2012 11:41:08 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.0 Operating System:  Any
Fixed Release:  4.0 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 04 Mar 2012 02:57:03 PM UTC, comment #5: 

I just don't believe the change will really save much.  strlen() is pretty darn efficient and trying to circumvent it has costs as well.  With modern compilers and architectures it's almost impossible to guess which sorts of micro optimizations, like this, will be effective.  If you have any empirical numbers showing a significant difference I'll think about it.

Paul D. Smith <psmith>
Group administrator
Sun 04 Mar 2012 10:12:43 AM UTC, comment #4: 

Well, personally I often use filter-out to intersect lists of variables, which can be rather big (about 20000 variables) and contain more or less long names.


old_variables := $(.VARIABLES)
...
new_variables := $(filter-out $(old_variables),$(.VARIABLES))


Eldar Abusalimov <abusalimov>
Sun 04 Mar 2012 08:59:51 AM UTC, comment #3: 

I don't think the strlen() thing is worth the complexity: the average length of a word passed to filter/filter-out is pretty small.

I did simplify the detection of filter vs. filter-out (and some other functions as well) though.

Paul D. Smith <psmith>
Group administrator
Sat 03 Mar 2012 11:04:58 PM UTC, comment #2: 

Oops, yes, I'm agree.

Another possible (and quite simple to apply it right now) optimization is to use something like:


pat->length = len/2 + strlen(pat->str + len/2)


It seems to be safe as far as the string can't become shorter than a half of the original one (the worst case is like '\\\%' -> '\%').

The patch for the latest version from CVS is attached below. It also changes the way of checking whether the called function is "filter" or "filter-out".

(file #25259)

Eldar Abusalimov <abusalimov>
Sat 03 Mar 2012 10:15:10 PM UTC, comment #1: 

The patch here was not quite right: you can't be sure that every character between the new EOS and the old EOS is a nul character, so I used strlen() to find the new length.  To be more efficient we'd need to change the calling method for the find_percent() etc. functions to return the new string length.

Fix has been committed.

Paul D. Smith <psmith>
Group administrator
Mon 30 Jan 2012 11:41:08 PM UTC, original submission:  

Literal pattern containing quoted percents (without any operative ones) does not match any word.


# Expected to return 'foo%bar', but returns nothing.
$(filter foo\%bar,foo%bar)


This happens because after calling 'find_percent' function the string length can decrease, but pattern matching code for literals uses old value of the length.

The attached patch also removes a code used to restore whitespaces inside the first argument as far as arguments are always get freed after calling a function handler anyway.

Eldar Abusalimov <abusalimov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #25259:  func_filter2.patch added by abusalimov (825B - text/x-patch - patch against CVS HEAD)
file #24928:  func_filter.patch added by abusalimov (991B - text/x-patch - patch against CVS HEAD)

 

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 abusalimov (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
    2012-03-03 abusalimov Attached File- Added func_filter2.patch, #25259
    2012-03-03 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.0
    2012-01-30 abusalimov Attached File- Added func_filter.patch, #24928

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code