mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- Removed unused text.cpp isWordEnd function.
This commit is contained in:
parent
7890cf0ab7
commit
3f07173a03
3 changed files with 1 additions and 45 deletions
22
src/text.cpp
22
src/text.cpp
|
@ -569,28 +569,6 @@ bool noVerticalSpace (const std::string& input)
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 end.
|
||||
if (input.length () == 0)
|
||||
return false;
|
||||
|
||||
// If pos is the last alphanumeric character of the string.
|
||||
if (pos == input.length () - 1 && ! Lexer::is_ws (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 && ! Lexer::is_ws (input[pos]) && !isPunctuation (input[pos])
|
||||
&& ( Lexer::is_ws (input[pos + 1]) || isPunctuation (input[pos + 1])))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Override of ispunct, that considers #, $ and @ not to be punctuation.
|
||||
//
|
||||
|
|
|
@ -56,7 +56,6 @@ bool nontrivial (const std::string&);
|
|||
bool digitsOnly (const std::string&);
|
||||
bool noSpaces (const std::string&);
|
||||
bool noVerticalSpace (const std::string&);
|
||||
bool isWordEnd (const std::string&, std::string::size_type);
|
||||
bool isPunctuation (char);
|
||||
std::string visible (char);
|
||||
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
||||
|
|
|
@ -37,7 +37,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (242);
|
||||
UnitTest t (227);
|
||||
|
||||
// Ensure environment has no influence.
|
||||
unsetenv ("TASKDATA");
|
||||
|
@ -324,27 +324,6 @@ int main (int argc, char** argv)
|
|||
t.notok (noVerticalSpace ("a\rb"), "noVerticalSpace 'a\\rb' -> false");
|
||||
t.notok (noVerticalSpace ("a\fb"), "noVerticalSpace 'a\\fb' -> false");
|
||||
|
||||
text = "Hello, world.";
|
||||
// 0123456789012
|
||||
// s e s e
|
||||
|
||||
// bool isWordEnd (const std::string&, std::string::size_type);
|
||||
t.notok (isWordEnd ("", 0), "isWordEnd (\"\", 0) -> false");
|
||||
t.ok (isWordEnd ("foo", 2), "isWordEnd (\"foo\", 2) -> true");
|
||||
t.notok (isWordEnd (text, 0), "isWordEnd (\"Hello, world.\", 0) -> false");
|
||||
t.notok (isWordEnd (text, 1), "isWordEnd (\"Hello, world.\", 1) -> false");
|
||||
t.notok (isWordEnd (text, 2), "isWordEnd (\"Hello, world.\", 2) -> false");
|
||||
t.notok (isWordEnd (text, 3), "isWordEnd (\"Hello, world.\", 3) -> false");
|
||||
t.ok (isWordEnd (text, 4), "isWordEnd (\"Hello, world.\", 4) -> true");
|
||||
t.notok (isWordEnd (text, 5), "isWordEnd (\"Hello, world.\", 5) -> false");
|
||||
t.notok (isWordEnd (text, 6), "isWordEnd (\"Hello, world.\", 6) -> false");
|
||||
t.notok (isWordEnd (text, 7), "isWordEnd (\"Hello, world.\", 7) -> false");
|
||||
t.notok (isWordEnd (text, 8), "isWordEnd (\"Hello, world.\", 8) -> false");
|
||||
t.notok (isWordEnd (text, 9), "isWordEnd (\"Hello, world.\", 9) -> false");
|
||||
t.notok (isWordEnd (text, 10), "isWordEnd (\"Hello, world.\", 10) -> false");
|
||||
t.ok (isWordEnd (text, 11), "isWordEnd (\"Hello, world.\", 11) -> true");
|
||||
t.notok (isWordEnd (text, 12), "isWordEnd (\"Hello, world.\", 12) -> false");
|
||||
|
||||
// bool compare (const std::string&, const std::string&, bool caseless = false);
|
||||
// Make sure degenerate cases are handled.
|
||||
t.ok (compare ("", ""), "'' == ''");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue