summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2014-02-20 21:48:06 -0500
committerMike Blumenkrantz <zmike@samsung.com>2014-02-21 17:22:53 -0500
commit13c7adeb468dc2dbf70d3cb801d2d53f4608981d (patch)
tree526a18c0e42e9f29b995ceeaed18d64c3d835d1c
parentd8f04b43b64c1d85a8549f415679fd3cd85a75ba (diff)
bugfix: evry string matching now handles UTF8
T152
-rw-r--r--src/modules/everything/evry_util.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/modules/everything/evry_util.c b/src/modules/everything/evry_util.c
index f0072b36e..af0d440c0 100644
--- a/src/modules/everything/evry_util.c
+++ b/src/modules/everything/evry_util.c
@@ -94,8 +94,14 @@ evry_fuzzy_match(const char *str, const char *match)
94 next = str; 94 next = str;
95 m = match; 95 m = match;
96 96
97#if (EINA_VERSION_MAJOR == 1) && (EINA_VERSION_MINOR < 8)
98# define eina_unicode_utf8_next_get eina_unicode_utf8_get_next
99#endif
100
97 while ((m_cnt < m_num) && (*next != 0)) 101 while ((m_cnt < m_num) && (*next != 0))
98 { 102 {
103 int ii;
104
99 /* reset match */ 105 /* reset match */
100 if (m_cnt == 0) m = match; 106 if (m_cnt == 0) m = match;
101 107
@@ -124,8 +130,10 @@ evry_fuzzy_match(const char *str, const char *match)
124 } 130 }
125 else 131 else
126 { 132 {
133 ii = 0;
127 /* go to next word */ 134 /* go to next word */
128 for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++) ; 135 for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p += ii)
136 if (!eina_unicode_utf8_next_get(p, &ii)) break;
129 cnt++; 137 cnt++;
130 next = p; 138 next = p;
131 m_cnt = 0; 139 m_cnt = 0;
@@ -160,7 +168,10 @@ evry_fuzzy_match(const char *str, const char *match)
160 last = offset; 168 last = offset;
161 169
162 /* try next char of match */ 170 /* try next char of match */
163 if (*(++m) != 0 && !isspace(*m)) 171 ii = 0;
172 if (!eina_unicode_utf8_next_get(m, &ii)) continue;
173 m += ii;
174 if (*m != 0 && !isspace(*m))
164 continue; 175 continue;
165 176
166 /* end of match: store min weight of match */ 177 /* end of match: store min weight of match */
@@ -171,22 +182,30 @@ evry_fuzzy_match(const char *str, const char *match)
171 } 182 }
172 else 183 else
173 { 184 {
185 ii = 0;
174 /* go to next match */ 186 /* go to next match */
175 for (; (*m != 0) && !isspace(*m); m++) ; 187 for (; (*m != 0) && !isspace(*m); m += ii)
188 if (!eina_unicode_utf8_next_get(m, &ii)) break;
176 } 189 }
177 190
178 if (m_cnt < m_num - 1) 191 if (m_cnt < m_num - 1)
179 { 192 {
193 ii = 0;
180 /* test next match */ 194 /* test next match */
181 for (; (*m != 0) && isspace(*m); m++) ; 195 for (; (*m != 0) && isspace(*m); m += ii)
196 if (!eina_unicode_utf8_next_get(m, &ii)) break;
182 m_cnt++; 197 m_cnt++;
183 break; 198 break;
184 } 199 }
185 else if (*p != 0) 200 else if (*p != 0)
186 { 201 {
202 ii = 0;
187 /* go to next word */ 203 /* go to next word */
188 for (; (*p != 0) && !((isspace(*p) || (ip && ispunct(*p)))); p++) ; 204 for (; (*p != 0) && !((isspace(*p) || (ip && ispunct(*p)))); p += ii)
189 for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++) ; 205 if (!eina_unicode_utf8_next_get(p, &ii)) break;
206 ii = 0;
207 for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p += ii)
208 if (!eina_unicode_utf8_next_get(p, &ii)) break;
190 cnt++; 209 cnt++;
191 next = p; 210 next = p;
192 m_cnt = 0; 211 m_cnt = 0;