about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/dirname.c4
-rw-r--r--misc/tst-dirname.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/misc/dirname.c b/misc/dirname.c
index b1a0e0c2ac..94ab1c085f 100644
--- a/misc/dirname.c
+++ b/misc/dirname.c
@@ -1,5 +1,5 @@
 /* dirname - return directory part of PATH.
-   Copyright (C) 1996, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -66,6 +66,8 @@ dirname (char *path)
 	  else
 	    last_slash = path + 1;
 	}
+      else
+	last_slash = runp;
 
       last_slash[0] = '\0';
     }
diff --git a/misc/tst-dirname.c b/misc/tst-dirname.c
index 0808b839df..a428786db6 100644
--- a/misc/tst-dirname.c
+++ b/misc/tst-dirname.c
@@ -1,5 +1,5 @@
 /* Test program for dirname function a la XPG.
-   Copyright (C) 1996, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -62,5 +62,9 @@ main (void)
   result |= test ("//usr//", "//");
   result |= test ("//", "//");
 
+  /* Other Unix implementations behave like this.  */
+  result |= test ("x///y", "x");
+  result |= test ("x/////y", "x");
+
   return result != 0;
 }