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)
|
bool Nibbler::getQuoted (char c, std::string& result)
|
||||||
{
|
{
|
||||||
std::string::size_type start = mCursor;
|
std::string::size_type backup = mCursor;
|
||||||
if (start < mLength && mInput[start] == c)
|
|
||||||
|
if (skip (c) &&
|
||||||
|
getUntil (c, result) &&
|
||||||
|
skip (c))
|
||||||
{
|
{
|
||||||
++start;
|
return true;
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,10 +311,8 @@ bool Nibbler::getRx (const std::string& regex, std::string& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::skipN (const int quantity /* = 1 */)
|
bool Nibbler::skipN (const int quantity /* = 1 */)
|
||||||
{
|
{
|
||||||
if (mCursor >= mLength)
|
if (mCursor < mLength &&
|
||||||
return false;
|
mCursor <= mLength - quantity)
|
||||||
|
|
||||||
if (mCursor <= mLength - quantity)
|
|
||||||
{
|
{
|
||||||
mCursor += quantity;
|
mCursor += quantity;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue