From 20fb555d31802253a723cddf71f59c18c8966168 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Tue, 19 Mar 2002 07:20:29 +0000 Subject: [PATCH] not sure why these didn't land the first time. for my last checkin, bug 107575 sr=jag, r=dougt, a=scc --- intl/locale/src/unix/nsCollationUnix.cpp | 18 ++++++++---------- intl/locale/src/unix/nsCollationUnix.h | 4 ++-- intl/locale/src/unix/nsDateTimeFormatUnix.cpp | 3 ++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/intl/locale/src/unix/nsCollationUnix.cpp b/intl/locale/src/unix/nsCollationUnix.cpp index 392e0420ca45..ac7d2d51e4ae 100644 --- a/intl/locale/src/unix/nsCollationUnix.cpp +++ b/intl/locale/src/unix/nsCollationUnix.cpp @@ -54,18 +54,16 @@ inline void nsCollationUnix::DoSetLocale() { char *locale = setlocale(LC_COLLATE, NULL); - mSavedLocale.AssignWithConversion(locale ? locale : ""); - if (!mSavedLocale.EqualsIgnoreCase(mLocale)) { - (void) setlocale(LC_COLLATE, - NS_LossyConvertUCS2toASCII(Substring(mLocale,0,MAX_LOCALE_LEN)).get()); + mSavedLocale.Assign(locale ? locale : ""); + if (!mSavedLocale.EqualsIgnoreCase(mLocale.get())) { + (void) setlocale(LC_COLLATE, PromiseFlatCString(Substring(mLocale,0,MAX_LOCALE_LEN)).get()); } } inline void nsCollationUnix::DoRestoreLocale() { - if (!mSavedLocale.EqualsIgnoreCase(mLocale)) { - (void) setlocale(LC_COLLATE, - NS_LossyConvertUCS2toASCII(Substring(mSavedLocale,0,MAX_LOCALE_LEN)).get()); + if (!mSavedLocale.EqualsIgnoreCase(mLocale.get())) { + (void) setlocale(LC_COLLATE, PromiseFlatCString(Substring(mSavedLocale,0,MAX_LOCALE_LEN)).get()); } } @@ -113,7 +111,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) mCharset.Assign(NS_LITERAL_STRING("ISO-8859-1")); // default platform locale - mLocale.Assign(NS_LITERAL_STRING("C")); + mLocale.Assign('C'); PRUnichar *aLocaleUnichar = NULL; nsString aCategory; @@ -156,7 +154,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) char platformLocale[kPlatformLocaleLength+1]; res = posixLocale->GetPlatformLocale(&aLocale, platformLocale, kPlatformLocaleLength+1); if (NS_SUCCEEDED(res)) { - mLocale.AssignWithConversion(platformLocale); + mLocale.Assign(platformLocale); } } @@ -174,7 +172,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) #if defined(DEBUG_UNIX_COLLATION) printf("nsCollationUnix::Initialize mLocale = %s\n" "nsCollationUnix::Initialize mCharset = %s\n", - NS_LossyConvertUCS2toASCII(mLocale).get(), + mLocale.get(), NS_LossyConvertUCS2toASCII(mCharset).get()); #endif diff --git a/intl/locale/src/unix/nsCollationUnix.h b/intl/locale/src/unix/nsCollationUnix.h index c5b349ccce1d..cb5f238afad2 100644 --- a/intl/locale/src/unix/nsCollationUnix.h +++ b/intl/locale/src/unix/nsCollationUnix.h @@ -33,8 +33,8 @@ class nsCollationUnix : public nsICollation { protected: nsCollation *mCollation; - nsString mLocale; - nsString mSavedLocale; + nsCString mLocale; + nsCString mSavedLocale; nsString mCharset; PRBool mUseCodePointOrder; diff --git a/intl/locale/src/unix/nsDateTimeFormatUnix.cpp b/intl/locale/src/unix/nsDateTimeFormatUnix.cpp index aff76f52005e..189472a2807e 100644 --- a/intl/locale/src/unix/nsDateTimeFormatUnix.cpp +++ b/intl/locale/src/unix/nsDateTimeFormatUnix.cpp @@ -61,7 +61,8 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale) // use cached info if match with stored locale if (NULL == locale) { - if (mLocale.Length() && mLocale.EqualsIgnoreCase(mAppLocale)) { + if (mLocale.Length() && + mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) { return NS_OK; } }