Bug #414 - Tags filtering not working with unicode characters

- Fixed bug #414, that caused filtering on the presence or absence of tags
  containing Unicode characters to fail (thanks to Michal Josífko).
+ + Fixed bug #414, that caused filtering on the presence or absence of tags
+   containing Unicode characters to fail (thanks to Michal Josífko).

 ------ old releases ------------------------------
This commit is contained in:
Paul Beckingham 2010-06-20 20:10:20 -04:00
parent 916b8641b3
commit 99bce308e6
5 changed files with 86 additions and 8 deletions

View file

@ -22,6 +22,7 @@ The following submitted code, packages or analysis, and deserve special thanks:
Alexander Neumann
Emil Sköldberg
Johannes Schlatow
Michal Josífko
Thanks to the following, who submitted detailed bug reports and excellent suggestions:
Eugene Kramer

View file

@ -32,6 +32,8 @@
+ Fixed bug #211 - it was unclear which commands modify a task description.
+ Fixed bug #411, clarifying that the 'projects' command only lists projects
for which there are pending tasks (thanks to Dirk Deimeke).
+ Fixed bug #414, that caused filtering on the presence or absence of tags
containing Unicode characters to fail (thanks to Michal Josífko).
------ old releases ------------------------------

View file

@ -127,13 +127,13 @@ static fileType determineFileType (const std::vector <std::string>& lines)
// +project
if (words[w].length () > 1 &&
words[w][0] == '+' &&
isalnum (words[w][1]))
!isspace (words[w][1]))
return todo_sh_2_0;
// @context
if (words[w].length () > 1 &&
words[w][0] == '@' &&
isalnum (words[w][1]))
!isspace (words[w][1]))
return todo_sh_2_0;
}
}

73
src/tests/bug.414.t Executable file
View file

@ -0,0 +1,73 @@
#! /usr/bin/perl
################################################################################
## task - a command line task list manager.
##
## Copyright 2006 - 2010, Paul Beckingham.
## All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 2 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, write to the
##
## Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor,
## Boston, MA
## 02110-1301
## USA
##
################################################################################
use strict;
use warnings;
use Test::More tests => 9;
# 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 #414: Tags filtering not working with unicode characters
# Add a task with a UTF-8 tag.
qx{../task rc:bug.rc add one +osobní};
my $output = qx{../task rc:bug.rc ls +osobní};
like ($output, qr/one/, 'found UTF8 tag osobní');
$output = qx{../task rc:bug.rc ls -osobní};
unlike ($output, qr/one/, 'not found UTF8 tag osobní');
# And a different one
qx{../task rc:bug.rc add two +föo};
$output = qx{../task rc:bug.rc ls +föo};
like ($output, qr/two/, 'found UTF8 tag föo');
$output = qx{../task rc:bug.rc ls -föo};
unlike ($output, qr/two/, 'not found UTF8 tag föo');
# Cleanup.
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
unlink 'completed.data';
ok (!-r 'completed.data', 'Removed completed.data');
unlink 'undo.data';
ok (!-r 'undo.data', 'Removed undo.data');
unlink 'bug.rc';
ok (!-r 'bug.rc', 'Removed bug.rc');
exit 0;

View file

@ -429,13 +429,14 @@ bool isWordStart (const std::string& input, std::string::size_type pos)
if (input.length () == 0)
return false;
// If pos is the first alphanumeric character of the string.
if (pos == 0 && isalnum (input[pos]))
// If pos is the first non space/punct character of the string.
if (pos == 0 && !isspace (input[pos]) && !ispunct (input[pos]))
return true;
// If pos is not the first alphanumeric character, but there is a preceding
// non-alphanumeric character.
if (pos > 0 && isalnum (input[pos]) && !isalnum (input[pos - 1]))
// space/punct character.
if (pos > 0 && !isspace (input[pos]) && !ispunct (input[pos])
&& (isspace (input[pos - 1]) || ispunct (input[pos - 1])))
return true;
return false;
@ -451,12 +452,13 @@ bool isWordEnd (const std::string& input, std::string::size_type pos)
return false;
// If pos is the last alphanumeric character of the string.
if (pos == input.length () - 1 && isalnum (input[pos]))
if (pos == input.length () - 1 && !isspace (input[pos]) && !ispunct (input[pos]))
return true;
// If pos is not the last alphanumeric character, but there is a following
// non-alphanumeric character.
if (pos < input.length () - 1 && isalnum (input[pos]) && !isalnum (input[pos + 1]))
if (pos < input.length () - 1 && !isspace (input[pos]) && !ispunct (input[pos])
&& (isspace (input[pos + 1]) || ispunct (input[pos + 1])))
return true;
return false;