diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-23 11:51:53 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-23 11:51:53 +0100 |
commit | c5e769ec0ce3d7347276809d79d7dcb81aae8324 (patch) | |
tree | aa3f55253232d2a2de9faa9a8370e1c1b956334a /src | |
parent | 00f687383ae2ea5f3e39840989541e4704887f01 (diff) | |
download | rspamd-c5e769ec0ce3d7347276809d79d7dcb81aae8324.tar.gz rspamd-c5e769ec0ce3d7347276809d79d7dcb81aae8324.zip |
Allow conditional build of snowball.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/libmime/message.c | 16 | ||||
-rw-r--r-- | src/libstat/tokenizers/osb.c | 1 | ||||
-rw-r--r-- | src/rspamadm/CMakeLists.txt | 5 |
4 files changed, 21 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 17ff6ebe5..b58067210 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,7 +108,9 @@ IF(NOT DEBIAN_BUILD) ENDIF(NOT DEBIAN_BUILD) TARGET_LINK_LIBRARIES(rspamd rspamd-server) -TARGET_LINK_LIBRARIES(rspamd stemmer) +IF (ENABLE_SNOWBALL MATCHES "ON") + TARGET_LINK_LIBRARIES(rspamd stemmer) +ENDIF() TARGET_LINK_LIBRARIES(rspamd rspamd-actrie) TARGET_LINK_LIBRARIES(rspamd ${RSPAMD_REQUIRED_LIBRARIES}) diff --git a/src/libmime/message.c b/src/libmime/message.c index 591107ba4..845f2f804 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -31,7 +31,11 @@ #include "images.h" #include "utlist.h" #include "tokenizers/tokenizers.h" + +#ifdef WITH_SNOWBALL #include "libstemmer.h" +#endif + #include "acism.h" #include <iconv.h> @@ -947,13 +951,16 @@ static void rspamd_normalize_text_part (struct rspamd_task *task, struct mime_text_part *part) { +#ifdef WITH_SNOWBALL struct sb_stemmer *stem = NULL; +#endif rspamd_ftok_t *w; const guchar *r; gchar *temp_word; guint i, nlen; GArray *tmp; +#ifdef WITH_SNOWBALL if (part->language && part->language[0] != '\0' && IS_PART_UTF (part)) { stem = sb_stemmer_new (part->language, "UTF_8"); if (stem == NULL) { @@ -961,6 +968,7 @@ rspamd_normalize_text_part (struct rspamd_task *task, task->message_id, part->language); } } +#endif /* Ugly workaround */ tmp = rspamd_tokenize_text (part->content->data, @@ -971,12 +979,15 @@ rspamd_normalize_text_part (struct rspamd_task *task, if (tmp) { for (i = 0; i < tmp->len; i ++) { w = &g_array_index (tmp, rspamd_ftok_t, i); + r = NULL; +#ifdef WITH_SNOWBALL if (stem) { r = sb_stemmer_stem (stem, w->begin, w->len); } +#endif if (w->len > 0 && !(w->len == 6 && memcmp (w->begin, "!!EX!!", 6) == 0)) { - if (stem != NULL && r != NULL) { + if (r != NULL) { nlen = strlen (r); nlen = MIN (nlen, w->len); temp_word = rspamd_mempool_alloc (task->task_pool, nlen); @@ -1001,10 +1012,11 @@ rspamd_normalize_text_part (struct rspamd_task *task, } part->normalized_words = tmp; } - +#ifdef WITH_SNOWBALL if (stem != NULL) { sb_stemmer_delete (stem); } +#endif } #define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c))) diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index 7744e2883..20fc6ece8 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -28,7 +28,6 @@ #include "tokenizers.h" #include "stat_internal.h" -#include "libstemmer.h" #include "xxhash.h" #include "cryptobox.h" diff --git a/src/rspamadm/CMakeLists.txt b/src/rspamadm/CMakeLists.txt index 20cf3b3a0..7d693c388 100644 --- a/src/rspamadm/CMakeLists.txt +++ b/src/rspamadm/CMakeLists.txt @@ -11,7 +11,10 @@ SET(RSPAMADMSRC rspamadm.c commands.c pw.c keypair.c configtest.c ADD_EXECUTABLE(rspamadm ${RSPAMADMSRC}) TARGET_LINK_LIBRARIES(rspamadm rspamd-server) TARGET_LINK_LIBRARIES(rspamadm ${RSPAMD_REQUIRED_LIBRARIES}) -TARGET_LINK_LIBRARIES(rspamadm stemmer) + +IF (ENABLE_SNOWBALL MATCHES "ON") + TARGET_LINK_LIBRARIES(rspamadm stemmer) +ENDIF() TARGET_LINK_LIBRARIES(rspamadm rspamd-actrie) IF (NOT DEBIAN_BUILD) |