mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
Enhancement - related to, but not fixing bug #293
- Added new attribute modifiers 'word' and 'noword' which find the existence of whole words, or prove the non-existence of whole words. If a task has the description "Pay the bill", then "description.word:the" will match, but "description.word:th" will not. For partial word matches, there is still "description.contains:th". - Added unit tests for the text.cpp functions. - Added unit tests including the new modifiers in filters. - Added unit tests to parse the new modifiers. - Modified man page. - Modified the Context::autoFilter processing to use the new modifiers for +tag and -tag filtering. - Added a support email to an error message, while looking at the filter code. - Added new modifiers to the help report. - Modified a utf8.t unit test to include an alphanumeric tag, rather than a smiley face.
This commit is contained in:
parent
d019126086
commit
7acef0c9fd
12 changed files with 189 additions and 10 deletions
42
src/text.cpp
42
src/text.cpp
|
@ -420,3 +420,45 @@ bool noVerticalSpace (const std::string& input)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Input: hello, world
|
||||
// Result for pos: y......y....
|
||||
bool isWordStart (const std::string& input, std::string::size_type pos)
|
||||
{
|
||||
// Short circuit: no input means no word start.
|
||||
if (input.length () == 0)
|
||||
return false;
|
||||
|
||||
// If pos is the first alphanumeric character of the string.
|
||||
if (pos == 0 && isalnum (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]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Input: hello, world
|
||||
// Result for pos: ....y......y
|
||||
bool isWordEnd (const std::string& input, std::string::size_type pos)
|
||||
{
|
||||
// Short circuit: no input means no word start.
|
||||
if (input.length () == 0)
|
||||
return false;
|
||||
|
||||
// If pos is the last alphanumeric character of the string.
|
||||
if (pos == input.length () - 1 && isalnum (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]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue