#include "dict.h"
-void *
+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);
+
+#define TRIE_CHAR_TO_INDEX(c) (tolower (c) - 'a')
+#define TRIE_INDEX_TO_CHAR(i) (i + 'a')
+
+static void *
xmalloc (size_t size)
{
void *res;
return res;
}
-void *
+static void *
xrealloc (void *ptr, size_t size)
{
void *res;
return res;
}
-void
+static void
chomp (char *s)
{
int len = strlen (s);
+ if (len == 0)
+ return;
if (s[len - 1] == '\n')
s[len - 1] = '\0';
}
-void
+static void
string_init (string_t *string)
{
string->size = 0;
string->len = 0;
}
-void
+static void
string_fini (string_t *string)
{
string->size = 0;
string->len = 0;
}
-void
+static void
string_append_char (string_t *string, char c)
{
if (string->size == 0) {
string->s[string->len] = '\0';
}
-void
+static void
string_chop (string_t *string)
{
if (string->len == 0)
trie_destroy (trie->next[i]);
}
-trie_t *
+static trie_t *
trie_create (void)
{
trie_t *trie;
free (trie);
}
-void
+static void
trie_add (trie_t *trie,
const char *word_chunk)
{
trie_add (trie->next[i], word_chunk + 1);
}
-trie_t *
+static trie_t *
trie_find (trie_t *trie,
const char *word_chunk)
{
return trie;
}
-int
+static int
trie_count (trie_t *trie,
trie_predicate_t predicate)
{
return count;
}
-int
+static int
trie_print (trie_t *trie,
string_t *string,
trie_predicate_t predicate,