From 3f4daeacf039014df66678ea8ef5306b8b47298e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 27 Aug 2015 23:22:28 -0400 Subject: [PATCH] TW-1670: Reversed ranges are parsed as a mathematician would expect - Thanks to Daniel Shahaf. --- ChangeLog | 2 ++ src/CLI2.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7512ed7d0..eb7a5f6d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -127,6 +127,8 @@ to Daniel Shahaf). - TW-1664 Notify of waiting→pending promotion (thanks to Daniel Shahaf). - TW-1666 import should reject invalid data (thanks to Daniel Shahaf). +- TW-1670 Reversed ranges are parsed as a mathematician would expect (thanks to + Daniel Shahaf). - TW-1671 task add: segfault with foo-bar:1 (thanks to Daniel Shahaf). - TW-1675 project.not:something doesn't exclude project:something.subprojects (thanks to Ander). diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 94b61a1af..1993ef304 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -1619,11 +1619,19 @@ void CLI2::insertIDExpr () } else { + bool ascending = true; + int low = strtol (r->first.c_str (), NULL, 10); + int high = strtol (r->second.c_str (), NULL, 10); + if (low <= high) + ascending = true; + else + ascending = false; + reconstructed.push_back (openParen); reconstructed.push_back (argID); reconstructed.push_back (opGTE); - A2 startValue (r->first, Lexer::Type::number); + A2 startValue ((ascending ? r->first : r->second), Lexer::Type::number); startValue.tag ("FILTER"); reconstructed.push_back (startValue); @@ -1631,7 +1639,7 @@ void CLI2::insertIDExpr () reconstructed.push_back (argID); reconstructed.push_back (opLTE); - A2 endValue (r->second, Lexer::Type::number); + A2 endValue ((ascending ? r->second : r->first), Lexer::Type::number); endValue.tag ("FILTER"); reconstructed.push_back (endValue);