www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5247] New: std.utf.stride() should not return 0xFF

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

           Summary: std.utf.stride() should not return 0xFF
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: rsinfu gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu gmail.com> 2010-11-21 01:12:18 PST
---
stride(s, i) returns 0xFF, or 255, if s[i] is not a UTF-8 lead byte. This
design allows the function to silently succeed when the input is broken:

auto str = new char[](300);
str[0] = '\xFE';                // broken
str = str[str.stride(0) .. $];  // jumps 255 bytes

stride(s, i) should throw an exception if s[i] is not a lead byte. Or at least
the error value should not be 255.

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


Jacob Carlborg <doob me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob me.com


--- Comment #1 from Jacob Carlborg <doob me.com> 2010-11-21 02:59:58 PST ---
Are you sure that you understand how stride works? stride returns the length of
an UTF sequence, not an index. Why would you try to use the return value of
stride as an index?

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


nfxjfg gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg gmail.com


--- Comment #2 from nfxjfg gmail.com 2010-11-21 05:10:52 PST ---
(In reply to comment #1)
 Are you sure that you understand how stride works? stride returns the length of
 an UTF sequence, not an index. Why would you try to use the return value of
 stride as an index?
You use the length to index into the string or to slice it. Obviously stride() should return a valid value, and not some undocumented magic (well it's a bug most likely, and not a feature gone wrong). I don't get what's your problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 21 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5247


Masahiro Nakagawa <repeatedly gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |repeatedly gmail.com
         Resolution|                            |FIXED


--- Comment #3 from Masahiro Nakagawa <repeatedly gmail.com> 2010-11-24
07:57:11 PST ---
Fixed in changeset 2190.
http://dsource.org/projects/phobos/changeset/2190

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 24 2010