From fc234c55f3890b0c3ecfa836033c0acf59a54834 Mon Sep 17 00:00:00 2001 From: "erik%netscape.com" Date: Thu, 1 Mar 2001 01:01:10 +0000 Subject: [PATCH] checkin for bstell@netscape.com: bug 61108, r=ftang@netscape.com, sr=brendan@mozilla.org we now store both the XP and Unix platform specific local the the platform locale is under ##PLATFORM eg: save the XP locale under NSILOCALE_COLLATE and save the platform locale under NSILOCALE_COLLATE##PLATFORM --- intl/locale/src/unix/nsCollationUnix.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/intl/locale/src/unix/nsCollationUnix.cpp b/intl/locale/src/unix/nsCollationUnix.cpp index 73b6ff2d5bf5..231e2bb584e8 100644 --- a/intl/locale/src/unix/nsCollationUnix.cpp +++ b/intl/locale/src/unix/nsCollationUnix.cpp @@ -49,16 +49,16 @@ inline void nsCollationUnix::DoSetLocale() char *locale = setlocale(LC_COLLATE, NULL); mSavedLocale.AssignWithConversion(locale ? locale : ""); if (!mSavedLocale.EqualsIgnoreCase(mLocale)) { - char newLocale[128]; - (void) setlocale(LC_COLLATE, mLocale.ToCString(newLocale, 128)); + char newLocale[MAX_LOCALE_LEN+1]; + (void) setlocale(LC_COLLATE, mLocale.ToCString(newLocale, sizeof(newLocale))); } } inline void nsCollationUnix::DoRestoreLocale() { if (!mSavedLocale.EqualsIgnoreCase(mLocale)) { - char oldLocale[128]; - (void) setlocale(LC_COLLATE, mSavedLocale.ToCString(oldLocale, 128)); + char oldLocale[MAX_LOCALE_LEN+1]; + (void) setlocale(LC_COLLATE, mSavedLocale.ToCString(oldLocale, sizeof(oldLocale))); } } @@ -106,7 +106,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) PRUnichar *aLocaleUnichar = NULL; nsString aCategory; - aCategory.AssignWithConversion("NSILOCALE_COLLATE"); + aCategory.Assign(NS_LITERAL_STRING("NSILOCALE_COLLATE##PLATFORM")); // get locale string, use app default if no locale specified if (locale == nsnull) { @@ -116,12 +116,14 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) res = localeService->GetApplicationLocale(&appLocale); if (NS_SUCCEEDED(res)) { res = appLocale->GetCategory(aCategory.GetUnicode(), &aLocaleUnichar); + NS_ASSERTION(NS_SUCCEEDED(res), "failed to get app locale info"); appLocale->Release(); } } } else { res = locale->GetCategory(aCategory.GetUnicode(), &aLocaleUnichar); + NS_ASSERTION(NS_SUCCEEDED(res), "failed to get locale info"); } // Get platform locale and charset name from locale, if available @@ -133,7 +135,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) } // keep the same behavior as 4.x as well as avoiding Linux collation key problem - if (aLocale.EqualsIgnoreCase("en-US")) { + if (aLocale.EqualsIgnoreCase("en_US")) { // note: locale is in platform format aLocale.AssignWithConversion("C"); }