]> mj.ucw.cz Git - libucw.git/blobdiff - lib/wildmatch.c
All numbers printed by sort-test should be unsigned.
[libucw.git] / lib / wildmatch.c
index 8e001e8f5178a99f417dc17582f756c283d3e62b..fed2ddb944efd5e9c8e6141cdbeb5fbe3337be52 100644 (file)
@@ -1,13 +1,16 @@
 /*
- *     Fast Pattern Matcher for Short Wildcard Patterns (only `?' and `*' supported)
+ *     UCW Library -- Fast Pattern Matcher for Short Wildcard Patterns (only `?' and `*' supported)
  *
  *     Traditional NFA -> DFA method with on-the-fly DFA construction.
  *
  *     (c) 1999 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 #include "lib/lib.h"
-#include "lib/pools.h"
+#include "lib/mempool.h"
 #include "lib/wildmatch.h"
 
 #include <stdio.h>
@@ -26,7 +29,7 @@ struct nfa_state {
 };
 
 struct dfa_state {
-  addr_int_t edge[256];                /* Outgoing DFA edges. Bit 0 is set for incomplete edges which
+  uintptr_t edge[256];         /* Outgoing DFA edges. Bit 0 is set for incomplete edges which
                                 * contain just state set and clear for complete ones which point
                                 * to other states. NULL means `no match'.
                                 */
@@ -103,8 +106,7 @@ wp_compile(byte *p, struct mempool *pool)
 
   if (strlen(p) >= MAX_STATES)         /* Too long */
     return NULL;
-  w = mp_alloc(pool, sizeof(*w));
-  bzero(w, sizeof(*w));
+  w = mp_alloc_zero(pool, sizeof(*w));
   w->pool = pool;
   for(i=1; *p; p++)
     {
@@ -155,12 +157,12 @@ wp_match(struct wildpatt *w, byte *s)
   d = w->dfa_start;
   while (*s)
     {
-      addr_int_t next = d->edge[*s];
+      uintptr_t next = d->edge[*s];
       if (next & 1)
        {
          /* Need to lookup/create the destination state */
          struct dfa_state *new = wp_new_state(w, next & ~1);
-         d->edge[*s] = (addr_int_t) new;
+         d->edge[*s] = (uintptr_t) new;
          d = new;
        }
       else if (!next)