www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10078] New: std.string.indexOf(Char[], dchar, CaseSensitive) fails at compile time

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

           Summary: std.string.indexOf(Char[], dchar, CaseSensitive) fails
                    at compile time
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: michael overuse.org


--- Comment #0 from Mike Houston <michael overuse.org> 2013-05-13 16:44:16 PDT
---
Created an attachment (id=1213)
Patch to indexOf to avoid calling memchr

DMD 2.062
OS X

If the std.string.indexOf(Char[], dchar, CaseSensitive) method is called at
compile time with an ASCII dchar, it will fail:

/usr/share/dmd/src/phobos/std/string.d(345): Error: memchr cannot be
interpreted at compile time, because it has no available source code

Test case:

import std.stdio;
import std.string;

int index = indexOf("xyz", cast(dchar) 'x'); // Fails compile
int index1 = indexOf("xyz", cast(dstring) "x"); // Succeeds

void main() {

    writeln("indexOf(\"xyz\", \"x\") = ", index);

}

Patch:

I've modified the string.d implementation to avoid calling memchr. In that
branch of the code, I have inserted a modified version of the case-insensitive
version of the search loop.

Diff file attached against the source included in the 2.0.62 distribution.

Regards,
Mike.

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


Diggory <diggsey googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |diggsey googlemail.com


--- Comment #1 from Diggory <diggsey googlemail.com> 2013-05-14 17:04:23 PDT ---
Coincidence - I just ran into the exact same problem with almost the exact same
test you are using...

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



--- Comment #2 from Mike Houston <michael overuse.org> 2013-05-17 04:17:51 PDT
---
I've created a pull request, in case it helps:

https://github.com/D-Programming-Language/phobos/pull/1293

Mike.

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



--- Comment #3 from github-bugzilla puremagic.com 2013-07-16 18:00:21 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/4bafa5735ff54dca7ae386599ab1c2be87b72cb8
fix Issue 10078 - std.string.indexOf fails at compile time

https://github.com/D-Programming-Language/phobos/commit/8410f983b485c3cd7c08ca82221405b2937c8e70
Merge pull request #1417 from dawgfoto/fix10078

fix Issue 10078 - std.string.indexOf fails at compile time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10078


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 16 2013