take account of joker tile
authorLaurent Mazet <mazet@softndesign.org>
Thu, 13 Jun 2024 21:22:06 +0000 (23:22 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Thu, 13 Jun 2024 21:22:06 +0000 (23:22 +0200)
function.c

index b0176c79f511722f15d9bf27916b9cca8b4dc556..fff192c19cdcca7772d3e8d670676ec14705df86 100644 (file)
@@ -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;