diff options
author | Youngbok Shin <youngb.shin@samsung.com> | 2016-04-08 11:17:51 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2016-04-08 11:24:32 +0100 |
commit | f4f9753c201c569b1a31f0b394d9352c80a7d9d0 (patch) | |
tree | 8a097bab49da040019d0dd52c7a9ae720a72ee23 /src/lib/evas/common | |
parent | f7a4a2b2a04d3135f874bc0760db90a247b8f270 (diff) |
Evas: Add API to reinit the language and use it in elementary.
Summary:
evas_common_language_from_locale_* functions kept static pointers
inside of its functions. Once these function was called, it was never reset.
It made big problems for harfbuzz and hyphenation. Also, Elementary
provides elm_language_set() API. Then we need to support it fully.
@fix
Test Plan: Test case for hyphenation is included in Evas test suite.
Reviewers: raster, tasn, herdsman, woohyun, z-wony, Blackmole, minudf
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D3864
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r-- | src/lib/evas/common/language/evas_language_utils.c | 19 | ||||
-rw-r--r-- | src/lib/evas/common/language/evas_language_utils.h | 3 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/evas/common/language/evas_language_utils.c b/src/lib/evas/common/language/evas_language_utils.c index 19638d528d..f8b38b6abd 100644 --- a/src/lib/evas/common/language/evas_language_utils.c +++ b/src/lib/evas/common/language/evas_language_utils.c | |||
@@ -45,6 +45,9 @@ | |||
45 | #define EXPLICIT_SCRIPT(script) \ | 45 | #define EXPLICIT_SCRIPT(script) \ |
46 | (((script) != EVAS_SCRIPT_UNKNOWN) && ((script) > EVAS_SCRIPT_INHERITED)) | 46 | (((script) != EVAS_SCRIPT_UNKNOWN) && ((script) > EVAS_SCRIPT_INHERITED)) |
47 | 47 | ||
48 | static char lang[6]; /* FIXME: Maximum length I know about */ | ||
49 | static char lang_full[32]; | ||
50 | |||
48 | static Evas_Script_Type | 51 | static Evas_Script_Type |
49 | _evas_common_language_char_script_search(Eina_Unicode unicode) | 52 | _evas_common_language_char_script_search(Eina_Unicode unicode) |
50 | { | 53 | { |
@@ -135,7 +138,6 @@ evas_common_language_script_type_get(const Eina_Unicode *str, size_t len) | |||
135 | const char * | 138 | const char * |
136 | evas_common_language_from_locale_get(void) | 139 | evas_common_language_from_locale_get(void) |
137 | { | 140 | { |
138 | static char lang[6]; /* FIXME: Maximum length I know about */ | ||
139 | if (*lang) return lang; | 141 | if (*lang) return lang; |
140 | 142 | ||
141 | const char *locale; | 143 | const char *locale; |
@@ -163,8 +165,7 @@ evas_common_language_from_locale_get(void) | |||
163 | const char * | 165 | const char * |
164 | evas_common_language_from_locale_full_get(void) | 166 | evas_common_language_from_locale_full_get(void) |
165 | { | 167 | { |
166 | static char lang[32]; | 168 | if (*lang_full) return lang_full; |
167 | if (*lang) return lang; | ||
168 | 169 | ||
169 | const char *locale; | 170 | const char *locale; |
170 | locale = setlocale(LC_MESSAGES, NULL); | 171 | locale = setlocale(LC_MESSAGES, NULL); |
@@ -177,14 +178,20 @@ evas_common_language_from_locale_full_get(void) | |||
177 | if ((c == '.') || (c == '@') || (c == ' ')) /* Looks like en_US.UTF8 or de_DE@euro or aa_ER UTF-8*/ | 178 | if ((c == '.') || (c == '@') || (c == ' ')) /* Looks like en_US.UTF8 or de_DE@euro or aa_ER UTF-8*/ |
178 | break; | 179 | break; |
179 | } | 180 | } |
180 | strncpy(lang, locale, i); | 181 | strncpy(lang_full, locale, i); |
181 | lang[i] = '\0'; | 182 | lang_full[i] = '\0'; |
182 | return lang; | 183 | return lang_full; |
183 | } | 184 | } |
184 | 185 | ||
185 | return ""; | 186 | return ""; |
186 | } | 187 | } |
187 | 188 | ||
189 | void | ||
190 | evas_common_language_reinit(void) | ||
191 | { | ||
192 | *lang = *lang_full = '\0'; | ||
193 | } | ||
194 | |||
188 | /* | 195 | /* |
189 | * @} | 196 | * @} |
190 | */ | 197 | */ |
diff --git a/src/lib/evas/common/language/evas_language_utils.h b/src/lib/evas/common/language/evas_language_utils.h index 5e249121fd..8c7529a572 100644 --- a/src/lib/evas/common/language/evas_language_utils.h +++ b/src/lib/evas/common/language/evas_language_utils.h | |||
@@ -131,5 +131,8 @@ evas_common_language_from_locale_get(void); | |||
131 | 131 | ||
132 | const char * | 132 | const char * |
133 | evas_common_language_from_locale_full_get(void); | 133 | evas_common_language_from_locale_full_get(void); |
134 | |||
135 | void | ||
136 | evas_common_language_reinit(void); | ||
134 | #endif | 137 | #endif |
135 | 138 | ||