mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 20:37:20 +02:00
Code Cleaup
- Reimplemented Nibbler::getQuoted. - Reimplemented Nibbler::skipN.
This commit is contained in:
parent
f1a0b842dc
commit
05fd9278a6
1 changed files with 9 additions and 17 deletions
|
@ -212,22 +212,16 @@ bool Nibbler::getUntilEOS (std::string& result)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getQuoted (char c, std::string& result)
|
||||
{
|
||||
std::string::size_type start = mCursor;
|
||||
if (start < mLength && mInput[start] == c)
|
||||
std::string::size_type backup = mCursor;
|
||||
|
||||
if (skip (c) &&
|
||||
getUntil (c, result) &&
|
||||
skip (c))
|
||||
{
|
||||
++start;
|
||||
if (start < mLength)
|
||||
{
|
||||
std::string::size_type end = mInput.find (c, start);
|
||||
if (end != std::string::npos)
|
||||
{
|
||||
result = mInput.substr (start, end - start);
|
||||
mCursor = end + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mCursor = backup;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -317,10 +311,8 @@ bool Nibbler::getRx (const std::string& regex, std::string& result)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::skipN (const int quantity /* = 1 */)
|
||||
{
|
||||
if (mCursor >= mLength)
|
||||
return false;
|
||||
|
||||
if (mCursor <= mLength - quantity)
|
||||
if (mCursor < mLength &&
|
||||
mCursor <= mLength - quantity)
|
||||
{
|
||||
mCursor += quantity;
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue