From e4bf711227db798eaef7900f43fee1092dd8747e Mon Sep 17 00:00:00 2001 From: gocha Date: Sun, 22 Jul 2012 09:21:12 +0900 Subject: [PATCH] win32: fix newly introduced bug of S9xBasename. I guess it could provide a wrong result when it processes a string which has both slash and backslash. --- win32/win32.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/win32/win32.cpp b/win32/win32.cpp index 34922807..db4eedfb 100644 --- a/win32/win32.cpp +++ b/win32/win32.cpp @@ -614,10 +614,25 @@ const char *S9xBasename (const char *f) const char *p = f; const char *last = p; const char *slash; + const char *backslash; // search rightmost separator - while ((slash = strchr (p, '/')) != NULL || (slash = strchr (p, '\\')) != NULL) + while (true) { + slash = strchr (p, '/'); + backslash = strchr (p, '\\'); + if (backslash != NULL) + { + if (slash == NULL || slash > backslash) + { + slash = backslash; + } + } + if (slash == NULL) + { + break; + } + p = slash + 1; #ifdef UNICODE