eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot dic/dic.c dic/dic.h game/board_cross.cpp ...


From: eliot-dev
Subject: [Eliot-dev] eliot dic/dic.c dic/dic.h game/board_cross.cpp ...
Date: Sat, 24 Dec 2005 18:42:44 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Branch:         
Changes by:     Olivier Teulière <address@hidden>      05/12/24 18:42:44

Modified files:
        dic            : dic.c dic.h 
        game           : board_cross.cpp board_search.cpp 

Log message:
        Dic_chr returns the actual char, not a code between 0 and 31.
        Dic_lookup takes a string containing real chars, not codes.
        The idea is to hide the internal representation of the characters from 
the
        users of the dictionary, who don't care about it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/dic/dic.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/dic/dic.h.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/board_cross.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/board_search.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: eliot/dic/dic.c
diff -u eliot/dic/dic.c:1.8 eliot/dic/dic.c:1.9
--- eliot/dic/dic.c:1.8 Sat Nov  5 17:56:22 2005
+++ eliot/dic/dic.c     Sat Dec 24 18:42:44 2005
@@ -120,7 +120,11 @@
 char
 Dic_chr(Dictionary d, dic_elt_t e)
 {
-  return (d->dawg[e]).chr;
+    char c = (d->dawg[e]).chr;
+    if (c)
+        return c + 'A' - 1;
+    else
+        return 0;
 }
 
 
Index: eliot/dic/dic.h
diff -u eliot/dic/dic.h:1.10 eliot/dic/dic.h:1.11
--- eliot/dic/dic.h:1.10        Fri Nov  4 20:00:06 2005
+++ eliot/dic/dic.h     Sat Dec 24 18:42:44 2005
@@ -58,9 +58,9 @@
 int    Dic_destroy(Dictionary dic);
 
     /**
-     * Dic_chr returns the character code associated with an element,
-     * codes may range from 0 to 31. 0 is the null character.
-     * @returns code for the encoded character
+     * Dic_chr returns the character associated with an element
+     * (in the range ['A'-'Z']), or the null character ('\0').
+     * @returns ASCII code for the character
      */
 char   Dic_chr (Dictionary dic, dic_elt_t elt);
 
@@ -104,8 +104,8 @@
      * from the given root node by walking the dictionary tree
      * @params dic : valid dictionary
      * @params root : starting dictionary node for the search
-     * @params pattern : string encoded according to the dictionary codes,
-     * the pattern must be null ('\0') terminated
+     * @params pattern : string made of uppercase characters in the range
+     * ['A'-'Z']. The pattern must be null ('\0') terminated
      * @returns 0 if the string cannot be matched otherwise returns the
      * element that results from walking the dictionary according to the
      * pattern
Index: eliot/game/board_cross.cpp
diff -u eliot/game/board_cross.cpp:1.4 eliot/game/board_cross.cpp:1.5
--- eliot/game/board_cross.cpp:1.4      Fri Nov  4 20:00:06 2005
+++ eliot/game/board_cross.cpp  Sat Dec 24 18:42:44 2005
@@ -50,7 +50,7 @@
     // FIXME: create a temporary string until the dictionary uses Tile objects
     char leftTiles[BOARD_DIM + 1];
     for (j = i; j < index; j++)
-        leftTiles[j - i] = toupper(iTiles[j].toChar()) - 'A' + 1;
+        leftTiles[j - i] = toupper(iTiles[j].toChar());
     leftTiles[index - i] = 0;
     node = Dic_lookup(iDic, Dic_root(iDic), leftTiles);
     if (node == 0)
@@ -62,12 +62,12 @@
     // FIXME: same thing for the right part
     char rightTiles[BOARD_DIM + 1];
     for (j = index + 1; !iTiles[j].isEmpty(); j++)
-        rightTiles[j - index - 1] = toupper(iTiles[j].toChar()) - 'A' + 1;
+        rightTiles[j - index - 1] = toupper(iTiles[j].toChar());
     rightTiles[j - index - 1] = 0;
     for (succ = Dic_succ(iDic, node); succ; succ = Dic_next(iDic, succ))
     {
         if (Dic_word(iDic, Dic_lookup(iDic, succ, rightTiles)))
-            oCross.insert(Tile(Dic_chr(iDic, succ) + 'A' - 1));
+            oCross.insert(Tile(Dic_chr(iDic, succ)));
         if (Dic_last(iDic, succ))
             break;
     }
Index: eliot/game/board_search.cpp
diff -u eliot/game/board_search.cpp:1.7 eliot/game/board_search.cpp:1.8
--- eliot/game/board_search.cpp:1.7     Sat Nov  5 13:56:59 2005
+++ eliot/game/board_search.cpp Sat Dec 24 18:42:44 2005
@@ -114,7 +114,7 @@
 
         for (succ = Dic_succ(iDic, iNode); succ; succ = Dic_next(iDic, succ))
         {
-            l = Tile('A' - 1 + Dic_chr(iDic, succ));
+            l = Tile(Dic_chr(iDic, succ));
             if (iCrossMx[iRow][iCol].check(l))
             {
                 if (iRack.in(l))
@@ -145,7 +145,7 @@
         l = iTilesMx[iRow][iCol];
         for (succ = Dic_succ(iDic, iNode); succ ; succ = Dic_next(iDic, succ))
         {
-            if (Tile('A' - 1 + Dic_chr(iDic, succ)) == l)
+            if (Tile(Dic_chr(iDic, succ)) == l)
             {
                 ioPartialWord.addRightFromBoard(l);
                 ExtendRight(iBoard, iDic, iTilesMx, iCrossMx, iPointsMx,
@@ -178,7 +178,7 @@
     {
         for (succ = Dic_succ(iDic, n); succ; succ = Dic_next(iDic, succ))
         {
-            l = Tile('A' - 1 + Dic_chr(iDic, succ));
+            l = Tile(Dic_chr(iDic, succ));
             if (iRack.in(l))
             {
                 iRack.remove(l);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]