diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-11-06 14:55:41 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-11-06 14:56:07 +0100 |
commit | 6e02f49a0f0acfcbf2cedd126de25a7bb9643a4b (patch) | |
tree | c49031f5e418357a952a6171c6e7af619de2fa5a /i18npool/source | |
parent | 2254f5022d9e1b1320f9bbd7a9df8292e2dee9f4 (diff) |
Adapting to liblangtag 0.4.0
Change-Id: Ie70a38a1481a280760a435f4809020ed5a327627
Diffstat (limited to 'i18npool/source')
-rw-r--r-- | i18npool/source/languagetag/languagetag.cxx | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx index 8e96d61db320..bc700bd2a4cf 100644 --- a/i18npool/source/languagetag/languagetag.cxx +++ b/i18npool/source/languagetag/languagetag.cxx @@ -285,14 +285,6 @@ bool LanguageTag::canonicalize() const dumper aDumper( &mpImplLangtag); #endif - // g_error_free() mocks about NULL, so ... - struct myerror - { - GError* p; - myerror() : p(NULL) {} - ~myerror() { if (p) g_error_free( p); } - } aError; - getBcp47(); // side effect: have maBcp47 in any case // Checking empty for system locale before having allocated mpImplLangtag // may result in multiple calls of this method because that serves as flag @@ -305,11 +297,16 @@ bool LanguageTag::canonicalize() const } if (!mpImplLangtag) mpImplLangtag = lt_tag_new(); - if (lt_tag_parse( MPLANGTAG, OUStringToOString( maBcp47, RTL_TEXTENCODING_UTF8).getStr(), &aError.p)) + + lt_error_t *pError; + + if (lt_tag_parse( MPLANGTAG, OUStringToOString( maBcp47, RTL_TEXTENCODING_UTF8).getStr(), &pError)) { - gchar* pTag = lt_tag_canonicalize( MPLANGTAG, &aError.p); - SAL_WARN_IF( !pTag || aError.p, "i18npool.langtag", "LanguageTag::canonicalize: could not canonicalize, " << - (aError.p ? aError.p->message : "")); + char* pTag = lt_tag_canonicalize( MPLANGTAG, &pError); +#if 0 + SAL_WARN_IF( !pTag || lt_error_is_set(pError), "i18npool.langtag", "LanguageTag::canonicalize: could not canonicalize, " << + (lt_error_is_set(pError) ? pError->message : "")); +#endif if (pTag) { OUString aOld( maBcp47); @@ -318,26 +315,30 @@ bool LanguageTag::canonicalize() const // removes default script and such. if (maBcp47 != aOld) { - if (!lt_tag_parse( MPLANGTAG, pTag, &aError.p)) + if (!lt_tag_parse( MPLANGTAG, pTag, &pError)) { +#if 0 SAL_WARN( "i18npool.langtag", "LanguageTag::canonicalize: could not reparse, " << - (aError.p ? aError.p->message : "")); - g_free( pTag); + (lt_error_is_set(pError) ? pError->message : "")); +#endif + free( pTag); meIsValid = DECISION_NO; return false; } } - g_free( pTag); + free( pTag); meIsValid = DECISION_YES; return true; } } else { +#if 0 SAL_INFO( "i18npool.langtag", "LanguageTag::canonicalize " << maBcp47 << ": could not parse, " - << (aError.p ? aError.p->message : "")); + << (lt_error_is_set(pError) ? pError->message : "")); +#endif } meIsValid = DECISION_NO; return false; @@ -472,7 +473,7 @@ rtl::OUString LanguageTag::getLanguageFromLangtag() const SAL_WARN_IF( !pLangT, "i18npool.langtag", "LanguageTag::getLanguageFromLangtag: pLangT==NULL"); if (!pLangT) return aLanguage; - const gchar* pLang = lt_lang_get_tag( pLangT); + const char* pLang = lt_lang_get_tag( pLangT); SAL_WARN_IF( !pLang, "i18npool.langtag", "LanguageTag::getLanguageFromLangtag: pLang==NULL"); if (pLang) aLanguage = OUString::createFromAscii( pLang); @@ -491,7 +492,7 @@ rtl::OUString LanguageTag::getScriptFromLangtag() const // pScriptT==NULL is valid for default scripts if (!pScriptT) return aScript; - const gchar* pScript = lt_script_get_tag( pScriptT); + const char* pScript = lt_script_get_tag( pScriptT); SAL_WARN_IF( !pScript, "i18npool.langtag", "LanguageTag::getScriptFromLangtag: pScript==NULL"); if (pScript) aScript = OUString::createFromAscii( pScript); @@ -510,7 +511,7 @@ rtl::OUString LanguageTag::getRegionFromLangtag() const SAL_WARN_IF( !pRegionT, "i18npool.langtag", "LanguageTag::getRegionFromLangtag: pRegionT==NULL"); if (!pRegionT) return aRegion; - const gchar* pRegion = lt_region_get_tag( pRegionT); + const char* pRegion = lt_region_get_tag( pRegionT); SAL_WARN_IF( !pRegion, "i18npool.langtag", "LanguageTag::getRegionFromLangtag: pRegion==NULL"); if (pRegion) aRegion = OUString::createFromAscii( pRegion); |