[SCM] Development fot GoFind! branch, master, updated. 31f9511a3139a74c5f0d8a559a2e4dfe619752a3

Miriam Ruiz miriam at debian.org
Mon Apr 27 22:28:59 UTC 2009


The following commit has been merged in the master branch:
commit 31f9511a3139a74c5f0d8a559a2e4dfe619752a3
Author: Miriam Ruiz <miriam at debian.org>
Date:   Tue Apr 28 00:34:31 2009 +0200

    Improve filter loading

diff --git a/filter.cfg b/filter.cfg
index 32040c4..043b9f3 100644
--- a/filter.cfg
+++ b/filter.cfg
@@ -1,16 +1,18 @@
-<filter target="black">
-	<rule condition="sex::violent" />
-</filter>
-<filter target="red">
-	<rule condition="violence::non-realistic-optional" />
-	<rule condition="violence::non-realistic" />
-</filter>
-<filter target="yellow">
-	<rule condition="  issues::horror" />
-</filter>
-<filter target="yellow">
-	<rule condition="issues::horror&(issues::horror|issues::cruelty)" />
-</filter>
-<filter target="green">
-	<rule condition="violence::none & sex::none & !issues::bad-words & !  issues::discrimination    " />
-</filter>
+<gofind version="1">
+	<filter target="black">
+		<rule condition="sex::violent" />
+	</filter>
+	<filter target="red">
+		<rule condition="violence::non-realistic-optional" />
+		<rule condition="violence::non-realistic" />
+	</filter>
+	<filter target="yellow">
+		<rule condition="  issues::horror" />
+	</filter>
+	<filter target="yellow">
+		<rule condition="issues::horror&(issues::horror|issues::cruelty)" />
+	</filter>
+	<filter target="green">
+		<rule condition="violence::none & sex::none & !issues::bad-words & !  issues::discrimination    " />
+	</filter>
+</gofind>
\ No newline at end of file
diff --git a/filter.cpp b/filter.cpp
index 6385f8c..acab118 100644
--- a/filter.cpp
+++ b/filter.cpp
@@ -193,7 +193,13 @@ bool PackageFilter::Load(const char *filename)
 
 	//std::cout << doc;
 
-	for (rapidxml::xml_node<> *filter = doc.first_node("filter");
+	rapidxml::xml_node<> *data = doc.first_node("gofind");
+	if (!data) return false;
+	rapidxml::xml_attribute<> *version = data->first_attribute("version");
+	if (!version) return false;
+	if (atoi(version->value()) != 1) return false;
+
+	for (rapidxml::xml_node<> *filter = data->first_node("filter");
 			filter; filter = filter->next_sibling("filter"))
 	{
 		rapidxml::xml_attribute<> *target = filter->first_attribute("target");
@@ -206,64 +212,14 @@ bool PackageFilter::Load(const char *filename)
 			rapidxml::xml_attribute<> *condition = rule->first_attribute("condition");
 			if (!condition) break;
 			std::cout << condition->name() << " = " << condition->value() << std::endl;
-		}
-	}
-
-	return true;
-
-/*
-	struct slre_pattern pattern[1];
-	const char *pattern_text[1];
-	const char pattern_type[] = { 'd', '\0' };
-	pattern_text[0] = "^\\s*(\\S+)\\s*=\\s*((\\S|\\s)*\\S)\\s*$";
-	pattern_text[1] = NULL;
-
-	int j = 0;
-	while (pattern_text[j] != NULL)
-	{
-		if (!slre_compile(&pattern[j], pattern_text[j]))
-			std::cerr << _("Error compiling RE: ") << pattern[j].err_str << std::endl;
-		j++;
-	}
-
-	ifstream ifs(filename);
-	string line;
-	BoolParser parser;
-
-	while( getline( ifs, line ) )
-	{
-		//cout << "in: " << line << endl;
-		const char *buffer = line.c_str();
-		struct slre_capture captures[16];
-		int match = -1;
-		int j = 0;
-		while (match == -1 && pattern_text[j] != NULL)
-		{
-			if (slre_match(pattern+j, buffer, strlen(buffer), captures))
-			{
-				match = j;
-			}
-			j++;
-		}
-		if (match == -1)
-			cout << "Syntax Error" << std::endl;
-		else switch (pattern_type[match])
-		{
-			case 'd':
-			{
-				if (!AddLast( std::string(captures[2].ptr).substr(0,captures[2].len) ))
-					cerr << "Filter: Error Adding '"<< std::string(captures[1].ptr).substr(0,captures[1].len) << "'" << endl;
-				//else cerr << "Filter: Adding '"<< std::string(captures[1].ptr).substr(0,captures[1].len) << "'" << endl;
-				break;
-			}
+			if (!AddLast( condition->value() ))
+				std::cerr << "Error Adding '"<< condition->value() << "'" << endl;
 		}
 	}
 
 	Print(std::cerr);
 	std::cerr << std::endl;
-
 	return true;
-*/
 }
 
 /* Find out the color of a single tag */
@@ -331,7 +287,7 @@ bool PackageFilter::AddLast(const std::string &bool_expr)
 			std::cout << "result too large" << std::endl;
 			success = false;
 		}
-		//else std::cout << expr << std::endl;
+		else std::cout << expr << std::endl;
 
 		delete expr;
 	}

-- 
Development fot GoFind!



More information about the Pkg-games-commits mailing list