[Issue 4608] New: std.string.chomp documentation mismatch implementation
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 9 14:43:57 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4608
Summary: std.string.chomp documentation mismatch implementation
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: minor
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: simen.endsjo at pandavre.com
--- Comment #0 from simendsjo <simen.endsjo at pandavre.com> 2010-08-09 14:43:53 PDT ---
The documentation says
/*******************************************
* Returns s[] sans trailing delimiter[], if any.
* If delimiter[] is null, removes trailing CR, LF, or CRLF, if any.
*/
The implementation on the other hand returns the input string if delimiter is
null. So either the documentation or the implementation needs to be fixed.
If the implementation should work like the documentation, it could be something
like this:
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;
}
--
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