* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
*/
-/* Portably, schmortability. I want ease of programming. */
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
+#include "dict.h"
+
#include <string.h>
#include <errno.h>
#include <ctype.h>
-#include "dict.h"
-
typedef struct _string {
size_t size;
char *s;
size_t len;
} string_t;
-#define TRIE_FLAGS_IS_WORD (1<<0)
-
typedef bool_t
(*trie_predicate_t) (trie_t *trie);
free (trie);
}
-static void
+static trie_t *
trie_add (trie_t *trie,
const char *word_chunk)
{
char c = word_chunk[0];
int i;
- if (c == '\0') {
- trie->flags |= TRIE_FLAGS_IS_WORD;
- return;
- }
+ if (c == '\0')
+ return trie;
i = TRIE_CHAR_TO_INDEX (c);
if (trie->next[i] == NULL)
trie->next[i] = trie_create ();
- trie_add (trie->next[i], word_chunk + 1);
+ return trie_add (trie->next[i], word_chunk + 1);
}
static trie_t *
dict_add_word (dict_t *dict,
const char *word)
{
- trie_add (dict, word);
+ trie_t *trie;
+
+ trie = trie_add (dict, word);
+ trie->flags |= DICT_ENTRY_FLAG_IS_WORD;
}
void