* if not defined, zero-terminated array of bytes is used as the input
* KMP_GET_CHAR(ctx,src,c)
*
- * KMP_NODE user-defined data stored in each added string
+ * KMP_NODE user-defined data in each state
+ * KMP_CONTEXT user-defined data in context
*
* Parameters to default get_char():
* KMP_USE_ASCII reads single bytes from the input (default)
#include "lib/mempool.h"
#include <alloca.h>
+#include <string.h>
#define P(x) KMP_PREFIX(x)
struct P(context) {
struct P(hash_table) hash; /* hash table*/
struct P(state) null; /* null state */
+# ifdef KMP_CONTEXT
+ KMP_CONTEXT v; /* user defined data */
+# endif
};
#ifdef KMP_SOURCE
return !ctx->hash.hash_count;
}
+static inline struct P(state) *
+P(chain_start) (struct P(state) *s)
+{
+ return s->len ? s : s->next;
+}
+
static void
P(build) (struct P(context) *ctx)
{
#undef KMP_SOURCE
#undef KMP_GET_CHAR
#undef KMP_NODE
+#undef KMP_CONTEXT
#undef KMP_USE_ASCII
#undef KMP_USE_UTF8
#undef KMP_TOLOWER