[SCM] Development fot GoFind! branch, master, updated. a3928cc51865fbfad44d9d41cc428b54813e904d
Miriam Ruiz
miriam at miriam.princast.es
Mon Nov 24 14:35:52 UTC 2008
The following commit has been merged in the master branch:
commit a3928cc51865fbfad44d9d41cc428b54813e904d
Author: Miriam Ruiz <miriam at miriam.princast.es>
Date: Mon Nov 24 15:40:17 2008 +0100
Command line option to select GUI plugin
Improved parsering of filtering configuration
diff --git a/GamesOptions.h b/GamesOptions.h
index f4f172f..53a5f9b 100644
--- a/GamesOptions.h
+++ b/GamesOptions.h
@@ -31,6 +31,7 @@ struct GamesOptions : public StandardParserWithManpage
public:
BoolOption* out_debug;
BoolOption* out_verbose;
+ StringOption* gui;
StringOption* gowhere;
StringOption* mainFacet;
StringOption* secondaryFacet;
@@ -45,10 +46,14 @@ public:
"GoPlay! is a Graphical User Interface (GUI) that uses DebTags"
" for finding games in Debian easily.\n";
+ // add( name, shortName, longName, usage, description )
+
out_verbose = add<BoolOption>("verbose", 'v', "verbose", "",
"enable verbose output");
out_debug = add<BoolOption>("debug", 0, "debug", "",
"enable debugging output (including verbose output)");
+ gui = add<StringOption>("gui", 0, "gui", "plugin",
+ "select the user interface flavour. ");
gowhere = add<StringOption>("go", 0, "go", "where",
"change the interface flavour. "
"Available flavours are: play, learn, admin, net, office, safe, web");
diff --git a/boolparser.cpp b/boolparser.cpp
index 9011760..461de07 100644
--- a/boolparser.cpp
+++ b/boolparser.cpp
@@ -122,6 +122,8 @@ BoolExpr<string> * BoolParser::parseString() throw(Error)
if (curIndex == inputLen)
throw Error(curIndex, Error::STRING_EXPECTED);
size_t startIndex = curIndex;
+ if (curIndex < inputLen && isStartingStringChar(curInput[curIndex]))
+ curIndex++;
while (curIndex < inputLen && isStringChar(curInput[curIndex]))
curIndex++;
if (curIndex == startIndex)
@@ -159,7 +161,12 @@ void BoolParser::skipSpaces()
}
// TODO: support UTF8
-bool BoolParser::isStringChar(char c) const
+bool BoolParser::isStartingStringChar(char c) const
{
return isalnum(c) || c == ':' || c == '_';
}
+
+bool BoolParser::isStringChar(char c) const
+{
+ return isalnum(c) || c == ':' || c == '_' || c == '-';
+}
diff --git a/boolparser.h b/boolparser.h
index 0353fd8..753f19e 100644
--- a/boolparser.h
+++ b/boolparser.h
@@ -82,6 +82,9 @@ public:
*/
boolstuff::BoolExpr<std::string> *parse(const std::string &expr) throw(Error);
+ bool isStartingStringChar(char c) const;
+ bool isStringChar(char c) const;
+
private:
std::string curInput;
@@ -98,7 +101,6 @@ private:
bool tokenSeen(const char *s);
void skipToken(const char *s);
void skipSpaces();
- bool isStringChar(char c) const;
// Forbidden operations:
BoolParser(const BoolParser &);
diff --git a/filter.cfg b/filter.cfg
index 7926d98..70a8488 100644
--- a/filter.cfg
+++ b/filter.cfg
@@ -1,5 +1,6 @@
black=rating:sex::violence
red=rating:violence::non-realistic:optional
red=rating:violence::non-realistic
-yellow = rating:theme::horror
+yellow = rating:theme::horror-optional
+yellow = rating:theme::horror-optional&(rating:theme::horror-optional|rating:theme::horror2-optional)
green = rating:violence::none & rating:sex::none & rating:language::benign & rating:discrimination::none
diff --git a/filter.cpp b/filter.cpp
index fedb1ce..d47d930 100644
--- a/filter.cpp
+++ b/filter.cpp
@@ -178,10 +178,11 @@ bool PackageFilter::Load(const char *filename)
ifstream ifs(filename);
string line;
+ BoolParser parser;
while( getline( ifs, line ) )
{
- cout << "in: " << line << endl;
+ //cout << "in: " << line << endl;
const char *buffer = line.c_str();
struct slre_capture captures[16];
int match = -1;
@@ -200,8 +201,9 @@ bool PackageFilter::Load(const char *filename)
{
case 'd':
{
- cout << "Assign: '"<< std::string(captures[1].ptr).substr(0,captures[1].len) <<
- "' := \"" << std::string(captures[2].ptr).substr(0,captures[2].len) << "\"" << endl;
+ 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;
}
}
@@ -263,7 +265,7 @@ int PackageFilter::TagsValue(const TagSet &tags)
return PackageFilter::Unknown;
}
-void PackageFilter::AddLast(const char * bool_expr)
+bool PackageFilter::AddLast(const std::string &bool_expr)
{
bool success = true;
BoolParser parser;
@@ -273,15 +275,12 @@ void PackageFilter::AddLast(const char * bool_expr)
assert(expr != NULL);
expr = boolstuff::BoolExpr<std::string>::getDisjunctiveNormalForm(expr);
- if (expr != NULL)
- std::cout << expr;
- else
+ if (expr == NULL)
{
- std::cout << "result too large";
+ std::cout << "result too large" << std::endl;
success = false;
}
-
- std::cout << std::endl;
+ //else std::cout << expr << std::endl;
delete expr;
}
@@ -304,6 +303,12 @@ void PackageFilter::AddLast(const char * bool_expr)
std::cout << std::endl;
success = false;
}
+
+ if (success)
+ {
+ }
+
+ return success;
}
#ifdef UNIT_TEST
diff --git a/filter.h b/filter.h
index 5d337bd..40b00a1 100644
--- a/filter.h
+++ b/filter.h
@@ -87,7 +87,7 @@ protected:
list->GetLast()->next = old_list;
}
- void AddLast(const char * bool_expr);
+ bool AddLast(const std::string &bool_expr);
inline void AddLast(PackageFilter::ResultList *new_list) {
if (!list) { list = new_list; }
diff --git a/gofind.cpp b/gofind.cpp
index 49b3cfe..f53e9bf 100644
--- a/gofind.cpp
+++ b/gofind.cpp
@@ -90,17 +90,6 @@ int main(int argc, const char* argv[])
bindtextdomain ("gofind", NULL);
#endif
- GUIPlugIn gui_plugin( "./gui_fltk.so" );
-
- if( gui_plugin.LastError())
- {
- std::cout << _("Could not load GUI plugin.") << std::endl;
- return -1;
- }
-
- gui_plugin.Init(argc, argv);
- gui_plugin.Comment(_("Starting system"));
-
wibble::commandline::GamesOptions opts;
try {
@@ -116,6 +105,18 @@ int main(int argc, const char* argv[])
if (opts.out_debug->boolValue())
::Environment::get().debug(true);
+ std::string plugin_file = opts.gui->isSet() ? std::string("./gui_") + opts.gui->stringValue() + std::string(".so") : "./gui_fltk.so";
+ GUIPlugIn gui_plugin( plugin_file.c_str() );
+
+ if( gui_plugin.LastError())
+ {
+ std::cout << _("Could not load GUI plugin.") << std::endl;
+ return -1;
+ }
+
+ gui_plugin.Init(argc, argv);
+ gui_plugin.Comment(_("Starting system"));
+
PackageData pkgdata;
if (wibble::str::endsWith(argv[0], "learn") || opts.gowhere->stringValue() == "learn")
--
Development fot GoFind!
More information about the Pkg-games-commits
mailing list