felipe Sun, 12 Jun 2011 15:15:44 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=312104
Log: - Restore basename in filename on non Windows OS Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c U php/php-src/branches/PHP_5_4/main/rfc1867.c U php/php-src/trunk/ext/mbstring/mbstring.c U php/php-src/trunk/main/rfc1867.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c =================================================================== --- php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c 2011-06-12 15:14:18 UTC (rev 312103) +++ php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c 2011-06-12 15:15:44 UTC (rev 312104) @@ -1146,7 +1146,7 @@ static char *php_mb_rfc1867_basename(const zend_encoding *encoding, char *filename TSRMLS_DC) /* {{{ */ { - char *s, *tmp; + char *s, *s2, *tmp; const size_t filename_len = strlen(filename); /* The \ check should technically be needed for win32 systems only where @@ -1155,11 +1155,18 @@ * the user does basename() they get a bogus file name. Until IE's user base drops * to nill or problem is fixed this code must remain enabled for all systems. */ s = php_mb_safe_strrchr_ex(filename, '\\', filename_len, (const mbfl_encoding *)encoding); - if ((tmp = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding)) > s) { - s = tmp; - } - if (s) { - return s + 1; + s2 = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding); + + if (s && s2) { + if (s > s2) { + return ++s; + } else { + return ++s2; + } + } else if (s) { + return ++s; + } else if (s2) { + return ++s2; } else { return filename; } Modified: php/php-src/branches/PHP_5_4/main/rfc1867.c =================================================================== --- php/php-src/branches/PHP_5_4/main/rfc1867.c 2011-06-12 15:14:18 UTC (rev 312103) +++ php/php-src/branches/PHP_5_4/main/rfc1867.c 2011-06-12 15:15:44 UTC (rev 312104) @@ -555,17 +555,21 @@ static char *php_ap_basename(const zend_encoding *encoding, char *path TSRMLS_DC) { char *s = strrchr(path, '\\'); - if (s) { - char *tmp = strrchr(path, '/'); - if (tmp && tmp > s) { - s = tmp + 1; + char *s2 = strrchr(path, '/'); + + if (s && s2) { + if (s > s2) { + ++s; } else { - s++; + s = ++s2; } - } else { - s = path; + return s; + } else if (s) { + return ++s; + } else if (s2) { + return ++s2; } - return s; + return path; } /* Modified: php/php-src/trunk/ext/mbstring/mbstring.c =================================================================== --- php/php-src/trunk/ext/mbstring/mbstring.c 2011-06-12 15:14:18 UTC (rev 312103) +++ php/php-src/trunk/ext/mbstring/mbstring.c 2011-06-12 15:15:44 UTC (rev 312104) @@ -1146,7 +1146,7 @@ static char *php_mb_rfc1867_basename(const zend_encoding *encoding, char *filename TSRMLS_DC) /* {{{ */ { - char *s, *tmp; + char *s, *s2, *tmp; const size_t filename_len = strlen(filename); /* The \ check should technically be needed for win32 systems only where @@ -1155,11 +1155,18 @@ * the user does basename() they get a bogus file name. Until IE's user base drops * to nill or problem is fixed this code must remain enabled for all systems. */ s = php_mb_safe_strrchr_ex(filename, '\\', filename_len, (const mbfl_encoding *)encoding); - if ((tmp = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding)) > s) { - s = tmp; - } - if (s) { - return s + 1; + s2 = php_mb_safe_strrchr_ex(filename, '/', filename_len, (const mbfl_encoding *)encoding); + + if (s && s2) { + if (s > s2) { + return ++s; + } else { + return ++s2; + } + } else if (s) { + return ++s; + } else if (s2) { + return ++s2; } else { return filename; } Modified: php/php-src/trunk/main/rfc1867.c =================================================================== --- php/php-src/trunk/main/rfc1867.c 2011-06-12 15:14:18 UTC (rev 312103) +++ php/php-src/trunk/main/rfc1867.c 2011-06-12 15:15:44 UTC (rev 312104) @@ -555,17 +555,21 @@ static char *php_ap_basename(const zend_encoding *encoding, char *path TSRMLS_DC) { char *s = strrchr(path, '\\'); - if (s) { - char *tmp = strrchr(path, '/'); - if (tmp && tmp > s) { - s = tmp + 1; + char *s2 = strrchr(path, '/'); + + if (s && s2) { + if (s > s2) { + ++s; } else { - s++; + s = ++s2; } - } else { - s = path; + return s; + } else if (s) { + return ++s; + } else if (s2) { + return ++s2; } - return s; + return path; } /*
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php