Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 09, 2010 [Issue 4608] New: std.string.chomp documentation mismatch implementation | ||||
---|---|---|---|---|
| ||||
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@puremagic.com ReportedBy: simen.endsjo@pandavre.com --- Comment #0 from simendsjo <simen.endsjo@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: ------- |
January 09, 2011 [Issue 4608] std.string.chomp documentation mismatch implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | http://d.puremagic.com/issues/show_bug.cgi?id=4608 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei@metalanguage.com AssignedTo|nobody@puremagic.com |andrei@metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 06, 2012 [Issue 4608] std.string.chomp documentation mismatch implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | http://d.puremagic.com/issues/show_bug.cgi?id=4608 Yao Gomez <yao.gomez@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yao.gomez@gmail.com --- Comment #1 from Yao Gomez <yao.gomez@gmail.com> 2012-02-05 21:18:12 PST --- DMD 2.058HEAD. With this example, all the assertions fail. ------ import std.string, std.stdio, std.conv; void main() { auto foo = "foobar\n\r\n\n"; auto baz = chomp(foo); auto bar = chomp(foo, ""); auto soz = chomp(foo, "\n\r"); assert( baz == "foobar"); assert( bar == "foobar"); assert( soz == "foobar"); } ------ -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 22, 2012 [Issue 4608] std.string.chomp documentation mismatch implementation | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | http://d.puremagic.com/issues/show_bug.cgi?id=4608 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED CC| |andrej.mitrovich@gmail.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation