]> git.tdb.fi Git - builder.git/blobdiff - source/condition.cpp
Remove dead code
[builder.git] / source / condition.cpp
index 314d9c93688c592f80d9c07452cedb2c31be8cb7..c80134d237a7707a4f439b7cebd17ff62c9b582d 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of builder
-Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <msp/strings/utils.h>
 #include "builder.h"
 #include "condition.h"
@@ -25,9 +18,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->substr(1), "!"));
                else
                        expression.insert(StringMap::value_type(i->substr(0, token), i->substr(token)));
        }
@@ -44,14 +37,20 @@ bool Condition::eval()
                unsigned start = 1;
                if(i->second[1]=='=')
                        ++start;
+               string value = i->second.substr(start);
 
-               string value;
+               bool match = false;
                if(conf.is_option(i->first))
-                       value = conf.get_option(i->first).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")
-                       value = pkg.get_builder().get_current_arch().get_name();
+                       match = pkg.get_builder().get_current_arch().match_name(value);
 
-               if((value==i->second.substr(start))==neg)
+               if(match==neg)
                        result = false;
        }