Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2586

Show
Ignore:
Timestamp:
09/29/07 13:45:43 (1 year ago)
Author:
kris
Message:

fixes #649

added short-circuit to avoid appending multiple nulls

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/stdc/stringz.d

    r2465 r2586  
    2020{ 
    2121        if (s.ptr) 
    22             s ~= '\0'; 
     22            if (! (s.length && s[$-1] is 0)) 
     23                   s ~= '\0'; 
    2324        return s.ptr; 
    2425} 
     
    4041{ 
    4142        if (s.ptr) 
    42             s ~= "\0"w; 
     43            if (! (s.length && s[$-1] is 0)) 
     44                   s ~= "\0"w; 
    4345        return s.ptr; 
    4446} 
     
    8385        assert(strlenz(p) == 2); 
    8486 
    85         char[] test = ""; 
     87        char[] test = "\0"; 
    8688        p = toUtf8z(test); 
    8789        assert(*p == 0); 
     90        assert(p == test.ptr); 
    8891        } 
    8992}