[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
index buggy for matching patterns longer than 3
From: |
Jean-Francois Cardoso |
Subject: |
index buggy for matching patterns longer than 3 |
Date: |
Tue, 7 Aug 2007 00:15:35 +0200 (CEST) |
User-agent: |
SquirrelMail/1.4.10a |
There is an error in the logic of find.m which makes it report a
matching pattern when *only* the first three characters match.
For example,
index("abc---", "abc+++")
returns 1 rather than 0.
The following patch fixes this and also adds the relevant new
testcases.
Cheers, JF
================================================================
*** octave-2.9.13/scripts/strings/index.m Wed Jun 20 20:10:04 2007
--- index.m Mon Aug 6 23:35:01 2007
***************
*** 106,111 ****
--- 106,112 ----
break;
endif
endfor
+ v = [] ;
endif
endif
***************
*** 122,130 ****
--- 123,134 ----
%!assert(index("astringbstringcstring", "st"), 2)
%!assert(index("astringbstringcstring", "str"), 2)
%!assert(index("astringbstringcstring", "string"), 2)
+ %!assert(index("abc---", "abc+++"), 0)
## test everything out in reverse
%!assert(index("astringbstringcstring", "s", "last"), 16)
%!assert(index("astringbstringcstring", "st", "last"), 16)
%!assert(index("astringbstringcstring", "str", "last"), 16)
%!assert(index("astringbstringcstring", "string", "last"), 16)
+ %!assert(index("abc---", "abc+++", "last"), 0)
+
================================================================
Changelog entry:
2007-08-04 Jean-Francois Cardoso <address@hidden>
* strings/index.m: correct for strings differing after the third
position (bug reported by Maude Martin).
- index buggy for matching patterns longer than 3,
Jean-Francois Cardoso <=