]> git.cworth.org Git - wordgame/commitdiff
Remove dependence on string_t functions from grid.c
authorCarl Worth <cworth@raht.cworth.org>
Thu, 21 Sep 2006 08:55:59 +0000 (01:55 -0700)
committerCarl Worth <cworth@raht.cworth.org>
Thu, 21 Sep 2006 08:55:59 +0000 (01:55 -0700)
grid.c

diff --git a/grid.c b/grid.c
index d796cabee7b4ed2bda6fb00d31810f6a0f0096e6..cce4ab768da43dcd7f8105a7cf0f38ac9328f206 100644 (file)
--- a/grid.c
+++ b/grid.c
@@ -103,7 +103,7 @@ board_enumerate (board_t    *board,
                 int             x,
                 int             y,
                 int16_t         seen,
-                string_t       *word,
+                char           *word,
                 dict_cursor_t   dict_cursor)
 {
     char c;
@@ -122,24 +122,24 @@ board_enumerate (board_t  *board,
     seen |= SEEN_BIT (x, y);
 
     c = board->letters[y][x];
-    string_append_char (word, c);
+    word[strlen (word)] = c;
     dict_cursor = dict_cursor_next (dict_cursor, c);
 
     if (c == 'q') {
-       string_append_char (word, 'u');
+       word[strlen (word)] = 'u';
        dict_cursor = dict_cursor_next (dict_cursor, 'u');
     }
 
     if (DICT_ENTRY_IS_WORD (dict_cursor_resolve (dict_cursor)))
-       dict_add_word (board->results, word->s);
+       dict_add_word (board->results, word);
 
     for (dy = -1; dy <= 1; dy++)
        for (dx = -1; dx <= 1; dx++)
            board_enumerate (board, x + dx, y + dy, seen, word, dict_cursor);
 
     if (c == 'q')
-       string_chop (word);
-    string_chop (word);
+       word [strlen (word) - 1] = '\0';
+    word [strlen (word) - 1] = '\0';
 }
 
 static void
@@ -147,17 +147,15 @@ board_solve (board_t *board, dict_t *dict, dict_t *solution)
 {
     int x, y;
     int16_t seen = 0;
-    string_t word;
+    char word[17];
 
     board->results = solution;
 
-    string_init (&word);
+    memset (word, '\0', 17);
 
     for (y = 0; y < 4; y++)
        for (x = 0; x < 4; x++)
-           board_enumerate (board, x, y, seen, &word, dict_root (dict));
-
-    string_fini (&word);
+           board_enumerate (board, x, y, seen, word, dict_root (dict));
 }
 
 static bool_t
@@ -182,7 +180,6 @@ main (void)
     int remaining, minutes, seconds;
     int found, missed;
     char prompt[7], *response;
-    string_t word;
 
     gettimeofday (&tv, NULL);
     srand (tv.tv_sec ^ tv.tv_usec);