diff options
author | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-08-27 22:59:59 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-08-27 22:59:59 -0400 |
commit | 8ce7a9c159c8c4eb480f0a65c6af753dbf9a1a70 (patch) | |
tree | be59573c0af3617d0cd8a7d61f0ed119e58b1156 /lib/ts_bm.c | |
parent | d2afb3ae04e36dbc6e9eb2d8bd54406ff7b6b3bd (diff) | |
parent | 01da5fd83d6b2c5e36b77539f6cbdd8f49849225 (diff) |
Merge ../linux-2.6
Diffstat (limited to 'lib/ts_bm.c')
-rw-r--r-- | lib/ts_bm.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/ts_bm.c b/lib/ts_bm.c index 0110e4414805..d90822c378a4 100644 --- a/lib/ts_bm.c +++ b/lib/ts_bm.c | |||
@@ -111,15 +111,14 @@ static int subpattern(u8 *pattern, int i, int j, int g) | |||
111 | return ret; | 111 | return ret; |
112 | } | 112 | } |
113 | 113 | ||
114 | static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern, | 114 | static void compute_prefix_tbl(struct ts_bm *bm) |
115 | unsigned int len) | ||
116 | { | 115 | { |
117 | int i, j, g; | 116 | int i, j, g; |
118 | 117 | ||
119 | for (i = 0; i < ASIZE; i++) | 118 | for (i = 0; i < ASIZE; i++) |
120 | bm->bad_shift[i] = len; | 119 | bm->bad_shift[i] = bm->patlen; |
121 | for (i = 0; i < len - 1; i++) | 120 | for (i = 0; i < bm->patlen - 1; i++) |
122 | bm->bad_shift[pattern[i]] = len - 1 - i; | 121 | bm->bad_shift[bm->pattern[i]] = bm->patlen - 1 - i; |
123 | 122 | ||
124 | /* Compute the good shift array, used to match reocurrences | 123 | /* Compute the good shift array, used to match reocurrences |
125 | * of a subpattern */ | 124 | * of a subpattern */ |
@@ -150,8 +149,8 @@ static struct ts_config *bm_init(const void *pattern, unsigned int len, | |||
150 | bm = ts_config_priv(conf); | 149 | bm = ts_config_priv(conf); |
151 | bm->patlen = len; | 150 | bm->patlen = len; |
152 | bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len; | 151 | bm->pattern = (u8 *) bm->good_shift + prefix_tbl_len; |
153 | compute_prefix_tbl(bm, pattern, len); | ||
154 | memcpy(bm->pattern, pattern, len); | 152 | memcpy(bm->pattern, pattern, len); |
153 | compute_prefix_tbl(bm); | ||
155 | 154 | ||
156 | return conf; | 155 | return conf; |
157 | } | 156 | } |