X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcondition.cpp;h=c80134d237a7707a4f439b7cebd17ff62c9b582d;hb=e89616b514c77e189b93d5a46aa5a5a72e34c3cb;hp=314d9c93688c592f80d9c07452cedb2c31be8cb7;hpb=04c316da6d5d90e43cba262f54d90ca231f703bf;p=builder.git diff --git a/source/condition.cpp b/source/condition.cpp index 314d9c9..c80134d 100644 --- a/source/condition.cpp +++ b/source/condition.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of builder -Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #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(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; }