diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-10 15:44:00 -0800 |
commit | 2f8ec03aa4809cec2b0944ca9bf1c7783e11b4ae (patch) | |
tree | 529ac21af6907441041545b76eaaaa13d9e8640e /shared | |
parent | 21208dbbe2608ae45b8c4a50d83e353880dc491f (diff) | |
download | srec-2f8ec03aa4809cec2b0944ca9bf1c7783e11b4ae.tar.gz |
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'shared')
-rw-r--r-- | shared/src/ESR_Locale.c | 95 |
1 files changed, 28 insertions, 67 deletions
diff --git a/shared/src/ESR_Locale.c b/shared/src/ESR_Locale.c index 2fb2680..148eb00 100644 --- a/shared/src/ESR_Locale.c +++ b/shared/src/ESR_Locale.c @@ -11,7 +11,7 @@ * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an 'AS IS' BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * @@ -22,78 +22,39 @@ #include "plog.h" #include "LCHAR.h" -#define LOCALE_COUNT 9 -static LCHAR* localeStringMapping[LOCALE_COUNT+1] = - { - L("ESR_LOCALE_EN_US"), - L("ESR_LOCALE_FR_FR"), - L("ESR_LOCALE_DE_DE"), - L("ESR_LOCALE_EN_GB"), - L("ESR_LOCALE_IT_IT"), - L("ESR_LOCALE_NL_NL"), - L("ESR_LOCALE_PT_PT"), - L("ESR_LOCALE_ES_ES"), - L("ESR_LOCALE_JA_JP"), - L("invalid locale code") /* must remain last element for ESR_locale2str() to function */ - }; - + LCHAR* ESR_locale2str(const ESR_Locale locale) { - if (locale >= LOCALE_COUNT) - return localeStringMapping[LOCALE_COUNT]; - return localeStringMapping[locale]; + switch (locale) { + case ESR_LOCALE_EN_US: return L("ESR_LOCALE_EN_US"); + case ESR_LOCALE_FR_FR: return L("ESR_LOCALE_FR_FR"); + case ESR_LOCALE_DE_DE: return L("ESR_LOCALE_DE_DE"); + case ESR_LOCALE_EN_GB: return L("ESR_LOCALE_EN_GB"); + case ESR_LOCALE_IT_IT: return L("ESR_LOCALE_IT_IT"); + case ESR_LOCALE_NL_NL: return L("ESR_LOCALE_NL_NL"); + case ESR_LOCALE_PT_PT: return L("ESR_LOCALE_PT_PT"); + case ESR_LOCALE_ES_ES: return L("ESR_LOCALE_ES_ES"); + case ESR_LOCALE_JA_JP: return L("ESR_LOCALE_JA_JP"); + } + return L("invalid locale code"); } ESR_ReturnCode ESR_str2locale(const LCHAR* str, ESR_Locale* locale) { - int result; - - if (lstrcasecmp(str, L("EN-US"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_EN_US; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("FR-FR"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_FR_FR; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("DE-DE"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_DE_DE; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("EN-GB"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_EN_GB; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("JA-JP"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_JA_JP; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("PT-PT"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_PT_PT; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("ES-ES"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_ES_ES; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("IT-IT"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_IT_IT; - return ESR_SUCCESS; - } - else if (lstrcasecmp(str, L("NL-NL"), &result) == ESR_SUCCESS && !result) - { - *locale = ESR_LOCALE_NL_NL; + int rtn = 0; + if (!lstrcasecmp(str, L("EN-US"), &rtn) && !rtn) *locale = ESR_LOCALE_EN_US; + else if (!lstrcasecmp(str, L("FR-FR"), &rtn) && !rtn) *locale = ESR_LOCALE_FR_FR; + else if (!lstrcasecmp(str, L("DE-DE"), &rtn) && !rtn) *locale = ESR_LOCALE_DE_DE; + else if (!lstrcasecmp(str, L("EN-GB"), &rtn) && !rtn) *locale = ESR_LOCALE_EN_GB; + else if (!lstrcasecmp(str, L("IT-IT"), &rtn) && !rtn) *locale = ESR_LOCALE_IT_IT; + else if (!lstrcasecmp(str, L("NL-NL"), &rtn) && !rtn) *locale = ESR_LOCALE_NL_NL; + else if (!lstrcasecmp(str, L("PT-PT"), &rtn) && !rtn) *locale = ESR_LOCALE_PT_PT; + else if (!lstrcasecmp(str, L("ES-ES"), &rtn) && !rtn) *locale = ESR_LOCALE_ES_ES; + else if (!lstrcasecmp(str, L("JA-JP"), &rtn) && !rtn) *locale = ESR_LOCALE_JA_JP; + else { + PLogError(L("no locale defined for %s"), str); + return ESR_INVALID_ARGUMENT; + } return ESR_SUCCESS; - } - PLogError(L("no locale defined for %s"), str); - return ESR_INVALID_ARGUMENT; } |