bugGNU Octave - Bugs: bug #29987, strrep compatibility

 
 

bug #29987: strrep compatibility

Submitted by:  John W. Eaton <jwe>
Submitted on:  Sat 29 May 2010 01:21:10 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Jaroslav Hajek <highegg>
Originator Name: Open/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 02 Jun 2010 08:15:25 AM UTC, comment #3:

Fixed by
http://hg.savannah.gnu.org/hgweb/octave/rev/21defab4207c

I also made both strfind and strrep recognize a bool "overlaps" option; I think that very often skipping overlaps is what you want.

Jaroslav Hajek <highegg>In charge of this item.
Tue 01 Jun 2010 02:36:12 PM UTC, comment #2:

I think the rule is that the full replacement string is inserted in the result string for each overlapping pattern match. So your example produces "xyzxyz".

The Matlab docs say that strrep first gets a list of all the locations where the pattern matches (same as the strfind function).

John W. Eaton <jwe>
Project Administrator
Tue 01 Jun 2010 05:57:17 AM UTC, comment #1:

I don't think I understand how it works. Are the overlapping replacements overwritten over each other? What does strrep ("ababab", "abab", "xyz") return?

Jaroslav Hajek <highegg>In charge of this item.
Sat 29 May 2010 01:21:10 AM UTC, original submission:

Octave's strrep is incompatible with Matlab when there are overlapping patterns. For example:

Matlab> strrep(',0,0,',',0,',',,')
ans = ,,,,
Octave> strrep(',0,0,',',0,',',,')
ans = ,,0,

The Matlab behavior is documented, so it seems that it is intentional.

It looks like the function to fix is qs_replace in src/DLD-FUNCTIONS/strfind.cc, but it is not clear to me exactly what the proper fix is.

John W. Eaton <jwe>
Project Administrator

 

(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 highegg (Posted a comment)
  • -unavailable- added by jwe (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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 02 Jun 2010 08:15:25 AM UTChigheggStatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Tue 01 Jun 2010 05:57:17 AM UTChigheggStatusNone=>Need Info
      Assigned toNone=>highegg

    Back to the top


    Powered by Savane 3.1-cleanup1