aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/aho-corasick
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-07 11:54:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-07 15:04:28 +0100
commitefaf25c90f01b79c8c6b83abc291334e61af37d1 (patch)
tree75efa8b86fcae2794d69139b8f3cd03e487b56b4 /contrib/aho-corasick
parentd2ebc3f96a3357cffd3189c2eaf3df7064e426af (diff)
downloadrspamd-efaf25c90f01b79c8c6b83abc291334e61af37d1.tar.gz
rspamd-efaf25c90f01b79c8c6b83abc291334e61af37d1.zip
Allow caseless trie search.
Diffstat (limited to 'contrib/aho-corasick')
-rw-r--r--contrib/aho-corasick/acism.c6
-rw-r--r--contrib/aho-corasick/acism.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/contrib/aho-corasick/acism.c b/contrib/aho-corasick/acism.c
index a4c678154..64e1eb956 100644
--- a/contrib/aho-corasick/acism.c
+++ b/contrib/aho-corasick/acism.c
@@ -24,15 +24,17 @@
int
acism_lookup(ac_trie_t const *psp, const char *text, size_t len,
- ACISM_ACTION *cb, void *context, int *statep)
+ ACISM_ACTION *cb, void *context, int *statep, bool caseless)
{
ac_trie_t const ps = *psp;
char const *cp = text, *endp = cp + len;
+ uint8_t s;
STATE state = *statep;
int ret = 0;
while (cp < endp) {
- _SYMBOL sym = ps.symv[(uint8_t)*cp++];
+ s = caseless ? g_ascii_tolower (*cp++) : *cp++;
+ _SYMBOL sym = ps.symv[s];
if (!sym) {
// Input byte is not in any pattern string.
state = ROOT;
diff --git a/contrib/aho-corasick/acism.h b/contrib/aho-corasick/acism.h
index 3886b149e..d942fd413 100644
--- a/contrib/aho-corasick/acism.h
+++ b/contrib/aho-corasick/acism.h
@@ -46,6 +46,6 @@ typedef int (ACISM_ACTION)(int strnum, int textpos, void *context);
// *state should initially be (0).
int acism_lookup(ac_trie_t const *psp, const char *text, size_t len,
- ACISM_ACTION *cb, void *context, int *statep);
+ ACISM_ACTION *cb, void *context, int *statep, bool caseless);
#endif//ACISM_H