Kaydet (Commit) 25d88d2b authored tarafından Tor Lillqvist's avatar Tor Lillqvist

More hacking on --with-locales

Propagate the restriction of locales into <config_locales.h>. Note that in the
normal case, with no locale restrictions, all the WITH_LOCALE_xx macros are
zero anyway, but WITH_LOCALE_ALL is one.

Restrict which character encodings are handled in
sal/textencsal/textenc/tables.cxx based on the WITH_LOCALE_ macros. (Don't
simply always do it for iOS.)

Massage the affected unit tests to not crash when only partial character
encoding information is present.

Change-Id: Ie2c882c262ebd0d2b37dde66b8fe3c3e2570da14
üst 95711f5b
/* Configuration of restriction on supported locales, by the
* --with-locales option.
*
* (Note that this is totally unrelated to what UI language(s) were
* configured with the --with-lang option.)
*
* Normally, especially for desktop OSes, LibreOffice is built to
* support all the locales and character encodings that it has code
* (data) for in the source code. By using the --with-locales
* configure switch, this can be restricted.
*
* This file defines feature test macros for those languages for which
* at least one locale is to be supported. In some cases, a feature
* test macro for a script is provided in addition or instead.
*
* Only languages for which there exists separate code and/or data in
* the source code need to be mentioned here.
*/
#ifndef CONFIG_LOCALES_H
#define CONFIG_LOCALES_H
/* In the normal case WITH_LOCALE_ALL is one and this
* overrides the others which are zero.
*/
#define WITH_LOCALE_ALL 0
/* When --with-locales was used, WITH_LOCALE_ALL is zero and some of
* these are one.
*/
#define WITH_LOCALE_ca 0
#define WITH_LOCALE_dz 0
#define WITH_LOCALE_el 0
#define WITH_LOCALE_he 0
#define WITH_LOCALE_hi 0
#define WITH_LOCALE_hr 0
#define WITH_LOCALE_hu 0
#define WITH_LOCALE_is 0
#define WITH_LOCALE_ja 0
#define WITH_LOCALE_ko 0
#define WITH_LOCALE_ku 0
#define WITH_LOCALE_ln 0
#define WITH_LOCALE_my 0
#define WITH_LOCALE_ne 0
#define WITH_LOCALE_ro 0
#define WITH_LOCALE_ru 0
#define WITH_LOCALE_sid 0
#define WITH_LOCALE_th 0
#define WITH_LOCALE_tr 0
#define WITH_LOCALE_uk 0
#define WITH_LOCALE_zh 0
#define WITH_LOCALE_FOR_SCRIPT_Cyrl 0
#define WITH_LOCALE_FOR_SCRIPT_Deva 0
#endif
......@@ -12201,6 +12201,26 @@ AC_SUBST(WITH_POOR_HELP_LOCALIZATIONS)
if test -n "$with_locales"; then
WITH_LOCALES="$with_locales"
just_langs="`echo $WITH_LOCALES | sed -e 's/_[A-Z]*//g'`"
# Only languages and scripts for which we actually have ifdefs need to be handled. Also see
# config_host/config_locales.h.in
for locale in $WITH_LOCALES; do
lang=${locale%_*}
AC_DEFINE_UNQUOTED(WITH_LOCALE_$lang, 1)
case $lang in
hi|mr*ne)
AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Deva)
;;
bg|ru)
AC_DEFINE(WITH_LOCALE_FOR_SCRIPT_Cyrl)
;;
esac
done
else
AC_DEFINE(WITH_LOCALE_ALL)
fi
AC_SUBST(WITH_LOCALES)
......@@ -12759,6 +12779,7 @@ AC_CONFIG_HEADERS([config_host/config_gcc.h])
AC_CONFIG_HEADERS([config_host/config_global.h])
AC_CONFIG_HEADERS([config_host/config_graphite.h])
AC_CONFIG_HEADERS([config_host/config_lgpl.h])
AC_CONFIG_HEADERS([config_host/config_locales.h])
AC_CONFIG_HEADERS([config_host/config_mpl.h])
AC_CONFIG_HEADERS([config_host/config_orcus.h])
AC_CONFIG_HEADERS([config_host/config_kde4.h])
......
......@@ -55,20 +55,10 @@ $(i18npool_CODIR)/collator_%.cxx : \
$(call gb_Helper_abbreviate_dirs, \
$(call gb_Helper_execute,gencoll_rule) $< $@ $*)
define i18npool_echo_one_lang
echo '#define LOCAL_RULE_$(1)' >>$@
endef
$(i18npool_CODIR)/lrl_include.hxx : \
$(SRCDIR)/i18npool/source/collator/data | $(i18npool_CODIR)/.dir
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),ECH,1)
echo '#define LOCAL_RULE_LANGS "$(sort $(foreach txt,$(i18npool_COTXTS), \
$(firstword $(subst _, ,$(txt)))))"' > $@
ifeq ($(WITH_LOCALES),)
echo '#define LOCAL_RULE_ALL' >>$@
else
$(foreach txt,$(i18npool_COTXTS),$(call i18npool_echo_one_lang,$(subst .txt,,$(txt))))
endif
# vim: set noet sw=4 ts=4:
......@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_locales.h>
// generated list of languages
#include "lrl_include.hxx"
#include <rtl/ustrbuf.hxx>
......@@ -156,23 +156,23 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang::
#else
if (false) {
;
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_ca_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_CA
} else if ( rLocale.Language == "ca" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_ca_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_dz_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_DZ
} else if ( rLocale.Language == "dz" || rLocale.Language == "bo" ) {
// 'bo' Tibetan uses the same collation rules as 'dz' Dzongkha
if ( rAlgorithm == "charset" )
func = get_collator_data_dz_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_hu
#if WITH_LOCALE_ALL || WITH_LOCALE_HU
} else if ( rLocale.Language == "hu" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_hu_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_ja_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_JA
} else if ( rLocale.Language == "ja" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_ja_charset;
......@@ -181,37 +181,37 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang::
else if ( rAlgorithm == "phonetic (alphanumeric last)" )
func = get_collator_data_ja_phonetic_alphanumeric_last;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_ko_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_KO
} else if ( rLocale.Language == "ko" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_ko_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_ku_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_KU
} else if ( rLocale.Language == "ku" ) {
if ( rAlgorithm == "alphanumeric" )
func = get_collator_data_ku_alphanumeric;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_ln_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_LN
} else if ( rLocale.Language == "ln" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_ln_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_my_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_MY
} else if ( rLocale.Language == "my" ) {
if ( rAlgorithm == "dictionary" )
func = get_collator_data_my_dictionary;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_ne_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_NE
} else if ( rLocale.Language == "ne" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_ne_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_sid_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_SID
} else if ( rLocale.Language == "sid" ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_sid_charset;
#endif
#if defined LOCAL_RULE_ALL || defined LOCAL_RULE_zh_charset
#if WITH_LOCALE_ALL || WITH_LOCALE_ZH
} else if ( rLocale.Language == "zh" && (rLocale.Country == "TW" || rLocale.Country == "HK" || rLocale.Country == "MO") ) {
if ( rAlgorithm == "charset" )
func = get_collator_data_zh_TW_charset;
......
......@@ -54,8 +54,8 @@ $(eval $(call gb_Module_add_check_targets,sal,\
CppunitTest_sal_rtl_oustringbuffer \
CppunitTest_sal_rtl_oustring \
CppunitTest_sal_rtl_textenc \
CppunitTest_sal_rtl_strings \
CppunitTest_sal_rtl_uri \
CppunitTest_sal_rtl_strings \
CppunitTest_sal_rtl_uuid \
CppunitTest_sal_tcwf \
CppunitTest_sal_types \
......
......@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_locales.h>
#include "rtl/strbuf.hxx"
#include "rtl/uri.hxx"
#include "rtl/ustrbuf.hxx"
......@@ -395,6 +397,7 @@ void Test::test_Uri() {
aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_ISO_8859_5)
== aText1));
}
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
{
sal_Unicode const aText1U[] = { ' ', '!', 0x028A, 0xD849, 0xDD13, 0 };
aText1 = rtl::OUString(aText1U);
......@@ -411,7 +414,7 @@ void Test::test_Uri() {
aText2, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_GB_18030)
== aText1));
}
#endif
// Check strict mode:
{
......@@ -434,6 +437,7 @@ void Test::test_Uri() {
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8)
== aText2));
}
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
{
aText1 = rtl::OUString("%81 ");
aText2 = rtl::OUString();
......@@ -472,7 +476,7 @@ void Test::test_Uri() {
aText1, rtl_UriDecodeStrict, RTL_TEXTENCODING_GB_18030)
== aText2));
}
#endif
// Check rtl_UriEncodeStrictKeepEscapes mode:
{
......
......@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <config_locales.h>
#include "sal/config.h"
#include <cassert>
......@@ -158,48 +160,101 @@ extern "C" SAL_DLLPUBLIC_EXPORT ImplTextEncodingData const *
NULL, /* TODO! APPLE_THAI */
&aImplAPPLETURKISHTextEncodingData, /* APPLE_TURKISH */
&aImplAPPLEUKRAINIANTextEncodingData, /* APPLE_UKRAINIAN */
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
&aImplAPPLECHINSIMPTextEncodingData, /* APPLE_CHINSIMP */
&aImplAPPLECHINTRADTextEncodingData, /* APPLE_CHINTRAD */
#else
NULL,
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_ja
&aImplAPPLEJAPANESETextEncodingData, /* APPLE_JAPANESE */
#else
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_ko
&aImplAPPLEKOREANTextEncodingData, /* APPLE_KOREAN */
#else
NULL,
#endif
&aImplMS932TextEncodingData, /* MS_932 */
&aImplMS936TextEncodingData, /* MS_936 */
&aImplMS949TextEncodingData, /* MS_949 */
&aImplMS950TextEncodingData, /* MS_950 */
#if WITH_LOCALE_ALL || WITH_LOCALE_ja
&aImplSJISTextEncodingData, /* SHIFT_JIS */
#else
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
&aImplGB2312TextEncodingData, /* GB_2312 */
&aImplGBT12345TextEncodingData, /* GBT_12345 */
&aImplGBKTextEncodingData, /* GBK */
&aImplBIG5TextEncodingData, /* BIG5 */
#ifndef IOS
#else
NULL,
NULL,
NULL,
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_ja
&aImplEUCJPTextEncodingData, /* EUC_JP */
#else
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
&aImplEUCCNTextEncodingData, /* EUC_CN */
&aImplEucTwTextEncodingData, /* EUC_TW */
#else
NULL,
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_ja
&aImplIso2022JpTextEncodingData, /* ISO_2022_JP */
#else
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
&aImplIso2022CnTextEncodingData, /* ISO_2022_CN */
#else
NULL, /* EUC_JP */
NULL, /* EUC_CN */
NULL, /* EUC_TW */
NULL, /* ISO_2022_JP */
NULL, /* ISO_2022_CN */
NULL,
#endif
&aImplKOI8RTextEncodingData, /* KOI8_R */
&aImplUTF7TextEncodingData, /* UTF7 */
NULL, /* UTF8, see above */
&aImplISO885910TextEncodingData, /* ISO_8859_10 */
&aImplISO885913TextEncodingData, /* ISO_8859_13 */
#if WITH_LOCALE_ALL || WITH_LOCALE_ko
&aImplEUCKRTextEncodingData, /* EUC_KR */
&aImplIso2022KrTextEncodingData, /* ISO_2022_KR */
#else
NULL,
NULL,
#endif
#if WITH_LOCALE_ALL || WITH_LOCALE_ja
&aImplJISX0201TextEncodingData, /* JIS_X_0201 */
&aImplJISX0208TextEncodingData, /* JIS_X_0208 */
&aImplJISX0212TextEncodingData, /* JIS_X_0212 */
#else
NULL,
NULL,
NULL,
#endif
&aImplMS1361TextEncodingData, /* MS_1361 */
#if WITH_LOCALE_ALL || WITH_LOCALE_zh
&aImplGb18030TextEncodingData, /* GB_18030 */
&aImplBig5HkscsTextEncodingData, /* BIG5_HKSCS */
#else
NULL,
NULL,
#endif
&aImplTis620TextEncodingData, /* TIS_620 */
&aImplKoi8UTextEncodingData, /* KOI8_U */
#if WITH_LOCALE_ALL || WITH_LOCALE_FOR_SCRIPT_Deva
&aImplIsciiDevanagariTextEncodingData, /* ISCII_DEVANAGARI */
#else
NULL,
#endif
NULL, /* JAVA_UTF8, see above */
&adobeStandardEncodingData, /* ADOBE_STANDARD */
&adobeSymbolEncodingData, /* ADOBE_SYMBOL */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment