From: Martin Mares Date: Sat, 27 Mar 1999 21:43:23 +0000 (+0000) Subject: Miscellaneous fixes to the word matcher. X-Git-Tag: holmes-import~1670 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8886ac0aa8be3913ef1fbefcff5d970acce3010a;p=libucw.git Miscellaneous fixes to the word matcher. --- diff --git a/lib/wildmatch.c b/lib/wildmatch.c index 545487ce..fbc9bdb3 100644 --- a/lib/wildmatch.c +++ b/lib/wildmatch.c @@ -39,8 +39,8 @@ struct wildpatt { struct nfa_state nfa[MAX_STATES]; struct dfa_state *hash[HASH_SIZE]; struct dfa_state *dfa_start; - int nfa_states; - int dfa_cache_counter; + uns nfa_states; + uns dfa_cache_counter; struct mempool *pool; struct dfa_state *free_states; }; @@ -104,7 +104,7 @@ wp_compile(byte *p, struct mempool *pool) if (strlen(p) >= MAX_STATES) /* Too long */ return NULL; w = pool_alloc(pool, sizeof(*w)); - bzero(w, sizeof(w)); + bzero(w, sizeof(*w)); w->pool = pool; for(i=1; *p; p++) { @@ -172,6 +172,17 @@ wp_match(struct wildpatt *w, byte *s) return d->final; } +int +wp_min_size(byte *p) +{ + int s = 0; + + while (*p) + if (*p++ != '*') + s++; + return s; +} + #ifdef TEST void diff --git a/lib/wildmatch.h b/lib/wildmatch.h index 27a553b5..00bd1fb3 100644 --- a/lib/wildmatch.h +++ b/lib/wildmatch.h @@ -9,3 +9,4 @@ struct mempool; struct wildpatt *wp_compile(byte *, struct mempool *); int wp_match(struct wildpatt *, byte *); +int wp_min_size(byte *);