bugfix: evry string matching now handles UTF8

T152
This commit is contained in:
Mike Blumenkrantz 2014-02-20 21:48:06 -05:00
parent a588b891b5
commit b83cbdd100
1 changed files with 21 additions and 6 deletions

View File

@ -96,6 +96,8 @@ evry_fuzzy_match(const char *str, const char *match)
while ((m_cnt < m_num) && (*next != 0)) while ((m_cnt < m_num) && (*next != 0))
{ {
int ii;
/* reset match */ /* reset match */
if (m_cnt == 0) m = match; if (m_cnt == 0) m = match;
@ -124,8 +126,10 @@ evry_fuzzy_match(const char *str, const char *match)
} }
else else
{ {
ii = 0;
/* go to next word */ /* go to next word */
for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++) ; for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p += ii)
if (!eina_unicode_utf8_next_get(p, &ii)) break;
cnt++; cnt++;
next = p; next = p;
m_cnt = 0; m_cnt = 0;
@ -160,7 +164,10 @@ evry_fuzzy_match(const char *str, const char *match)
last = offset; last = offset;
/* try next char of match */ /* try next char of match */
if (*(++m) != 0 && !isspace(*m)) ii = 0;
if (!eina_unicode_utf8_next_get(m, &ii)) continue;
m += ii;
if (*m != 0 && !isspace(*m))
continue; continue;
/* end of match: store min weight of match */ /* end of match: store min weight of match */
@ -171,22 +178,30 @@ evry_fuzzy_match(const char *str, const char *match)
} }
else else
{ {
ii = 0;
/* go to next match */ /* go to next match */
for (; (*m != 0) && !isspace(*m); m++) ; for (; (*m != 0) && !isspace(*m); m += ii)
if (!eina_unicode_utf8_next_get(m, &ii)) break;
} }
if (m_cnt < m_num - 1) if (m_cnt < m_num - 1)
{ {
ii = 0;
/* test next match */ /* test next match */
for (; (*m != 0) && isspace(*m); m++) ; for (; (*m != 0) && isspace(*m); m += ii)
if (!eina_unicode_utf8_next_get(m, &ii)) break;
m_cnt++; m_cnt++;
break; break;
} }
else if (*p != 0) else if (*p != 0)
{ {
ii = 0;
/* go to next word */ /* go to next word */
for (; (*p != 0) && !((isspace(*p) || (ip && ispunct(*p)))); p++) ; for (; (*p != 0) && !((isspace(*p) || (ip && ispunct(*p)))); p += ii)
for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p++) ; if (!eina_unicode_utf8_next_get(p, &ii)) break;
ii = 0;
for (; (*p != 0) && ((isspace(*p) || (ip && ispunct(*p)))); p += ii)
if (!eina_unicode_utf8_next_get(p, &ii)) break;
cnt++; cnt++;
next = p; next = p;
m_cnt = 0; m_cnt = 0;