From eb1d405a4e38b09785d712725e7ef17096f09f51 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Mon, 14 Jul 2008 13:48:06 +0200 Subject: [PATCH] Libucw: wildmatch uses char * instead of byte * for strings. Needs to be typecasted to unsigned char when indexing arrays. Expects chars to be 8-bit. --- lib/wildmatch.c | 14 +++++++------- lib/wildmatch.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/wildmatch.c b/lib/wildmatch.c index e0b5e2ec..b14ea2d3 100644 --- a/lib/wildmatch.c +++ b/lib/wildmatch.c @@ -22,7 +22,7 @@ #define HASH_SKIP 137 struct nfa_state { - byte ch; /* 0 for non-matching state */ + char ch; /* 0 for non-matching state */ byte final; /* Accepting state */ u32 match_states; /* States to go to when input character == ch */ u32 default_states; /* States to go to whatever the input is */ @@ -83,7 +83,7 @@ wp_new_state(struct wildpatt *w, u32 set) { struct nfa_state *n = &w->nfa[bit]; if (n->ch) - d->edge[n->ch] |= n->match_states | 1; + d->edge[(unsigned char)n->ch] |= n->match_states | 1; d->final |= n->final; def_set |= n->default_states; } @@ -99,7 +99,7 @@ wp_new_state(struct wildpatt *w, u32 set) } struct wildpatt * -wp_compile(const byte *p, struct mempool *pool) +wp_compile(const char *p, struct mempool *pool) { struct wildpatt *w; uns i; @@ -148,7 +148,7 @@ wp_prune_cache(struct wildpatt *w) } int -wp_match(struct wildpatt *w, const byte *s) +wp_match(struct wildpatt *w, const char *s) { struct dfa_state *d; @@ -157,12 +157,12 @@ wp_match(struct wildpatt *w, const byte *s) d = w->dfa_start; while (*s) { - uintptr_t next = d->edge[*s]; + uintptr_t next = d->edge[(unsigned char)*s]; if (next & 1) { /* Need to lookup/create the destination state */ struct dfa_state *new = wp_new_state(w, next & ~1); - d->edge[*s] = (uintptr_t) new; + d->edge[(unsigned char)*s] = (uintptr_t) new; d = new; } else if (!next) @@ -175,7 +175,7 @@ wp_match(struct wildpatt *w, const byte *s) } int -wp_min_size(const byte *p) +wp_min_size(const char *p) { int s = 0; diff --git a/lib/wildmatch.h b/lib/wildmatch.h index a429da13..6c7b21a7 100644 --- a/lib/wildmatch.h +++ b/lib/wildmatch.h @@ -10,6 +10,6 @@ struct wildpatt; struct mempool; -struct wildpatt *wp_compile(const byte *, struct mempool *); -int wp_match(struct wildpatt *, const byte *); -int wp_min_size(const byte *); +struct wildpatt *wp_compile(const char *, struct mempool *); +int wp_match(struct wildpatt *, const char *); +int wp_min_size(const char *); -- 2.39.2