]> git.tdb.fi Git - builder.git/commitdiff
Fix Condition to handle booleans properly
authorMikko Rasa <tdb@tdb.fi>
Wed, 10 Feb 2010 14:46:45 +0000 (14:46 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 10 Feb 2010 14:46:45 +0000 (14:46 +0000)
source/condition.cpp

index 4c7b5ed5b2d923a8b308c975e470dbfdf75041b3..136b852fccd30c6e2b6ed2f7701ca8004e771c50 100644 (file)
@@ -25,9 +25,9 @@ Condition::Condition(SourcePackage &p, const string &expr):
 
                string::size_type token = i->find_first_of("=!");
                if(token==string::npos)
-                       expression.insert(StringMap::value_type(*i, "!0"));
+                       expression.insert(StringMap::value_type(*i, "="));
                else if(token==0 && (*i)[0]=='!')
-                       expression.insert(StringMap::value_type(*i, "=0"));
+                       expression.insert(StringMap::value_type(*i, "!"));
                else
                        expression.insert(StringMap::value_type(i->substr(0, token), i->substr(token)));
        }
@@ -48,7 +48,12 @@ bool Condition::eval()
 
                bool match = false;
                if(conf.is_option(i->first))
-                       match = (conf.get_option(i->first).value==value);
+               {
+                       if(value.empty())
+                               match = lexical_cast<bool>(conf.get_option(i->first).value);
+                       else
+                               match = (conf.get_option(i->first).value==value);
+               }
                else if(i->first=="arch")
                        match = pkg.get_builder().get_current_arch().match_name(value);