Skip to content

Commit

Permalink
textsearch: fix Boyer-Moore text search bug
Browse files Browse the repository at this point in the history
The current logic has a bug which cannot find matching pattern, if the
pattern is matched from the first character of target string.
for example:
	pattern=abc, string=abcdefg
	pattern=a,   string=abcdefg
Searching algorithm should return 0 for those things.

Signed-off-by: Joonwoo Park <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
joonwpark authored and davem330 committed Jun 30, 2008
1 parent 84ebe1c commit aebb6a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ts_bm.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static unsigned int bm_find(struct ts_config *conf, struct ts_state *state)
struct ts_bm *bm = ts_config_priv(conf);
unsigned int i, text_len, consumed = state->offset;
const u8 *text;
int shift = bm->patlen, bs;
int shift = bm->patlen - 1, bs;

for (;;) {
text_len = conf->get_next_block(consumed, &text, conf, state);
Expand Down

0 comments on commit aebb6a8

Please sign in to comment.