From 65a1183e219840e647678b1c9d4913aeabe0265a Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Sat, 31 Mar 2001 00:49:03 +0000 Subject: [PATCH] ICU-882 Forgot to remove the static fields for deprecation and change sep -> #define SEP_UCHAR and change sepchar -> #define SEP_CHAR X-SVN-Rev: 4419 --- icu4c/source/common/locid.cpp | 79 +++++++++++++++++------------------ 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/icu4c/source/common/locid.cpp b/icu4c/source/common/locid.cpp index c800b68a03..5e334ab856 100644 --- a/icu4c/source/common/locid.cpp +++ b/icu4c/source/common/locid.cpp @@ -47,11 +47,12 @@ Locale Locale::fgDefaultLocale; Locale* Locale::localeList = NULL; int32_t Locale::localeListCount; +#ifdef ICU_LOCID_USE_DEPRECATES UnicodeString* Locale::isoLanguages = NULL; int32_t Locale::isoLanguagesCount; UnicodeString* Locale::isoCountries = NULL;; int32_t Locale::isoCountriesCount; - +#endif @@ -92,7 +93,7 @@ const Locale Locale::CANADA_FRENCH("fr", "CA"); * into a single encoded String, and lazy evaluate the table from it.) */ UHashtable* Locale::ctry2LangMapping = 0; -const UnicodeString Locale::compressedCtry2LangMapping = UnicodeString( +const UnicodeString Locale::compressedCtry2LangMapping( "ADfresAEarenAFpsAGenAIrnALsqAMhyruANnlenAOptAResASensmATdeAUenAWnlenAZazhyru" "BAsrshhrslmksqBBenBDbnhibhenBEfrnldeBFfrBGbgtrBHarenBIrnfrswBJfrBMenBNmsenzh" "BOesayquBRptBSenBTdzenneBVnoBWentnBYberuBZenesCAenfrCCenCFfrsgCGfrCHfrdeitrm" @@ -118,8 +119,10 @@ const UnicodeString Locale::compressedCtry2LangMapping = UnicodeString( #define BUFFER_SIZE 50 /*Character separating the posix id fields*/ -const UChar sep = 0x005F; // '_' -const char sepchar = '_'; // In the platform codepage. +// '_' +#define SEP_UCHAR 0x005F +// In the platform codepage. +#define SEP_CHAR '_' Locale::~Locale() { @@ -174,14 +177,14 @@ Locale::Locale( const char * newLanguage, if ( newVariant != NULL ) { // remove leading _'s - while(newVariant[0] == sepchar) + while(newVariant[0] == SEP_CHAR) { newVariant++; } // remove trailing _'s vsize = (int32_t)uprv_strlen(newVariant); - while( (vsize>1) && (newVariant[vsize-1] == sepchar) ) + while( (vsize>1) && (newVariant[vsize-1] == SEP_CHAR) ) { vsize--; } @@ -228,19 +231,18 @@ Locale::Locale( const char * newLanguage, if ( ( vsize != 0 ) || (csize != 0) ) // at least: __v { // ^ - *p++ = sepchar; + *p++ = SEP_CHAR; } if ( csize != 0 ) { - uprv_strcpy(p, newCountry); p += csize; } if ( vsize != 0) { - *p++ = sepchar; // at least: __v + *p++ = SEP_CHAR; // at least: __v uprv_strncpy(p, newVariant, vsize); // Must use strncpy because p += vsize; // of trimming (above). @@ -373,7 +375,8 @@ Locale& Locale::operator=(const Locale& other) { /*In case the assigner has some of its data on the heap * we need to do the same*/ - if (fullName != fullNameBuffer) delete []fullName; + if (fullName != fullNameBuffer) + delete []fullName; fullName = new char[(uprv_strlen(other.fullName)+1)]; } uprv_strcpy(fullName, other.fullName); @@ -428,10 +431,10 @@ Locale Locale::createFromName (const char *name) { UErrorCode status = U_ZERO_ERROR; - char stack[128]; + char stack[ULOC_FULLNAME_CAPACITY]; char *heap = NULL; char *buf = stack; - int32_t buflen = 128; + int32_t buflen = ULOC_FULLNAME_CAPACITY; int32_t namelen = (int32_t)uprv_strlen(name); /* for some reason */ @@ -469,6 +472,25 @@ Locale::getVariant() const return variant; } +const char * +Locale::getName() const +{ + return fullName; +} + +const char * +Locale::getISO3Language() const +{ + return uloc_getISO3Language(fullName); +} + + +const char * +Locale::getISO3Country() const +{ + return uloc_getISO3Country(fullName); +} + #ifdef ICU_LOCID_USE_DEPRECATES UnicodeString& Locale::getLanguage(UnicodeString& lang) const @@ -497,28 +519,7 @@ Locale::getName(UnicodeString& name) const name = UnicodeString(fullName,""); return name; } -#endif -const char * -Locale::getName() const -{ - return fullName; -} - -const char * -Locale::getISO3Language() const -{ - return uloc_getISO3Language(fullName); -} - - -const char * -Locale::getISO3Country() const -{ - return uloc_getISO3Country(fullName); -} - -#ifdef ICU_LOCID_USE_DEPRECATES UnicodeString& Locale::getISO3Language(UnicodeString& lang, UErrorCode& status) const { @@ -943,7 +944,7 @@ Locale::Locale( const UnicodeString& newLanguage, char myLocaleID[ULOC_FULLNAME_CAPACITY]; if(newCountry.length()>0) { - togo += sep; + togo += SEP_UCHAR; togo += newCountry; } @@ -965,7 +966,7 @@ Locale::Locale( const UnicodeString& newLanguage, if (newCountry.length() > 0 || newVariantCopy.length() > 0 ) { - togo += sep; + togo += SEP_UCHAR; togo += newCountry; } @@ -974,11 +975,11 @@ Locale::Locale( const UnicodeString& newLanguage, { int i = 0; //We need to trim variant codes : (_*)$var(_*) --> $var - while ((i