From: Ilia Alshanetsky Date: Sun, 29 Jun 2003 15:36:10 +0000 (+0000) Subject: Fixed bug #24340 (basename failure win32 with containing both \ and /) X-Git-Tag: php-4.3.3RC2~222 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96d4171df7ec91b0626d328d23044ce0c09edb1a;p=php Fixed bug #24340 (basename failure win32 with containing both \ and /) --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 80897aa959..c8310fcde2 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1102,11 +1102,17 @@ PHPAPI char *php_basename(char *s, size_t len, char *suffix, size_t sufflen) p = c + 1; /* Save pointer to overwritten char */ } - if ((c = strrchr(s, '/')) #ifdef PHP_WIN32 - || ((c = strrchr(s, '\\')) && !IsDBCSLeadByte(*(c-1))) + if ((c = strrchr(s, '/')) || ((c = strrchr(s, '\\')) && !IsDBCSLeadByte(*(c-1)))) { + if (*c == '/') { + char *c2 = strrchr(s, '\\'); + if (c2 && !IsDBCSLeadByte(*(c2-1)) && c2 > c) { + c = c2; + } + } +#else + if ((c = strrchr(s, '/'))) { #endif - ) { ret = estrdup(c + 1); } else { ret = estrdup(s);