aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzy.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-23 14:10:07 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-23 14:10:07 +0300
commitc79b5ccd22cbc1c273479f4f88189a18effda533 (patch)
tree1741743779a70146a61cd1767936aa43d671e36b /src/fuzzy.c
parentafdaddc4d0745a5bcefad73dd74fd4c03ae3de15 (diff)
downloadrspamd-c79b5ccd22cbc1c273479f4f88189a18effda533.tar.gz
rspamd-c79b5ccd22cbc1c273479f4f88189a18effda533.zip
* Fix error in expression parser that causes bad errors with expressions that have regexp at the end
* Improve test for fuzzy hashes * Add new object - TextPart to perl XS library that allows access to stripped parts and fuzzy hashes * Add documentation for expressions parser and fot Mail::Rspamd::TextPart * Allways calculate fuzzy hash for text parts * Store text parts separately from other parts * Add compare_parts_distance for expressions that calculates difference in 2 parts messages * Do not try to substitute variables in empty strings
Diffstat (limited to 'src/fuzzy.c')
-rw-r--r--src/fuzzy.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/fuzzy.c b/src/fuzzy.c
index 08814eaa1..4dfec3fb7 100644
--- a/src/fuzzy.c
+++ b/src/fuzzy.c
@@ -95,7 +95,7 @@ fuzzy_update (fuzzy_hash_t *h, char c)
if (h->rh % h->block_size == (h->block_size - 1)) {
h->hash_pipe[h->hi] = h->h;
- if (h->hi < FUZZY_HASHLEN - 1) {
+ if (h->hi < FUZZY_HASHLEN - 2) {
h->h = HASH_INIT;
h->hi ++;
}
@@ -249,6 +249,17 @@ fuzzy_init (f_str_t *in, memory_pool_t *pool)
return new;
}
+fuzzy_hash_t *
+fuzzy_init_byte_array (GByteArray *in, memory_pool_t *pool)
+{
+ f_str_t f;
+
+ f.begin = in->data;
+ f.len = in->len;
+
+ return fuzzy_init (&f, pool);
+}
+
/* Compare score of difference between two hashes 0 - different hashes, 100 - identical hashes */
int
fuzzy_compare_hashes (fuzzy_hash_t *h1, fuzzy_hash_t *h2)