Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1954

Show
Ignore:
Timestamp:
09/04/10 15:23:54 (14 years ago)
Author:
dsimcha
Message:

Bug 4748: Shadowing declaration error in std.string.tolower

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docsrc/changelog.dd

    r1953 r1954  
    4242    $(LI $(BUGZILLA 4363): Some phobos ranges are not forward ranges (but should be).) 
    4343    $(LI $(BUGZILLA 4381): Length attribute for std.typecons.Tuple.) 
    4444    $(LI $(BUGZILLA 4387): std.range.Cycle assumes lvalue elements.) 
    4545    $(LI $(BUGZILLA 4388): std.range.Radial assumes lvalue elements.) 
    4646    $(LI $(BUGZILLA 4403): std.range.FrontTransversal assumes lvalue elements.) 
    4747    $(LI $(BUGZILLA 4404): std.range.Transversal assumes lvalue elements.) 
    4848    $(LI $(BUGZILLA 4455): Taking the sqrt of an integer shouldn't require an explicit cast.) 
    4949    $(LI $(BUGZILLA 4464): std.range.take does not always return Take!R.) 
    5050    $(LI $(BUGZILLA 4603): array(iota(1, 0)) error.) 
    5151    $(LI $(BUGZILLA 4700): to!float("0") fails) 
     52    $(LI $(BUGZILLA 4748): Shadowing declaration error in std.string.tolower) 
    5253    $(LI $(BUGZILLA 4789): std.algorithm.sort bug) 
    5354    $(LI $(BUGZILLA 4810): dotProduct problem with ints) 
    5455    ) 
    5556) 
    5657 
    5758 
    5859<div id=version> 
    5960$(UL 
    6061    $(NEW 049) 
    6162    $(NEW 048) 
  • trunk/phobos/std/string.d

    r1923 r1954  
    775775    assert(i == 0); 
    776776} 
    777777 
    778778 
    779779/************************************ 
    780780 * Convert string s[] to lower case. 
    781781 */ 
    782782 
    783783S tolower(S)(S s) if (isSomeString!S) 
    784784{ 
    785     foreach (i, dchar c; s) 
    786     { 
    787         if (!std.uni.isUniUpper(c)) continue; 
     785    foreach (i, dchar cOuter; s) 
     786    { 
     787        if (!std.uni.isUniUpper(cOuter)) continue; 
    788788        auto result = s[0.. i].dup; 
    789789        foreach (dchar c; s[i .. $]) 
    790790        { 
    791791            if (std.uni.isUniUpper(c)) 
    792792            { 
    793793                c = std.uni.toUniLower(c); 
    794794            } 
    795795            result ~= c; 
    796796        } 
    797797        return cast(S) result; 
     
    905905    tolowerInPlace(s3); 
    906906    assert(s3 == s2, s3); 
    907907 
    908908    s1 = "\u0130"; 
    909909    s2 = tolower(s1); 
    910910    s3 = s1.dup; 
    911911    assert(s2 == "i"); 
    912912    assert(s2 !is s1); 
    913913    tolowerInPlace(s3); 
    914914    assert(s3 == s2, s3); 
     915 
     916    // Test on wchar and dchar strings. 
     917    assert(tolower("Some String"w) == "some string"w); 
     918    assert(tolower("Some String"d) == "some string"d); 
    915919} 
    916920 
    917921/************************************ 
    918922 * Convert string s[] to upper case. 
    919923 */ 
    920924 
    921925S toupper(S)(S s) if (isSomeString!S) 
    922926{ 
    923927    alias typeof(s[0]) Char; 
    924928    int changed;