win32: improve DBCS processing in S9xBasename. This one should process S9xBasename("C:\roms\ソウルブレイダー.smc") correctly.

This commit is contained in:
gocha 2012-07-16 19:03:49 +09:00 committed by OV2
parent b4e78e3d2c
commit a91dfcb39b

View File

@ -611,16 +611,28 @@ void S9xSyncSpeed( void)
const char *S9xBasename (const char *f) const char *S9xBasename (const char *f)
{ {
const char *p; const char *p = f;
if ((p = strrchr (f, '/')) != NULL || (p = strrchr (f, '\\')) != NULL) const char *last = p;
return (p + 1); const char *slash;
#ifdef __DJGPP // search rightmost separator
if (p = _tcsrchr (f, SLASH_CHAR)) while ((slash = strchr (p, '/')) != NULL || (slash = strchr (p, '\\')) != NULL)
return (p + 1); {
p = slash + 1;
#ifdef UNICODE
// update always; UTF-8 doesn't have a problem between ASCII character and multi-byte character.
last = p;
#else
// update if it's not a trailer byte of a double-byte character.
if (CharPrev(f, p) == slash)
{
last = p;
}
#endif #endif
}
return (f); return last;
} }
bool8 S9xReadMousePosition (int which, int &x, int &y, uint32 &buttons) bool8 S9xReadMousePosition (int which, int &x, int &y, uint32 &buttons)