diff --git a/src/config.cpp b/src/config.cpp index 613c3b0f914..a043b475e8c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -395,10 +395,17 @@ bool config::attribute_value::operator==(const config::attribute_value &other) c * Checks for equality of the attribute values when viewed as strings. * Exception: Boolean synonyms can be equal ("yes" == "true"). * Note: Blanks have no string representation, so do not equal "" (an empty string). + * Also note that translatable string are never equal to non translatable strings. */ bool config::attribute_value::equals(const std::string &str) const { - return boost::apply_visitor(boost::bind( equality_visitor(), _1, boost::cref(str) ), value_); + attribute_value v; + v = str; + return *this == v; + // if c["a"] = "1" then this solution would have resulted in c["a"] == "1" beeing false + // because a["a"] is '1' and not '"1"'. + // return boost::apply_visitor(boost::bind( equality_visitor(), _1, boost::cref(str) ), value_); + // that's why we don't use it. } std::ostream &operator<<(std::ostream &os, const config::attribute_value &v) diff --git a/src/config.hpp b/src/config.hpp index 436056580cd..5970e48a0f5 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -285,7 +285,6 @@ public: bool operator!=(const attribute_value &other) const { return !operator==(other); } - // returns always false if the underlying type is no string. bool equals(const std::string& str) const; // These function prevent t_string creation in case of c["a"] == "b" comparisons. // The templates are needed to prevent using these function in case of c["a"] == 0 comparisons.