updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / rtorrent-extended / ex_equal_operator.patch
bloba4ba8ab0730222444288321214a1d9d97ef262ee
1 diff --git a/src/command_ui.cc b/src/command_ui.cc
2 index 915c2f0..977b9bb 100644
3 --- a/src/command_ui.cc
4 +++ b/src/command_ui.cc
5 @@ -210,7 +210,7 @@ apply_or(rpc::target_type target, const torrent::Object& rawArgs) {
8 torrent::Object
9 -apply_less(rpc::target_type target, const torrent::Object& rawArgs) {
10 +apply_cmp(rpc::target_type target, const torrent::Object& rawArgs) {
11 const torrent::Object::list_type& args = rawArgs.as_list();
13 // We only need to check if empty() since if size() == 1 it calls
14 @@ -237,16 +237,25 @@ apply_less(rpc::target_type target, const torrent::Object& rawArgs) {
15 throw torrent::input_error("Type mismatch.");
17 switch (result1.type()) {
18 - case torrent::Object::TYPE_VALUE: return result1.as_value() < result2.as_value();
19 - case torrent::Object::TYPE_STRING: return result1.as_string() < result2.as_string();
20 - default: return (int64_t)false;
21 + case torrent::Object::TYPE_VALUE: return result1.as_value() - result2.as_value();
22 + case torrent::Object::TYPE_STRING: return result1.as_string().compare(result2.as_string());
23 + default: return torrent::Object();
27 -// Fixme.
28 -torrent::Object
29 -apply_greater(rpc::target_type target, const torrent::Object& rawArgs) {
30 - return (int64_t)!apply_less(target, rawArgs).as_value();
31 +torrent::Object apply_less(rpc::target_type target, const torrent::Object& rawArgs) {
32 + torrent::Object result = apply_cmp(target, rawArgs);
33 + return result.is_value() ? result.as_value() < 0 : (int64_t)false;
36 +torrent::Object apply_greater(rpc::target_type target, const torrent::Object& rawArgs) {
37 + torrent::Object result = apply_cmp(target, rawArgs);
38 + return result.is_value() ? result.as_value() > 0 : (int64_t)false;
41 +torrent::Object apply_equal(rpc::target_type target, const torrent::Object& rawArgs) {
42 + torrent::Object result = apply_cmp(target, rawArgs);
43 + return result.is_value() ? result.as_value() == 0 : (int64_t)false;
46 torrent::Object
47 @@ -506,6 +515,7 @@ initialize_command_ui() {
49 ADD_ANY_LIST("less", rak::ptr_fn(&apply_less));
50 ADD_ANY_LIST("greater", rak::ptr_fn(&apply_greater));
51 + ADD_ANY_LIST("equal", rak::ptr_fn(&apply_equal));
53 // A temporary command for handling stuff until we get proper
54 // support for seperation of commands and literals.