www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3704] New: split(char[],char[]) is broken for delimiters greater than a single character

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

           Summary: split(char[],char[]) is broken for delimiters greater
                    than a single character
           Product: D
           Version: 1.054
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: nyphbl8d gmail.com



---
There are no fewer than 4 critical errors in the latest implementation of split
in phobos for the code path that deals with delimiters of length > 1.

test code:
import std.stdio;
import std.string;
void main() {
  foreach(item;" match".split(" and ")) writefln("my data: %s",item);
}

Half of the problem is caused by using size_t (which is unsigned afaict) to
capture the return value of find, which can be negative.  This issue causes the
following comparison to fail:
if (j == -1)

The other half is caused by not accounting for the fact that i can be greater
than s.length, as well as equal.  This causes the following comparison to fail
to perform as expected:
if (i == s.length)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 13 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3704


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



21:34:17 PDT ---
Has this been fixed? I have no problem of using delimiters with sizes greater
than 1:

This works:

import std.stdio;
import std.string;
void main()
{
    foreach (item; "test  test".split("  "))
    {
        writefln("my data: %s", item);
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 24 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3704


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



If this bug report doesn't become more clear, then I suggest to eventually
close it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25 2011