From: Pavel Charvat Date: Thu, 20 Apr 2006 16:56:41 +0000 (+0200) Subject: fixes X-Git-Tag: holmes-import~645^2~13 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=6c387c164c40f5f24efc45a6d2836e8ab45e3a04;p=libucw.git fixes --- diff --git a/lib/kmp-search.h b/lib/kmp-search.h index a399030b..726593f0 100644 --- a/lib/kmp-search.h +++ b/lib/kmp-search.h @@ -24,7 +24,7 @@ * void run(kmp,src) the same, but automatically allocates search structre from the stack * * - * Macros marked with [*] are mandatory. + * Parameters to the generator (these marked with [*] are mandatory): * * [*] KMPS_PREFIX(x) macro to add a name prefix (used on all global names * defined by the KMP search generator) @@ -44,8 +44,8 @@ * KMPS_STEP(kmp,src,search) ... after each step (read of next character + current state update) * of the algorithm, but before KMPS_FOUND[_CHAIN] * KMPS_FOUND_CHAIN(kmp,src,search) ... for each state representing locally longest match - * (stored in search->out - NOT necessary search.s!); - * all matches forms a NULL-terminated link list (search->out, search->out->next, ...) + * (stored in search->out - NOT necessary search->s!); + * all matches form a NULL-terminated link list (search->out, search->out->next, ...) * in order of decreasing length * KMPS_FOUND(kmp,src,search) ... called for every match (in search->out) * KMPS_WANT_BEST algorithm computes globally longest match, which is available diff --git a/lib/kmp-test.c b/lib/kmp-test.c index 28ea6d50..e245fcff 100644 --- a/lib/kmp-test.c +++ b/lib/kmp-test.c @@ -16,16 +16,16 @@ /* TEST1 - multiple searches */ -#define KMP_PREFIX(x) GLUE_(kmp1,x) +#define KMP_PREFIX(x) kmp1_##x #define KMP_WANT_CLEANUP #include "lib/kmp.h" -#define KMPS_PREFIX(x) GLUE_(kmp1s1,x) -#define KMPS_KMP_PREFIX(x) GLUE_(kmp1,x) +#define KMPS_PREFIX(x) kmp1s1_##x +#define KMPS_KMP_PREFIX(x) kmp1_##x #define KMPS_WANT_BEST #define KMPS_EXIT(kmp,src,s) TRACE("Best match has %d characters", s->best->len) #include "lib/kmp-search.h" -#define KMPS_PREFIX(x) GLUE_(kmp1s2,x) -#define KMPS_KMP_PREFIX(x) GLUE_(kmp1,x) +#define KMPS_PREFIX(x) kmp1s2_##x +#define KMPS_KMP_PREFIX(x) kmp1_##x #define KMPS_VARS uns count; #define KMPS_INIT(kmp,src,s) s->u.count = 0 #define KMPS_FOUND(kmp,src,s) s->u.count++ @@ -52,7 +52,7 @@ test1(void) /* TEST2 - various tracing */ -#define KMP_PREFIX(x) GLUE_(kmp2,x) +#define KMP_PREFIX(x) kmp2_##x #define KMP_USE_UTF8 #define KMP_TOLOWER #define KMP_ONLYALPHA @@ -91,7 +91,7 @@ test2(void) /* TEST3 - random tests */ -#define KMP_PREFIX(x) GLUE_(kmp3,x) +#define KMP_PREFIX(x) kmp3_##x #define KMP_STATE_VARS uns index; #define KMP_ADD_EXTRA_ARGS uns index #define KMP_VARS byte *start; @@ -170,7 +170,7 @@ kmp4_hash(struct kmp4_struct *kmp UNUSED, struct kmp4_state *s, byte *c) return (c ? (*c << 16) : 0) + (uns)(addr_int_t)s; } -#define KMP_PREFIX(x) GLUE_(kmp4,x) +#define KMP_PREFIX(x) kmp4_##x #define KMP_CHAR byte * #define KMP_CONTROL_CHAR NULL #define KMP_GET_CHAR(kmp,src,c) ({ c = src++; !!*c; }) diff --git a/lib/kmp.h b/lib/kmp.h index f4d14049..86a0f98f 100644 --- a/lib/kmp.h +++ b/lib/kmp.h @@ -16,12 +16,12 @@ * * This file contains only construction of the automaton. The search * itself can be generated by inclusion of file lib/kmp-search.h. - * Separeted headers allows the user to define multiple search + * Separeted headers allow the user to define multiple search * routines for one common set of key strings. * * Example: * - * #define KMP_PREFIX(x) GLUE_(kmp,x) + * #define KMP_PREFIX(x) kmp_##x * #define KMP_WANT_CLEANUP * #define KMP_WANT_SEARCH // includes lib/kmp-search.h automatically * #define KMPS_FOUND(kmp,src,s) printf("found\n") @@ -51,7 +51,7 @@ * Basic parameters: * KMP_PREFIX(x) macro to add a name prefix (used on all global names * defined by the KMP generator); mandatory; - * below we use P(x) alias + * we abbreviate this to P(x) below * * KMP_CHAR alphabet type, the default is u16 * @@ -131,11 +131,11 @@ typedef struct {} P(node_t); struct P(struct); struct P(state) { - struct P(state) *from; /* state with previous character (forms a tree with null state in the root) */ + struct P(state) *from; /* state with the previous character (forms a tree with null state in the root) */ struct P(state) *back; /* backwards edge to the longest shorter state with same suffix */ - struct P(state) *next; /* longest shorter match (or NULL) */ + struct P(state) *next; /* the longest of shorter matches (or NULL) */ P(len_t) len; /* state depth if it represents a key string, zero otherwise */ - P(char_t) c; /* last character of represented string */ + P(char_t) c; /* last character of the represented string */ struct { # ifdef KMP_STATE_VARS KMP_STATE_VARS @@ -224,7 +224,7 @@ P(hash_init_key) (struct P(hash_table) *t UNUSED, struct P(state) *s, struct P(s } #undef P -#define HASH_PREFIX(x) KMP_PREFIX(GLUE(hash_,x)) +#define HASH_PREFIX(x) KMP_PREFIX(hash_##x) #define HASH_NODE struct KMP_PREFIX(state) #define HASH_KEY_COMPLEX(x) x from, x c #define HASH_KEY_DECL struct KMP_PREFIX(state) *from, KMP_PREFIX(char_t) c