www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7692] New: std.conv.parse should do lookahead for "0x" in strings with radix 16

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

           Summary: std.conv.parse should do lookahead for "0x" in strings
                    with radix 16
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



19:50:29 PDT ---
import std.conv;

void main()
{
   string s1 = "ff";
   string s2 = "0xff";

   assert(parse!uint(s1, 16) == 0xff);  // ok
   assert(parse!uint(s2, 16) == 0xff);  // fail, it's 0
}

parse should pop the first two characters if the string starts with 0x.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 11 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7692




19:53:45 PDT ---
A simple thing to do would probably be to add this at the start of
Target parse(Target, Source)(ref Source s, uint radix):

    if (radix == 16 && s.startsWith("0x"))
        s.popFrontN(2);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 11 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7692


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

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



12:43:24 PDT ---
This would break code, notes:
https://github.com/D-Programming-Language/phobos/pull/835

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012