std.string.chomp error
simendsjo
simen.endsjo at pandavre.com
Mon Aug 9 09:58:36 PDT 2010
The documentation says
/*******************************************
* Returns s[] sans trailing delimiter[], if any.
* If delimiter[] is null, removes trailing CR, LF, or CRLF, if any.
*/
To adhere to the documentation, chomp must be changed from:
C[] chomp(C, C1)(C[] s, in C1[] delimiter)
{
if (endsWith(s, delimiter))
{
return s[0 .. $ - delimiter.length];
}
return s;
}
to:
C[] chomp(C, C1)(C[] s, in C1[] delimiter)
{
if (delimiter == null)
return chomp(s);
else if (endsWith(s, delimiter))
return s[0 .. $ - delimiter.length];
else
return s;
}
More information about the Digitalmars-d-learn
mailing list