Re: cvs: php4 /ext/standard string.c
| From: | Jani Taskinen | Date: | Tue, 29 Apr 2003 14:30:42 +0000 |
| Subject: | Re: cvs: php4 /ext/standard string.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-20585@lists.php.net to get a copy of this message | ||
You can MFH this. It's bug fix after all..?
--Jani
On Tue, 29 Apr 2003, Wez Furlong wrote:
>wez Tue Apr 29 09:35:48 2003 EDT
>
> Modified files:
> /php4/ext/standard string.c
> Log:
> Fix dirname() under win32.
> The calculated length would be off-by-two under windows, which resulted in bogus dirnames.
>
>Index: php4/ext/standard/string.c
>diff -u php4/ext/standard/string.c:1.375 php4/ext/standard/string.c:1.376
>--- php4/ext/standard/string.c:1.375 Tue Apr 15 21:07:03 2003
>+++ php4/ext/standard/string.c Tue Apr 29 09:35:48 2003
>@@ -18,7 +18,7 @@
> +----------------------------------------------------------------------+
> */
>
>-/* $Id: string.c,v 1.375 2003/04/16 01:07:03 iliaa Exp $ */
>+/* $Id: string.c,v 1.376 2003/04/29 13:35:48 wez Exp $ */
>
> /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
>
>@@ -1145,6 +1145,7 @@
> PHPAPI size_t php_dirname(char *path, size_t len)
> {
> register char *end = path + len - 1;
>+ unsigned int len_adjust = 0;
>
> #ifdef PHP_WIN32
> /* Note that on Win32 CWD is per drive (heritage from CP/M).
>@@ -1153,6 +1154,7 @@
> if ((2 <= len) && isalpha((int)((unsigned char *)path)[0]) &&
> (':' == path[1])) {
> /* Skip over the drive spec (if any) so as not to change */
> path += 2;
>+ len_adjust += 2;
> if (2 == len) {
> /* Return "c:" on Win32 for dirname("c:").
> * It would be more consistent to return "c:."
>@@ -1176,7 +1178,7 @@
> /* The path only contained slashes */
> path[0] = DEFAULT_SLASH;
> path[1] = '\0';
>- return 1;
>+ return 1 + len_adjust;
> }
>
> /* Strip filename */
>@@ -1187,7 +1189,7 @@
> /* No slash found, therefore return '.' */
> path[0] = '.';
> path[1] = '\0';
>- return 1;
>+ return 1 + len_adjust;
> }
>
> /* Strip slashes which came before the file name */
>@@ -1197,11 +1199,11 @@
> if (end < path) {
> path[0] = DEFAULT_SLASH;
> path[1] = '\0';
>- return 1;
>+ return 1 + len_adjust;
> }
> *(end+1) = '\0';
>
>- return (size_t)(end + 1 - path);
>+ return (size_t)(end + 1 - path) + len_adjust;
> }
> /* }}} */
>
>
>
>
>
--
<- For Sale! ->