From 69fac508c386f660be4428a1e58da30ec0acd9a1 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 9 Aug 2015 12:33:27 +0000 Subject: [PATCH] (svn r27367) -Codechange: make a distinction between the layouting part of ICU (lx) or the sorting/collation part of ICU (i18n) --- config.lib | 2 +- src/crashlog.cpp | 15 ++++++++++----- src/gfx_layout.cpp | 10 +++++----- src/gfx_layout.h | 10 +++++----- src/language.h | 8 ++++---- src/string.cpp | 10 +++++----- src/strings.cpp | 12 ++++++------ 7 files changed, 36 insertions(+), 31 deletions(-) diff --git a/config.lib b/config.lib index 68d8b13a8e..6fed7e803b 100644 --- a/config.lib +++ b/config.lib @@ -1754,7 +1754,7 @@ make_cflags_and_ldflags() { fi if [ -n "$icu_config" ]; then - CFLAGS="$CFLAGS -DWITH_ICU" + CFLAGS="$CFLAGS -DWITH_ICU_LAYOUT -DWITH_ICU_SORT" CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' ' '`" # Some icu-configs have the 'feature' of not adding a space where others do add the space diff --git a/src/crashlog.cpp b/src/crashlog.cpp index e8290a7c3f..7ddc2131f9 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -196,9 +196,9 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const # include # include FT_FREETYPE_H #endif /* WITH_FREETYPE */ -#ifdef WITH_ICU +#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT) # include -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */ #ifdef WITH_LZMA # include #endif @@ -241,14 +241,19 @@ char *CrashLog::LogLibraries(char *buffer, const char *last) const buffer += seprintf(buffer, last, " FreeType: %d.%d.%d\n", major, minor, patch); #endif /* WITH_FREETYPE */ -#ifdef WITH_ICU +#if defined(WITH_ICU_LAYOUT) || defined(WITH_ICU_SORT) /* 4 times 0-255, separated by dots (.) and a trailing '\0' */ char buf[4 * 3 + 3 + 1]; UVersionInfo ver; u_getVersion(ver); u_versionToString(ver, buf); - buffer += seprintf(buffer, last, " ICU: %s\n", buf); -#endif /* WITH_ICU */ +#ifdef WITH_ICU_SORT + buffer += seprintf(buffer, last, " ICU i18n: %s\n", buf); +#endif +#ifdef WITH_ICU_LAYOUT + buffer += seprintf(buffer, last, " ICU lx: %s\n", buf); +#endif +#endif /* WITH_ICU_SORT || WITH_ICU_LAYOUT */ #ifdef WITH_LZMA buffer += seprintf(buffer, last, " LZMA: %s\n", lzma_version_string()); diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index 2dba6a2046..f5463d4015 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -17,9 +17,9 @@ #include "table/control_codes.h" -#ifdef WITH_ICU +#ifdef WITH_ICU_LAYOUT #include -#endif /* WITH_ICU */ +#endif /* WITH_ICU_LAYOUT */ #include "safeguards.h" @@ -42,7 +42,7 @@ Font::Font(FontSize size, TextColour colour) : assert(size < FS_END); } -#ifdef WITH_ICU +#ifdef WITH_ICU_LAYOUT /* Implementation details of LEFontInstance */ le_int32 Font::getUnitsPerEM() const @@ -213,7 +213,7 @@ static ParagraphLayouter *GetParagraphLayout(UChar *buff, UChar *buff_end, FontM return new ICUParagraphLayout(p); } -#endif /* WITH_ICU */ +#endif /* WITH_ICU_LAYOUT */ /*** Paragraph layout ***/ /** @@ -654,7 +654,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi line.layout->Reflow(); } else { /* Line is new, layout it */ -#ifdef WITH_ICU +#ifdef WITH_ICU_LAYOUT FontState old_state = state; const char *old_str = str; diff --git a/src/gfx_layout.h b/src/gfx_layout.h index 7cd70ce280..0a21d9b0ca 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -19,12 +19,12 @@ #include #include -#ifdef WITH_ICU +#ifdef WITH_ICU_LAYOUT #include "layout/ParagraphLayout.h" #define ICU_FONTINSTANCE : public LEFontInstance -#else /* WITH_ICU */ +#else /* WITH_ICU_LAYOUT */ #define ICU_FONTINSTANCE -#endif /* WITH_ICU */ +#endif /* WITH_ICU_LAYOUT */ /** * Text drawing parameters, which can change while drawing a line, but are kept between multiple parts @@ -75,7 +75,7 @@ public: Font(FontSize size, TextColour colour); -#ifdef WITH_ICU +#ifdef WITH_ICU_LAYOUT /* Implementation details of LEFontInstance */ le_int32 getUnitsPerEM() const; @@ -91,7 +91,7 @@ public: LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; -#endif /* WITH_ICU */ +#endif /* WITH_ICU_LAYOUT */ }; /** Mapping from index to font. */ diff --git a/src/language.h b/src/language.h index 694b0ca1bb..fed138e635 100644 --- a/src/language.h +++ b/src/language.h @@ -13,9 +13,9 @@ #define LANGUAGE_H #include "core/smallvec_type.hpp" -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT #include -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT */ static const uint8 CASE_GENDER_LEN = 16; ///< The (maximum) length of a case/gender string. static const uint8 MAX_NUM_GENDERS = 8; ///< Maximum number of supported genders. @@ -110,9 +110,9 @@ extern LanguageList _languages; /** The currently loaded language. */ extern const LanguageMetadata *_current_language; -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT extern Collator *_current_collator; -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT */ bool ReadLanguagePack(const LanguageMetadata *lang); const LanguageMetadata *GetLanguage(byte newgrflangid); diff --git a/src/string.cpp b/src/string.cpp index 6bc9319c1c..377fb7f98d 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -25,12 +25,12 @@ #include // required by vsnprintf implementation for MSVC #endif -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT /* Required by strnatcmp. */ #include #include "language.h" #include "gfx_func.h" -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT */ /* The function vsnprintf is used internally to perform the required formatting * tasks. As such this one must be allowed, and makes sure it's terminated. */ @@ -572,7 +572,7 @@ int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front) s1 = SkipGarbage(s1); s2 = SkipGarbage(s2); } -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT if (_current_collator != NULL) { UErrorCode status = U_ZERO_ERROR; int result; @@ -592,13 +592,13 @@ int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front) if (U_SUCCESS(status)) return result; } -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT */ /* Do a normal comparison if ICU is missing or if we cannot create a collator. */ return strcasecmp(s1, s2); } -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT #include #include diff --git a/src/strings.cpp b/src/strings.cpp index 9c88b70c77..5d1059243c 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -49,9 +49,9 @@ const LanguageMetadata *_current_language = NULL; ///< The currently loaded lang TextDirection _current_text_dir; ///< Text direction of the currently selected language. -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT Collator *_current_collator = NULL; ///< Collator for the language currently in use. -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT */ static uint64 _global_string_params_data[20]; ///< Global array of string parameters. To access, use #SetDParam. static WChar _global_string_params_type[20]; ///< Type of parameters stored in #_decode_parameters @@ -1790,7 +1790,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang) strecpy(_config_language_file, c_file, lastof(_config_language_file)); SetCurrentGrfLangID(_current_language->newgrflangid); -#ifdef WITH_ICU +#ifdef WITH_ICU_SORT /* Delete previous collator. */ if (_current_collator != NULL) { delete _current_collator; @@ -1807,7 +1807,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang) delete _current_collator; _current_collator = NULL; } -#endif /* WITH_ICU */ +#endif /* WITH_ICU_SORT */ /* Some lists need to be sorted again after a language change. */ ReconsiderGameScriptLanguage(); @@ -2132,7 +2132,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) /* Update the font with cache */ LoadStringWidthTable(searcher->Monospace()); -#if !defined(WITH_ICU) +#if !defined(WITH_ICU_LAYOUT) /* * For right-to-left languages we need the ICU library. If * we do not have support for that library we warn the user @@ -2152,5 +2152,5 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) SetDParamStr(0, err_str); ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR); } -#endif +#endif /* !WITH_ICU_LAYOUT */ }