evrything - fix handling of broken strings without looping forever
this should fix #20 #20 @fix
This commit is contained in:
parent
1b9d1c9796
commit
ef788779f9
|
@ -60,7 +60,7 @@ _evry_utf8_next(const char *buf, int *iindex)
|
||||||
int
|
int
|
||||||
evry_fuzzy_match(const char *str, const char *match)
|
evry_fuzzy_match(const char *str, const char *match)
|
||||||
{
|
{
|
||||||
const char *p, *m, *next;
|
const char *p, *pp, *m, *pm, *next;
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
unsigned int last = 0;
|
unsigned int last = 0;
|
||||||
|
@ -104,10 +104,15 @@ evry_fuzzy_match(const char *str, const char *match)
|
||||||
next = str;
|
next = str;
|
||||||
m = match;
|
m = match;
|
||||||
|
|
||||||
|
pm = NULL;
|
||||||
while ((m_cnt < m_num) && (*next != 0))
|
while ((m_cnt < m_num) && (*next != 0))
|
||||||
{
|
{
|
||||||
int ii;
|
int ii;
|
||||||
|
|
||||||
|
/* check for a broken encoded string - not advancing */
|
||||||
|
if (pm == m) goto broken_string;
|
||||||
|
pm = m;
|
||||||
|
|
||||||
/* reset match */
|
/* reset match */
|
||||||
if (m_cnt == 0) m = match;
|
if (m_cnt == 0) m = match;
|
||||||
|
|
||||||
|
@ -120,9 +125,13 @@ evry_fuzzy_match(const char *str, const char *match)
|
||||||
first = 0;
|
first = 0;
|
||||||
/* m_len = 0; */
|
/* m_len = 0; */
|
||||||
|
|
||||||
|
pp = NULL;
|
||||||
/* match current word of string against current match */
|
/* match current word of string against current match */
|
||||||
for (p = next; *next != 0; p++)
|
for (p = next; *next != 0; p++)
|
||||||
{
|
{
|
||||||
|
/* check for a broken encoded string - not advancing */
|
||||||
|
if (pp == p) goto broken_string;
|
||||||
|
pp = p;
|
||||||
/* new word of string begins */
|
/* new word of string begins */
|
||||||
if ((*p == 0) || isspace(*p) || (ip && ispunct(*p)))
|
if ((*p == 0) || isspace(*p) || (ip && ispunct(*p)))
|
||||||
{
|
{
|
||||||
|
@ -241,6 +250,7 @@ evry_fuzzy_match(const char *str, const char *match)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
broken_string:
|
||||||
|
|
||||||
for (m_cnt = 0; m_cnt < m_num; m_cnt++)
|
for (m_cnt = 0; m_cnt < m_num; m_cnt++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue