summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-08-19 11:45:09 +0300
committerDaniel Hirt <daniel.hirt@samsung.com>2015-08-19 17:16:42 +0300
commita197aa366be10c57fcbc037d86f4a0310486375b (patch)
tree25cb4bda755458003b9ec591c54bc7113885f0eb /src/lib/evas/common
parentf1e3c7f41f2584ce45e16839e03003234f99ad9a (diff)
Evas language: fix script run code
For script runs that start with an UNKNOWN character, the whole run was mistakenly identified as script type UNKNOWN. Also, refactored code a bit for readability. Fixes T2670. @fix
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/language/evas_language_utils.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/lib/evas/common/language/evas_language_utils.c b/src/lib/evas/common/language/evas_language_utils.c
index b53ba5e..c9efc3b 100644
--- a/src/lib/evas/common/language/evas_language_utils.c
+++ b/src/lib/evas/common/language/evas_language_utils.c
@@ -34,6 +34,12 @@
34 34
35#include "evas_script_table.h" 35#include "evas_script_table.h"
36 36
37/* The given 'script' of a character is an EXPLICIT_SCRIPT if it is not one of
38 * the three special values: INHERITED, COMMON and UNKNOWN.
39 * See http://www.unicode.org/reports/tr24 */
40#define EXPLICIT_SCRIPT(script) \
41 (((script) != EVAS_SCRIPT_UNKNOWN) && ((script) > EVAS_SCRIPT_INHERITED))
42
37static Evas_Script_Type 43static Evas_Script_Type
38_evas_common_language_char_script_search(Eina_Unicode unicode) 44_evas_common_language_char_script_search(Eina_Unicode unicode)
39{ 45{
@@ -75,18 +81,20 @@ evas_common_language_script_end_of_run_get(const Eina_Unicode *str,
75 /* FIXME: Use the standard segmentation instead */ 81 /* FIXME: Use the standard segmentation instead */
76 Evas_Script_Type first = EVAS_SCRIPT_UNKNOWN; 82 Evas_Script_Type first = EVAS_SCRIPT_UNKNOWN;
77 int i; 83 int i;
78 for (i = 0 ; i < len ; i++, str++) 84
85 /* Find the first EXPLICIT_SCRIPT (see documented macro above), and
86 * use it to determine the script run */
87 for (i = 0 ; (i < len) && !EXPLICIT_SCRIPT(first) ; i++, str++)
79 { 88 {
80 Evas_Script_Type tmp; 89 first = evas_common_language_char_script_get(*str);
81 tmp = evas_common_language_char_script_get(*str); 90 }
82 /* Arabic is the first script in the array that's not 91
83 * common/inherited. */ 92 /* At this point either (i == len) or 'first' is an EXPLICIT_SCRIPT. */
84 if ((first == EVAS_SCRIPT_UNKNOWN) && (tmp >= EVAS_SCRIPT_ARABIC)) 93 /* NOTE: ++i, ++str is to start at the character after 'first', if exists. */
85 { 94 for ( ; i < len ; ++i, ++str)
86 first = tmp; 95 {
87 continue; 96 Evas_Script_Type tmp = evas_common_language_char_script_get(*str);
88 } 97 if (EXPLICIT_SCRIPT(tmp) && (tmp != first))
89 if ((first != tmp) && (tmp >= EVAS_SCRIPT_ARABIC))
90 { 98 {
91 break; 99 break;
92 } 100 }
@@ -112,9 +120,10 @@ evas_common_language_script_type_get(const Eina_Unicode *str, size_t len)
112{ 120{
113 Evas_Script_Type script = EVAS_SCRIPT_COMMON; 121 Evas_Script_Type script = EVAS_SCRIPT_COMMON;
114 const Eina_Unicode *end = str + len; 122 const Eina_Unicode *end = str + len;
115 /* Arabic is the first script in the array that's not a common/inherited */ 123 for ( ; (str < end) && !EXPLICIT_SCRIPT(script) ; str++)
116 for ( ; str < end && ((script = evas_common_language_char_script_get(*str)) < EVAS_SCRIPT_ARABIC) ; str++) 124 {
117 ; 125 script = evas_common_language_char_script_get(*str);
126 }
118 return script; 127 return script;
119} 128}
120 129