bugGNU Octave - Bugs: bug #45084, regexptranslate incorrectly...

 
 

bug #45084: regexptranslate incorrectly escapes "<" and ">", maybe others

Submitted by:  Colin Macdonald <cbm>
Submitted on:  Tue 12 May 2015 01:35:32 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 13 May 2015 11:34:08 AM UTC, comment #2:

Thank you for the quick fix! Seems to work perfectly for my issue.

Colin Macdonald <cbm>
Tue 12 May 2015 03:49:08 PM UTC, comment #1:

I'm pretty sure I was the one that coded that regular expression and I did it because it was simplest to escape everything that might be a regular expression, rather than to come up with a definitive list of the characters to escape.

But we could go the other way as well and list everything that seems like a possible pattern. I made that change on the development branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/89616a98b02e). I also improved the speed of the 'wildcard' option by 44% while I was modifying the function.

I made the change on the development branch, but I will also pull it across to the stable branch.

Rik <rik5>
Project Administrator
Tue 12 May 2015 01:35:32 PM UTC, original submission:

regexptranslate has an "escape" mode which escapes characters.

The docs say: "special meaning for regular expressions are escaped so that they are treated literally."

But some characters without special meaning are incorrectly escaped:

('re' is just 's' again on Matlab and thus 're' does indeed match 's'. I believe this is the correct behaviour).

I looked at the implementation and it does look wrong in that it escapes all non-word characters:

This is https://github.com/catch22/octave-doctest/issues/42.

If someone confirms this, I will try to write a patch which explicitly lists all characters to be translated.

Colin Macdonald <cbm>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by cbm (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 project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 12 May 2015 03:49:08 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1