mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug #480 - @ Symbol in context not returning
- Fixed bug #480, which didn't properly support @ characters in tags. The problem was that the ctype.h ispunct() function considers @, # and $ to be punctuation, which I don't. An override now allows these characters in tags, and specificallt '+@context' style tags. - Added unit tests.
This commit is contained in:
parent
3cfcc9fb6b
commit
58d678f927
5 changed files with 100 additions and 6 deletions
27
src/text.cpp
27
src/text.cpp
|
@ -455,13 +455,13 @@ bool isWordStart (const std::string& input, std::string::size_type pos)
|
|||
return false;
|
||||
|
||||
// If pos is the first non space/punct character of the string.
|
||||
if (pos == 0 && !isspace (input[pos]) && !ispunct (input[pos]))
|
||||
if (pos == 0 && !isspace (input[pos]) && !isPunctuation (input[pos]))
|
||||
return true;
|
||||
|
||||
// If pos is not the first alphanumeric character, but there is a preceding
|
||||
// space/punct character.
|
||||
if (pos > 0 && !isspace (input[pos]) && !ispunct (input[pos])
|
||||
&& (isspace (input[pos - 1]) || ispunct (input[pos - 1])))
|
||||
if (pos > 0 && !isspace (input[pos]) && !isPunctuation (input[pos])
|
||||
&& (isspace (input[pos - 1]) || isPunctuation (input[pos - 1])))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -477,18 +477,33 @@ 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 && !isspace (input[pos]) && !ispunct (input[pos]))
|
||||
if (pos == input.length () - 1 && !isspace (input[pos]) && !isPunctuation (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 && !isspace (input[pos]) && !ispunct (input[pos])
|
||||
&& (isspace (input[pos + 1]) || ispunct (input[pos + 1])))
|
||||
if (pos < input.length () - 1 && !isspace (input[pos]) && !isPunctuation (input[pos])
|
||||
&& (isspace (input[pos + 1]) || isPunctuation (input[pos + 1])))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Override of ispunct, that considers #, $ and @ not to be punctuation.
|
||||
//
|
||||
// ispunct: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
||||
// Punctuation: ! " % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ ` { | } ~
|
||||
// delta: # $ @
|
||||
//
|
||||
bool isPunctuation (char c)
|
||||
{
|
||||
if (c == '@' || c == '#' || c == '$')
|
||||
return false;
|
||||
|
||||
return ispunct (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool compare (
|
||||
const std::string& left,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue