From 4749187dde78ad796814c315739f715f51fc4fb0 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 13 Jun 2024 23:22:06 +0200 Subject: [PATCH] take account of joker tile --- function.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/function.c b/function.c index b0176c7..fff192c 100644 --- a/function.c +++ b/function.c @@ -432,6 +432,27 @@ void findwords (word_t *words, play_t *play, play_t *turn) } } +int _strrcmp (char *str1, char *str2) +{ + int ret = 0; + int l1 = strlen (str1); + int l2 = strlen (str2); + int l = (l1 < l2) ? l1 : l2; + int i; + for (i = 0; i < l; i++) { + if (str1[i] != '.') { + ret = str1[i] - str2[i]; + if (ret != 0) { + break; + } + } + } + if (ret == 0) { + ret = str1[l] - str2[l]; + } + return ret; +} + void checkspellingfromfile (word_t *words, char *dict) { FILE *fd = (dict) ? fopen (dict, "r") : NULL; @@ -442,7 +463,7 @@ void checkspellingfromfile (word_t *words, char *dict) int stop = 1; for (i = 0; i < words->maxnbwords; i++) { if (words->status[i] == notchecked) { - if (strcmp (words->tab[i], str) == 0) { + if (_strrcmp (words->tab[i], str) == 0) { words->status[i] = correct; } else { stop = 0; @@ -507,7 +528,7 @@ void checkspellingfromcache (word_t *words, char **listofwords) int stop = 1; for (i = 0; i < words->maxnbwords; i++) { if (words->status[i] == notchecked) { - if (strcmp (words->tab[i], *listofwords) == 0) { + if (_strrcmp (words->tab[i], *listofwords) == 0) { words->status[i] = correct; } else { stop = 0; -- 2.30.2