summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2016-04-08 11:17:51 +0100
committerTom Hacohen <tom@stosb.com>2016-04-08 11:24:32 +0100
commitf4f9753c201c569b1a31f0b394d9352c80a7d9d0 (patch)
tree8a097bab49da040019d0dd52c7a9ae720a72ee23 /src/lib/evas/common
parentf7a4a2b2a04d3135f874bc0760db90a247b8f270 (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.c19
-rw-r--r--src/lib/evas/common/language/evas_language_utils.h3
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 19638d5..f8b38b6 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
48static char lang[6]; /* FIXME: Maximum length I know about */
49static char lang_full[32];
50
48static Evas_Script_Type 51static 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)
135const char * 138const char *
136evas_common_language_from_locale_get(void) 139evas_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)
163const char * 165const char *
164evas_common_language_from_locale_full_get(void) 166evas_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
189void
190evas_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 5e24912..8c7529a 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
132const char * 132const char *
133evas_common_language_from_locale_full_get(void); 133evas_common_language_from_locale_full_get(void);
134
135void
136evas_common_language_reinit(void);
134#endif 137#endif
135 138