# add a boolean equal=arg1,arg2 operator that returns # true if both arguments are equal Index: rtorrent/src/command_ui.cc =================================================================== --- rtorrent/src/command_ui.cc (revision 1121) +++ rtorrent/src/command_ui.cc (working copy) @@ -210,7 +210,7 @@ } torrent::Object -apply_less(rpc::target_type target, const torrent::Object& rawArgs) { +apply_cmp(rpc::target_type target, const torrent::Object& rawArgs) { const torrent::Object::list_type& args = rawArgs.as_list(); // We only need to check if empty() since if size() == 1 it calls @@ -237,18 +237,27 @@ throw torrent::input_error("Type mismatch."); switch (result1.type()) { - case torrent::Object::TYPE_VALUE: return result1.as_value() < result2.as_value(); - case torrent::Object::TYPE_STRING: return result1.as_string() < result2.as_string(); - default: return (int64_t)false; + case torrent::Object::TYPE_VALUE: return result1.as_value() - result2.as_value(); + case torrent::Object::TYPE_STRING: return result1.as_string().compare(result2.as_string()); + default: return torrent::Object(); } } -// Fixme. -torrent::Object -apply_greater(rpc::target_type target, const torrent::Object& rawArgs) { - return (int64_t)!apply_less(target, rawArgs).as_value(); +torrent::Object apply_less(rpc::target_type target, const torrent::Object& rawArgs) { + torrent::Object result = apply_cmp(target, rawArgs); + return result.is_value() ? result.as_value() < 0 : (int64_t)false; } +torrent::Object apply_greater(rpc::target_type target, const torrent::Object& rawArgs) { + torrent::Object result = apply_cmp(target, rawArgs); + return result.is_value() ? result.as_value() > 0 : (int64_t)false; +} + +torrent::Object apply_equal(rpc::target_type target, const torrent::Object& rawArgs) { + torrent::Object result = apply_cmp(target, rawArgs); + return result.is_value() ? result.as_value() == 0 : (int64_t)false; +} + torrent::Object apply_to_time(int flags, const torrent::Object& rawArgs) { std::tm *u; @@ -503,6 +512,7 @@ ADD_ANY_LIST("less", rak::ptr_fn(&apply_less)); ADD_ANY_LIST("greater", rak::ptr_fn(&apply_greater)); + ADD_ANY_LIST("equal", rak::ptr_fn(&apply_equal)); // A temporary command for handling stuff until we get proper // support for seperation of commands and literals.