From 28a49472342baf5f8c5d74945fdb72fd0ac3505a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 12 Feb 2012 10:42:24 -0500 Subject: [PATCH] Bug #818 - Fixed bug #818, which caused partial tag matching (thanks to Joe Holloway). - Note that the regex word boundary anchors are different for Solaris and Linux, and largely broken on OSX. - Added unit tests. --- AUTHORS | 1 + ChangeLog | 1 + PUNCHLIST | 9 ------ src/A3.cpp | 16 ++++++++++ test/bug.818.t | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 9 deletions(-) delete mode 100644 PUNCHLIST create mode 100755 test/bug.818.t diff --git a/AUTHORS b/AUTHORS index 0c9f47640..074ec3e9f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -120,4 +120,5 @@ suggestions: Eli Lev Paul-Gheorghe Barbu Jennifer Cormier + Joe Holloway diff --git a/ChangeLog b/ChangeLog index ab60b9b5e..0c28ae803 100644 --- a/ChangeLog +++ b/ChangeLog @@ -208,6 +208,7 @@ + Fixed bug #817, which caused a build problem with a Core2 Duo processor on a Mac OSX 10.6 machine. Notes updated in INSTALL file (thanks to John Hammond). + + Fixed bug #818, which caused partial tag matching (thanks to Joe Holloway). + Fixed bug #822, #845, which generated incorrect IDs (thanks to Matt Kraai and Michelle Crane). + Fixed bug #823, so that recurring task change propagations are now always diff --git a/PUNCHLIST b/PUNCHLIST deleted file mode 100644 index 47938f4a3..000000000 --- a/PUNCHLIST +++ /dev/null @@ -1,9 +0,0 @@ -Beta1 Punch List -- DOM access -- task.1 man page that is accurate -- taskrc.5 man page that is accurate - -Release Punch List -- All updated man pages -- All important bug fixes - diff --git a/src/A3.cpp b/src/A3.cpp index 41cc1f947..8eafc1dd0 100644 --- a/src/A3.cpp +++ b/src/A3.cpp @@ -1017,10 +1017,14 @@ const A3 A3::expand (const A3& input) const { expanded.push_back (Arg (name, Arg::type_string, Arg::cat_dom)); expanded.push_back (Arg ("~", Arg::cat_op)); +#ifdef DARWIN + expanded.push_back (Arg (value, Arg::type_string, Arg::cat_literal)); +#else #ifdef SOLARIS expanded.push_back (Arg ("\\<" + value + "\\>", Arg::type_string, Arg::cat_rx)); #else expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx)); +#endif #endif } @@ -1029,10 +1033,14 @@ const A3 A3::expand (const A3& input) const { expanded.push_back (Arg (name, Arg::type_string, Arg::cat_dom)); expanded.push_back (Arg ("!~", Arg::cat_op)); +#ifdef DARWIN + expanded.push_back (Arg (value, Arg::type_string, Arg::cat_literal)); +#else #ifdef SOLARIS expanded.push_back (Arg ("\\<" + value + "\\>", Arg::type_string, Arg::cat_rx)); #else expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx)); +#endif #endif } else @@ -1048,7 +1056,15 @@ const A3 A3::expand (const A3& input) const expanded.push_back (Arg ("tags", Arg::type_string, Arg::cat_dom)); expanded.push_back (Arg (type == '+' ? "~" : "!~", Arg::cat_op)); +#ifdef DARWIN expanded.push_back (Arg (value, Arg::type_string, Arg::cat_literal)); +#else +#ifdef SOLARIS + expanded.push_back (Arg ("\\<" + value + "\\>", Arg::type_string, Arg::cat_rx)); +#else + expanded.push_back (Arg ("\\b" + value + "\\b", Arg::type_string, Arg::cat_rx)); +#endif +#endif } // word --> description ~ word diff --git a/test/bug.818.t b/test/bug.818.t new file mode 100755 index 000000000..c249b349d --- /dev/null +++ b/test/bug.818.t @@ -0,0 +1,79 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006-2012, Paul Beckingham, Federico Hernandez. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included +## in all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +## http://www.opensource.org/licenses/mit-license.php +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 10; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Bug #818: Filtering by tag counter-intuitively uses partial match + +qx{../src/task rc:bug.rc add +hannah +anna Buy some bananas}; +my $output = qx{../src/task rc:bug.rc list +hannah}; +like ($output, qr/bananas/, 'Containing tag query'); + +$output = qx{../src/task rc:bug.rc list +anna}; +like ($output, qr/bananas/, 'Contained tag query'); + +qx{../src/task rc:bug.rc add +anna +hannah Buy tickets to Santana}; +$output = qx{../src/task rc:bug.rc list +anna}; +like ($output, qr/Santana/, 'Contained tag query'); + +$output = qx{../src/task rc:bug.rc list +hannah}; +like ($output, qr/Santana/, 'Containing tag query'); + +# Buy some bananas +hannah +anna +# Buy tickets to Santana +anna +hannah +# AAA +hannah +# BBB +anna +qx{../src/task rc:bug.rc add +hannah AAA}; +qx{../src/task rc:bug.rc add +anna BBB}; +$output = qx{../src/task rc:bug.rc long +anna}; +like ($output, qr/bananas/, '+anna --> bananas'); +like ($output, qr/Santana/, '+anna --> Santana'); +unlike ($output, qr/AAA/, '+anna !-> AAA'); +like ($output, qr/BBB/, '+anna --> BBB'); + +# Cleanup. +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch.key' && + ! -r 'bug.rc', 'Cleanup'); + +exit 0; +