mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Lexer: Implemented ::commonLength for word root comparison
This commit is contained in:
parent
f5792a03fb
commit
244c81a647
2 changed files with 19 additions and 0 deletions
|
@ -367,6 +367,24 @@ int Lexer::hexToInt (int c0, int c1, int c2, int c3)
|
|||
hexToInt (c3);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Compares two strings, and returns the number bytes in common.
|
||||
//
|
||||
// left: wonderful
|
||||
// right: wonderbread
|
||||
// returns: ^ 6
|
||||
int Lexer::commonLength (const std::string& left, const std::string& right)
|
||||
{
|
||||
std::string::size_type l = 0;
|
||||
std::string::size_type r = 0;
|
||||
while (left[l] == right[r] &&
|
||||
utf8_next_char (left, l) &&
|
||||
utf8_next_char (right, r))
|
||||
;
|
||||
|
||||
return (int) l;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Lexer::Type::string
|
||||
// '|"
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
static int hexToInt (int);
|
||||
static int hexToInt (int, int);
|
||||
static int hexToInt (int, int, int, int);
|
||||
static int commonLength (const std::string&, const std::string&);
|
||||
|
||||
bool isEOS () const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue