Lines Matching +full:sigma +full:- +full:delta
2 * lib/ts_kmp.c Knuth-Morris-Pratt text search implementation
13 * Implements a linear-time string-matching algorithm due to Knuth,
15 * computation of the transition function DELTA altogether. Its
19 * the transition function DELTA to be computed efficiently
21 * "q" = 0,1,...,m and any character "a" in SIGMA, the value
23 * is needed to compute DELTA("q", "a") [2]. Since the array PI
24 * has only m entries, whereas DELTA has O(m|SIGMA|) entries, we
25 * save a factor of |SIGMA| in the preprocessing time by computing
26 * PI rather than DELTA.
49 unsigned int i, q = 0, text_len, consumed = state->offset; in kmp_find()
51 const int icase = conf->flags & TS_IGNORECASE; in kmp_find()
54 text_len = conf->get_next_block(consumed, &text, conf, state); in kmp_find()
60 while (q > 0 && kmp->pattern[q] in kmp_find()
62 q = kmp->prefix_tbl[q - 1]; in kmp_find()
63 if (kmp->pattern[q] in kmp_find()
66 if (unlikely(q == kmp->pattern_len)) { in kmp_find()
67 state->offset = consumed + i + 1; in kmp_find()
68 return state->offset - kmp->pattern_len; in kmp_find()
87 k = prefix_tbl[k-1]; in compute_prefix_tbl()
108 conf->flags = flags; in kmp_init()
110 kmp->pattern_len = len; in kmp_init()
111 compute_prefix_tbl(pattern, len, kmp->prefix_tbl, flags); in kmp_init()
112 kmp->pattern = (u8 *) kmp->prefix_tbl + prefix_tbl_len; in kmp_init()
115 kmp->pattern[i] = toupper(((u8 *)pattern)[i]); in kmp_init()
117 memcpy(kmp->pattern, pattern, len); in kmp_init()
125 return kmp->pattern; in kmp_get_pattern()
131 return kmp->pattern_len; in kmp_get_pattern_len()