From e9c6568a5753fb6f3407a6796d65d6e4107f50e0 Mon Sep 17 00:00:00 2001 From: Stig Brautaset Date: Sat, 3 Dec 2016 23:17:26 +0000 Subject: [PATCH] mu: swap begin and end if begin is _numerically_ bigger than end The old behaviour would compare the strings, so would swap the start and end ranges if start was 3K and end was 2M. Fixes: 964 --- lib/mu-query.cc | 6 +++--- mu/tests/test-mu-query.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/mu-query.cc b/lib/mu-query.cc index 5761f2a0..a32094d5 100644 --- a/lib/mu-query.cc +++ b/lib/mu-query.cc @@ -115,13 +115,13 @@ public: if (!substitute_size (begin) || !substitute_size (end)) return Xapian::BAD_VALUENO; + begin = Xapian::sortable_serialise (atol(begin.c_str())); + end = Xapian::sortable_serialise (atol(end.c_str())); + /* swap if b > e */ if (begin > end) std::swap (begin, end); - begin = Xapian::sortable_serialise (atol(begin.c_str())); - end = Xapian::sortable_serialise (atol(end.c_str())); - return (Xapian::valueno)MU_MSG_FIELD_ID_SIZE; } private: diff --git a/mu/tests/test-mu-query.c b/mu/tests/test-mu-query.c index 373d017e..73cbd3f4 100644 --- a/mu/tests/test-mu-query.c +++ b/mu/tests/test-mu-query.c @@ -507,6 +507,7 @@ test_mu_query_sizes (void) int i; QResults queries[] = { { "size:0b..2m", 19}, + { "size:3b..2m", 19}, { "size:2k..4k", 4}, { "size:2m..0b", 19} };