www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3937] New: os.path.dirname fails on absolute path

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu



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: -------
Mar 12 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3937


Shin Fujishiro <rsinfu gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



---
Fixed in svn r1692.  The fix will be included in release 2.048.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 23 2010