aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ts_bm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ts_bm.c')
-rw-r--r--lib/ts_bm.c11
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
114static void compute_prefix_tbl(struct ts_bm *bm, const u8 *pattern, 114static 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}