mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Lexer:: Implemented ::commonLength with offsets, for embedded parsing
This commit is contained in:
parent
244c81a647
commit
a9b701ae6d
2 changed files with 23 additions and 0 deletions
|
@ -385,6 +385,28 @@ int Lexer::commonLength (const std::string& left, const std::string& right)
|
||||||
return (int) l;
|
return (int) l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Compares two strings with offsets, and returns the number bytes in common.
|
||||||
|
//
|
||||||
|
// left: wonderful
|
||||||
|
// l: ^
|
||||||
|
// right: prowonderbread
|
||||||
|
// r: ^
|
||||||
|
// returns: ^ 6
|
||||||
|
int Lexer::commonLength (
|
||||||
|
const std::string& left,
|
||||||
|
std::string::size_type l,
|
||||||
|
const std::string& right,
|
||||||
|
std::string::size_type r)
|
||||||
|
{
|
||||||
|
while (left[l] == right[r] &&
|
||||||
|
utf8_next_char (left, l) &&
|
||||||
|
utf8_next_char (right, r))
|
||||||
|
;
|
||||||
|
|
||||||
|
return (int) l;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Lexer::Type::string
|
// Lexer::Type::string
|
||||||
// '|"
|
// '|"
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
static int hexToInt (int, int);
|
static int hexToInt (int, int);
|
||||||
static int hexToInt (int, int, int, int);
|
static int hexToInt (int, int, int, int);
|
||||||
static int commonLength (const std::string&, const std::string&);
|
static int commonLength (const std::string&, const std::string&);
|
||||||
|
static int commonLength (const std::string&, std::string::size_type, const std::string&, std::string::size_type);
|
||||||
|
|
||||||
bool isEOS () const;
|
bool isEOS () const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue