mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Helpers
- Implemented isTokenEnd, as a special case of isWordEnd, but considers consecutive punctuation to be a set of individual tokens.
This commit is contained in:
parent
94bb98edac
commit
562fd8ce3c
2 changed files with 21 additions and 1 deletions
21
src/text.cpp
21
src/text.cpp
|
@ -601,7 +601,7 @@ bool isWordStart (const std::string& input, std::string::size_type pos)
|
|||
// Result for pos: ....y......y
|
||||
bool isWordEnd (const std::string& input, std::string::size_type pos)
|
||||
{
|
||||
// Short circuit: no input means no word start.
|
||||
// Short circuit: no input means no word end.
|
||||
if (input.length () == 0)
|
||||
return false;
|
||||
|
||||
|
@ -618,6 +618,25 @@ bool isWordEnd (const std::string& input, std::string::size_type pos)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Input: hello, world
|
||||
// Result for pos: ....y......y
|
||||
//
|
||||
// Input: (one) two
|
||||
// Result for pos: y..yy...y
|
||||
bool isTokenEnd (const std::string& input, std::string::size_type pos)
|
||||
{
|
||||
// Delegate.
|
||||
if (isWordEnd (input, pos))
|
||||
return true;
|
||||
|
||||
// Punctuation divides tokens.
|
||||
if (pos < input.length () && isPunctuation (input[pos]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Override of ispunct, that considers #, $ and @ not to be punctuation.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue