X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=lib%2Fts_fsm.c;h=5696a35184e4a3a086573c6020b9f32fcede5fe2;hb=4daf7a0c0b3dd3c2e2ec829ecee8608d04d67773;hp=ef9779e005062d79de05f00cff7c0aa1ee3a24a3;hpb=3d2aef668920e8d93b77f145f8f647f62abe75db;p=safe%2Fjmp%2Flinux-2.6 diff --git a/lib/ts_fsm.c b/lib/ts_fsm.c index ef9779e..5696a35 100644 --- a/lib/ts_fsm.c +++ b/lib/ts_fsm.c @@ -12,13 +12,13 @@ * * A finite state machine consists of n states (struct ts_fsm_token) * representing the pattern as a finite automation. The data is read - * sequentially on a octet basis. Every state token specifies the number + * sequentially on an octet basis. Every state token specifies the number * of recurrences and the type of value accepted which can be either a * specific character or ctype based set of characters. The available * type of recurrences include 1, (0|1), [0 n], and [1 n]. * - * The algorithm differs between strict/non-strict mode specyfing - * whether the pattern has to start at the first octect. Strict mode + * The algorithm differs between strict/non-strict mode specifying + * whether the pattern has to start at the first octet. Strict mode * is enabled by default and can be disabled by inserting * TS_FSM_HEAD_IGNORE as the first token in the chain. * @@ -26,7 +26,6 @@ * however while in strict mode the average runtime can be better. */ -#include #include #include #include @@ -45,7 +44,7 @@ struct ts_fsm #define _W 0x200 /* wildcard */ /* Map to _ctype flags and some magic numbers */ -static u16 token_map[TS_FSM_TYPE_MAX+1] = { +static const u16 token_map[TS_FSM_TYPE_MAX+1] = { [TS_FSM_SPECIFIC] = 0, [TS_FSM_WILDCARD] = _W, [TS_FSM_CNTRL] = _C, @@ -62,7 +61,7 @@ static u16 token_map[TS_FSM_TYPE_MAX+1] = { [TS_FSM_ASCII] = _A, }; -static u16 token_lookup_tbl[256] = { +static const u16 token_lookup_tbl[256] = { _W|_A|_C, _W|_A|_C, _W|_A|_C, _W|_A|_C, /* 0- 3 */ _W|_A|_C, _W|_A|_C, _W|_A|_C, _W|_A|_C, /* 4- 7 */ _W|_A|_C, _W|_A|_C|_S, _W|_A|_C|_S, _W|_A|_C|_S, /* 8- 11 */ @@ -258,7 +257,7 @@ found_match: } static struct ts_config *fsm_init(const void *pattern, unsigned int len, - unsigned int __nocast gfp_mask) + gfp_t gfp_mask, int flags) { int i, err = -EINVAL; struct ts_config *conf; @@ -270,6 +269,9 @@ static struct ts_config *fsm_init(const void *pattern, unsigned int len, if (len % sizeof(struct ts_fsm_token) || ntokens < 1) goto errout; + if (flags & TS_IGNORECASE) + goto errout; + for (i = 0; i < ntokens; i++) { struct ts_fsm_token *t = &tokens[i]; @@ -285,6 +287,7 @@ static struct ts_config *fsm_init(const void *pattern, unsigned int len, if (IS_ERR(conf)) return conf; + conf->flags = flags; fsm = ts_config_priv(conf); fsm->ntokens = ntokens; memcpy(fsm->tokens, pattern, len);