stas Tue Feb 12 00:21:15 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/standard string.c Log: [DOC] Add compile-time __DIR__ constant which implements dirname(__FILE__) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.69.2.15&r2=1.445.2.14.2.69.2.16&diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.445.2.14.2.69.2.15 php-src/ext/standard/string.c:1.445.2.14.2.69.2.16 --- php-src/ext/standard/string.c:1.445.2.14.2.69.2.15 Sun Feb 3 14:30:25 2008 +++ php-src/ext/standard/string.c Tue Feb 12 00:21:15 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.445.2.14.2.69.2.15 2008/02/03 14:30:25 felipe Exp $ */ +/* $Id: string.c,v 1.445.2.14.2.69.2.16 2008/02/12 00:21:15 stas Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -1444,94 +1444,7 @@ Returns directory name component of path */ 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). - * This means dirname("c:foo") maps to "c:." or "c:" - which means CWD on C: drive. - */ - 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:." - * but that would require making the string *longer*. - */ - return len; - } - } -#elif defined(NETWARE) - /* - * Find the first occurence of : from the left - * move the path pointer to the position just after : - * increment the len_adjust to the length of path till colon character(inclusive) - * If there is no character beyond : simple return len - */ - char *colonpos = NULL; - colonpos = strchr(path, ':'); - if(colonpos != NULL) { - len_adjust = ((colonpos - path) + 1); - path += len_adjust; - if(len_adjust == len) { - return len; - } - } -#endif - - if (len == 0) { - /* Illegal use of this function */ - return 0; - } - - /* Strip trailing slashes */ - while (end >= path && IS_SLASH_P(end)) { - end--; - } - if (end < path) { - /* The path only contained slashes */ - path[0] = DEFAULT_SLASH; - path[1] = '\0'; - return 1 + len_adjust; - } - - /* Strip filename */ - while (end >= path && !IS_SLASH_P(end)) { - end--; - } - if (end < path) { - /* No slash found, therefore return '.' */ -#ifdef NETWARE - if(len_adjust == 0) { - path[0] = '.'; - path[1] = '\0'; - return 1; //only one character - } - else { - path[0] = '\0'; - return len_adjust; - } -#else - path[0] = '.'; - path[1] = '\0'; - return 1 + len_adjust; -#endif - } - - /* Strip slashes which came before the file name */ - while (end >= path && IS_SLASH_P(end)) { - end--; - } - if (end < path) { - path[0] = DEFAULT_SLASH; - path[1] = '\0'; - return 1 + len_adjust; - } - *(end+1) = '\0'; - - return (size_t)(end + 1 - path) + len_adjust; + return zend_dirname(path, len); } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php