www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1233] New: std.string.ifind(char[] s, char[] sub) fails on certain non ascii strings

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1233

           Summary: std.string.ifind(char[] s, char[] sub) fails on certain
                    non ascii strings
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: patch
          Severity: trivial
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: d chqrlie.org


import std.string;
int main(char[][] args) {
    printf("ifind(\"é\", \"é\") -> %d\n", ifind("é", "é"));
    return 0;
}

produces incorrect output : 

ifind("é", "é") -> -1

bug is in src/phobos/std/string.d, line 613:

-          size_t imax = s.length - sublength;
+          size_t imax = s.length - sublength + 1;

This will fix the bug, but the implementation will remain quite inefficient.


-- 
May 15 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1233


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 1.018 and DMD 2.002


-- 
Jul 01 2007