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.

This commit is contained in:
gocha 2012-07-22 09:21:12 +09:00 committed by OV2
parent a91dfcb39b
commit e4bf711227
1 changed files with 16 additions and 1 deletions

View File

@ -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