From: Laurent Mazet Date: Thu, 13 Jun 2024 21:22:06 +0000 (+0200) Subject: take account of joker tile X-Git-Tag: v1.0~18 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=4749187dde78ad796814c315739f715f51fc4fb0;p=scrabble.git take account of joker tile --- 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;