[Issue 3937] New: os.path.dirname fails on absolute path
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 12 12:45:02 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3937
Summary: os.path.dirname fails on absolute path
Product: D
Version: 2.040
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: ellery-newcomer at utulsa.edu
--- Comment #0 from Ellery Newcomer <ellery-newcomer at utulsa.edu> 2010-03-12 12:45:01 PST ---
According to DDoc,
assert(dirname(dirname("/home/user")) == "");
however, that assert isn't in the unittest, and the actual result is ".".
I would prefer "/" to either result.
suggested fix:
--- path.d (revision 1452)
+++ path.d (working copy)
@@ -359,7 +359,7 @@
* version(Posix)
* {
* assert(dirname("/home/user") == "/home");
- * assert(dirname(dirname("/home/user")) == "");
+ * assert(dirname(dirname("/home/user")) == "/");
* }
* -----
*/
@@ -386,7 +386,7 @@
version(Posix)
{
if (fullname[i - 1] == sep[0])
- { i--;
+ { if(i > 1) i--;
break;
}
}
@@ -401,6 +401,7 @@
version (Posix)
{
assert(dirname("/path/to/file") == "/path/to");
+ assert(dirname(dirname("/home/user")) == "/");
}
else
{
--
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