[Issue 9753] std.string.translate precondition asserts

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 18 15:36:04 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9753



--- Comment #2 from bearophile_hugs at eml.cc 2013-03-18 15:36:03 PDT ---
(In reply to comment #1)
> Why are those asserts in there anyway? A char can't be larger than 255..?

Ah, right. My brain was switched too much off.

This looks better:

    foreach (dchar c; str)
        assert(c < 256);


But this is a full-range translate(), so it should work in the whole range of
[0, 256[, so I this precondition:

in
{
    assert(transTable.length == 256);
    foreach(char c; str)
        assert(c <= 256);
    foreach(char c; transTable)
        assert(c <= 256);
    foreach(char c; toRemove)
        assert(c <= 256);
}


Should be:

in
{
    assert(transTable.length == 256);
}

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


More information about the Digitalmars-d-bugs mailing list