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