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

Submitted by:  Eldar Abusalimov <abusalimov>
Submitted on:  Mon 30 Jan 2012 11:41:08 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 4.0Operating System: Any
Fixed Release: 4.0Triage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project AdministratorIn charge of this item.
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.

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>
Project AdministratorIn charge of this item.
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:

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>
Project AdministratorIn charge of this item.
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.

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 File(s):
   
   
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
  • -unavailable- added by psmith (Posted a comment)
  • -unavailable- added by abusalimov (Submitted the item)
  •  

    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 03 Mar 2012 11:04:58 PM UTCabusalimovAttached File-=>Added func_filter2.patch, #25259
    Sat 03 Mar 2012 10:15:10 PM UTCpsmithStatusNone=>Fixed
      Assigned toNone=>psmith
      Open/ClosedOpen=>Closed
      Fixed ReleaseNone=>4.0
    Mon 30 Jan 2012 11:41:08 PM UTCabusalimovAttached File-=>Added func_filter.patch, #24928

    Back to the top


    Powered by Savane 3.1-cleanup1