From da6c46cba9a7e9fd982a82b89a23e812e1ff6d62 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Tue, 27 Sep 2016 03:35:14 +0200
Subject: Fix common prefix search with no collator
---
src/stardict.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
(limited to 'src/stardict.c')
diff --git a/src/stardict.c b/src/stardict.c
index 9ce6059..cc69c07 100644
--- a/src/stardict.c
+++ b/src/stardict.c
@@ -980,7 +980,13 @@ stardict_longest_common_collation_prefix (StardictDict *sd,
while ((pos1 = ubrk_next (it1)) != UBRK_DONE
&& (pos2 = ubrk_next (it2)) != UBRK_DONE)
{
- if (!ucol_strcoll (sd->priv->collator, uc1, pos1, uc2, pos2))
+ if (sd->priv->collator)
+ {
+ if (!ucol_strcoll (sd->priv->collator, uc1, pos1, uc2, pos2))
+ longest = pos1;
+ }
+ // I'd need a new collator, so just do the minimal working thing
+ else if (pos1 == pos2 && !memcmp (uc1, uc2, pos1 * sizeof *uc1))
longest = pos1;
}
ubrk_close (it1);
--
cgit v1.2.3-70-g09d2