]> granicus.if.org Git - php/commitdiff
Fixed bug #24340 (basename failure win32 with containing both \ and /)
authorIlia Alshanetsky <iliaa@php.net>
Sun, 29 Jun 2003 15:36:10 +0000 (15:36 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 29 Jun 2003 15:36:10 +0000 (15:36 +0000)
ext/standard/string.c

index 80897aa9594db828eb497c90dddb21b920e333e1..c8310fcde200bba0e3372c541fd55f224e8f5daa 100644 (file)
@@ -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);