Skip to content
Permalink
Browse files

Non-matching characters can skip f_len. Subtract 1 from f_len instead…

… of putting 'f_len - 1' all over the place.
  • Loading branch information
ggreer committed Aug 21, 2012
1 parent 7e5e7ba commit 43886f9b08d0772b54f21a291a0794d060f700f7
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/util.c
@@ -8,18 +8,20 @@


void generate_skip_lookup(const char *find, size_t f_len, size_t skip_lookup[], int case_sensitive) {
size_t i = 0;
size_t i;

for (i = 0; i < 256; i++) {
skip_lookup[i] = f_len - 1 || 1; /* Handle the case of f_len == 1 */
skip_lookup[i] = f_len;
}

for (i = 0; i < f_len - 1; i++) {
f_len--;

for (i = 0; i < f_len; i++) {
if (case_sensitive) {
skip_lookup[(unsigned char)find[i]] = f_len - i - 1;
skip_lookup[(unsigned char)find[i]] = f_len - i;
}
else {
skip_lookup[(unsigned char)tolower(find[i])] = f_len - i - 1;
skip_lookup[(unsigned char)tolower(find[i])] = f_len - i;
}
}
}

0 comments on commit 43886f9

Please sign in to comment.
You can’t perform that action at this time.