From 217f553161a71f7dd22dca379c70ac9f96bb9827 Mon Sep 17 00:00:00 2001 From: "mkaply%us.ibm.com" Date: Wed, 7 Feb 2001 04:32:24 +0000 Subject: [PATCH] r=dougt, a=blizzard OS/2 only code to handle DBCS properly in nsFileSpec --- xpcom/io/nsFileSpec.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xpcom/io/nsFileSpec.cpp b/xpcom/io/nsFileSpec.cpp index 3af5c14948a..4a2ca07f723 100644 --- a/xpcom/io/nsFileSpec.cpp +++ b/xpcom/io/nsFileSpec.cpp @@ -47,6 +47,10 @@ #include #endif +#ifdef XP_OS2 +extern unsigned char* _mbsrchr( const unsigned char*, int); +#endif + #ifdef XP_MAC #include #include @@ -318,8 +322,7 @@ void nsSimpleCharString::LeafReplace(char inSeparator, const char* inLeafName) return; } char* chars = mData->mString; -#if defined(XP_WIN) - // XXX OS/2 should use strrchr() of DBCS verison, too +#if defined(XP_WIN) || defined(XP_OS2) char* lastSeparator = (char*) _mbsrchr((const unsigned char*) chars, inSeparator); #else char* lastSeparator = strrchr(chars, inSeparator); @@ -331,8 +334,7 @@ void nsSimpleCharString::LeafReplace(char inSeparator, const char* inLeafName) char savedCh = *lastSeparator; char *savedLastSeparator = lastSeparator; *lastSeparator = '\0'; -#if defined(XP_WIN) - // XXX OS/2 should use strrchr() of DBCS verison, too +#if defined(XP_WIN) || defined(XP_OS2) lastSeparator = (char*) _mbsrchr((const unsigned char*) chars, inSeparator); #else lastSeparator = strrchr(chars, inSeparator); @@ -371,7 +373,7 @@ char* nsSimpleCharString::GetLeaf(char inSeparator) const return nsnull; char* chars = mData->mString; -#if defined(XP_WIN) +#if defined(XP_WIN) || defined(XP_OS2) const char* lastSeparator = (const char*) _mbsrchr((const unsigned char *) chars, inSeparator); #else const char* lastSeparator = strrchr(chars, inSeparator); @@ -388,7 +390,7 @@ char* nsSimpleCharString::GetLeaf(char inSeparator) const // So now, separator was the last character. Poke in a null instead. *(char*)lastSeparator = '\0'; // Should use const_cast, but Unix has old compiler. -#if defined(XP_WIN) +#if defined(XP_WIN) || defined(XP_OS2) leafPointer = (const char*) _mbsrchr((const unsigned char *) chars, inSeparator); #else leafPointer = strrchr(chars, inSeparator);