]> mj.ucw.cz Git - libucw.git/commitdiff
Miscellaneous fixes to the word matcher.
authorMartin Mares <mj@ucw.cz>
Sat, 27 Mar 1999 21:43:23 +0000 (21:43 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 27 Mar 1999 21:43:23 +0000 (21:43 +0000)
lib/wildmatch.c
lib/wildmatch.h

index 545487ce91a517a82f43fffa6a777087f49f7b4a..fbc9bdb3c547e33587b1fe674aab007f15affe7e 100644 (file)
@@ -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
index 27a553b50d083bec9c8f51088515618a53890297..00bd1fb3d2a0f276c314c3d8a232bb949c563ee7 100644 (file)
@@ -9,3 +9,4 @@ struct mempool;
 
 struct wildpatt *wp_compile(byte *, struct mempool *);
 int wp_match(struct wildpatt *, byte *);
+int wp_min_size(byte *);