PHP 4.0 Bug #7873: Dirname inconsistency
| From: | trifid at redigy dot cz | Date: | Sat, 18 Nov 2000 16:39:36 +0000 |
| Subject: | PHP 4.0 Bug #7873: Dirname inconsistency | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-38470@lists.php.net to get a copy of this message | ||
From: trifid@redigy.cz
Operating system: Linux 2.2.16/glibc 2.1
PHP version: 4.0.3pl1
PHP Bug Type: *Function Specific
Bug description: Dirname inconsistency
The last change in ext/standard/string.c brought very bad inconsistency into
dirname behaviour:
echo dirname("/foo/bar/")."/foobar"; => /foo/foobar
echo dirname("/foo/")."/foobar"; => //foobar
the function should everytime return a path with or without a slash at the end,
but always the same.
I created a very simple patch that will stop returning a slash at the end in any
case:
--- string.c.orig Sat Nov 18 17:00:28 2000
+++ string.c Sat Nov 18 17:04:53 2000
@@ -714,8 +714,7 @@
}
if (end < path) {
/* The path only contained slashes */
- path[0] = DEFAULT_SLASH;
- path[1] = '\0';
+ path[0] = '\0';
return;
}
@@ -735,8 +734,7 @@
end--;
}
if (end < path) {
- path[0] = DEFAULT_SLASH;
- path[1] = '\0';
+ path[0] = '\0';
return;
}
*(end+1) = '\0';
--
Edit Bug report at: http://bugs.php.net/?id=7873&edit=1