From 297b0c4b0458a82b85d0975adccfff71a1fbe7a5 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 24 Jul 2015 22:57:47 -0400 Subject: [PATCH] =?UTF-8?q?Dates:=20Added=20exact-match=20'ea=D1=95ter'=20?= =?UTF-8?q?logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Without checking for an exact match for 'easter', the date 'easter' is a valid partial match for 'eastermonday'. --- src/Dates.cpp | 5 +++++ src/text.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/Dates.cpp b/src/Dates.cpp index f0d9079d3..26a753b6c 100644 --- a/src/Dates.cpp +++ b/src/Dates.cpp @@ -466,6 +466,11 @@ bool namedDates (const std::string& name, Variant& value) } if (closeEnough ("goodfriday", name, minimum)) t->tm_mday -= 2; + + // DO NOT REMOVE THIS USELESS-LOOKING LINE. + // It is here to capture an exact match for 'easter', to prevent 'easter' + // being a partial match for 'eastermonday'. + else if (closeEnough ("easter", name, minimum)) ; else if (closeEnough ("eastermonday", name, minimum)) t->tm_mday += 1; else if (closeEnough ("ascension", name, minimum)) t->tm_mday += 39; else if (closeEnough ("pentecost", name, minimum)) t->tm_mday += 49; diff --git a/src/text.cpp b/src/text.cpp index 7d3998afb..6a21d3ee4 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -515,9 +515,11 @@ bool closeEnough ( const std::string& attempt, unsigned int minLength /* = 0 */) { + // An exact match is accepted first. if (compare (reference, attempt, false)) return true; + // A partial match will suffice. if (attempt.length () < reference.length () && attempt.length () >= minLength) return compare (reference.substr (0, attempt.length ()), attempt, false);