[pan2: 18/68] Update filter-info and scorefile-test to support non-overview headers.
- From: Petr Kovář <pmkovar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 18/68] Update filter-info and scorefile-test to support non-overview headers.
- Date: Tue, 8 Feb 2011 22:59:32 +0000 (UTC)
commit 35da81bfbd2ad1cd67aa409860b71a106fa37008
Author: K. Haley <haleykd users sf net>
Date: Mon Mar 22 23:32:03 2010 -0600
Update filter-info and scorefile-test to support non-overview headers.
pan/data-impl/article-filter.cc | 1 +
pan/usenet-utils/filter-info.cc | 10 ++++++++++
pan/usenet-utils/filter-info.h | 3 +++
pan/usenet-utils/scorefile-test.cc | 18 +++++++++++++++---
4 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/pan/data-impl/article-filter.cc b/pan/data-impl/article-filter.cc
index 315131a..f5a9e45 100644
--- a/pan/data-impl/article-filter.cc
+++ b/pan/data-impl/article-filter.cc
@@ -49,6 +49,7 @@ ArticleFilter :: test_article (const Data & data,
const Quark & group,
const Article & article) const
{
+ const ArticleCache & cache(data.get_cache());
bool pass (false);
switch (criteria._type)
{
diff --git a/pan/usenet-utils/filter-info.cc b/pan/usenet-utils/filter-info.cc
index 3ca2ec3..2e25835 100644
--- a/pan/usenet-utils/filter-info.cc
+++ b/pan/usenet-utils/filter-info.cc
@@ -40,6 +40,7 @@ FilterInfo :: clear ()
_text.clear ();
_aggregates.clear ();
_negate = false;
+ _needs_body = false;
}
void
@@ -75,10 +76,19 @@ void
FilterInfo :: set_type_text (const Quark & header,
const TextMatch::Description & text)
{
+ static const Quark subject("Subject"), from("From"),
+ xref("Xref"), references("References"), newsgroups("Newsgroups"),
+ message_Id("Message-Id"), message_ID("Message-ID");
+
clear ();
_type = TEXT;
_header = header;
_text.set (text);
+
+ if( !(header == subject || header == from || header == message_Id ||
+ header == message_ID || header == newsgroups || header == references ||
+ header == xref) )
+ _needs_body = true;
}
/****
diff --git a/pan/usenet-utils/filter-info.h b/pan/usenet-utils/filter-info.h
index e573a68..13e53ac 100644
--- a/pan/usenet-utils/filter-info.h
+++ b/pan/usenet-utils/filter-info.h
@@ -82,6 +82,9 @@ namespace pan
/** When this is true, the results of the test should be negated. */
bool _negate;
+ /** When this is true the test needs the article body. */
+ bool _needs_body;
+
private:
void set_type_is (Type type);
void set_type_ge (Type type, unsigned long ge);
diff --git a/pan/usenet-utils/scorefile-test.cc b/pan/usenet-utils/scorefile-test.cc
index 858e9d8..35f49a0 100644
--- a/pan/usenet-utils/scorefile-test.cc
+++ b/pan/usenet-utils/scorefile-test.cc
@@ -63,14 +63,18 @@ main( )
" {:\n"
" Subject: ^Re:\n"
" ~Subject: ^Re:.*\\c[a-z]\n"
- " }\n";
+ " }\n"
+ "\n"
+ "[alt.filters]\n"
+ " Score: -10\n"
+ " foo: filter\n";
const std::string filename = "/home/charles/News/Score";
Scorefile scorefile (my_ftr);
scorefile.parse_file (filename);
const Scorefile::sections_t& sections (scorefile.get_sections());
- check (sections.size() == 2)
+ check (sections.size() == 3)
const Scorefile::Section& section (sections[0]);
check (!section.negate)
check (section.name == "news.software.readers")
@@ -217,7 +221,15 @@ main( )
check (item.test._aggregates[1]._aggregates[1]._text.get_state().case_sensitive == false)
check (item.test._aggregates[1]._aggregates[1]._text.get_state().text == "^Re:.*\\c[a-z]")
-
+// "[alt.filters]\n"
+// " Score: -10\n"
+// " foo: filter\n";
+ const Scorefile::Section& s3 (sections[2]);
+ check (s3.negate == false)
+ check (s3.name == "alt.filters")
+ check (s3.items.size()==1)
+ item = s3.items[0];
+ check(item.test._needs_body == true)
#if 0
Scorefile::Item = sectionscheck
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]