mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Bug #542
- Fixed bug #542, which sorted the countdown columns incorrectly (thanks to Michelle Crane). - Duration could not parse all varieties of it's own output, which is why the sorting was broken, in particular negative durations and real numbers in durations (such as (1.2y'). - Sorting in Table::sort_compare for Table::periodAscending and Table::periodDescending was broken. - Missing unit tests for countdown_compact. - Imported Nibbler::getNumber from the Attitash project. - Additional Duration unit tests. - Additional Nibbler unit tests. - Additional countdown.t unit tests.
This commit is contained in:
parent
c2a84c7cf6
commit
38ffa390ea
8 changed files with 311 additions and 102 deletions
|
@ -323,6 +323,78 @@ bool Nibbler::getUnsignedInt (int& result)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// number:
|
||||
// int frac? exp?
|
||||
//
|
||||
// int:
|
||||
// -? digit+
|
||||
//
|
||||
// frac:
|
||||
// . digit+
|
||||
//
|
||||
// exp:
|
||||
// e digit+
|
||||
//
|
||||
// e:
|
||||
// e|E (+|-)?
|
||||
//
|
||||
bool Nibbler::getNumber (double& result)
|
||||
{
|
||||
std::string::size_type i = mCursor;
|
||||
|
||||
// [+-]?
|
||||
if (i < mLength && mInput[i] == '-')
|
||||
++i;
|
||||
|
||||
// digit+
|
||||
if (i < mLength && isdigit (mInput[i]))
|
||||
{
|
||||
++i;
|
||||
|
||||
while (i < mLength && isdigit (mInput[i]))
|
||||
++i;
|
||||
|
||||
// ( . digit+ )?
|
||||
if (i < mLength && mInput[i] == '.')
|
||||
{
|
||||
++i;
|
||||
|
||||
while (i < mLength && isdigit (mInput[i]))
|
||||
++i;
|
||||
}
|
||||
|
||||
// ( [eE] [+-]? digit+ )?
|
||||
if (i < mLength && (mInput[i] == 'e' || mInput[i] == 'E'))
|
||||
{
|
||||
++i;
|
||||
|
||||
if (i < mLength && (mInput[i] == '+' || mInput[i] == '-'))
|
||||
++i;
|
||||
|
||||
if (i < mLength && isdigit (mInput[i]))
|
||||
{
|
||||
++i;
|
||||
|
||||
while (i < mLength && isdigit (mInput[i]))
|
||||
++i;
|
||||
|
||||
result = atof (mInput.substr (mCursor, i - mCursor).c_str ());
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
result = atof (mInput.substr (mCursor, i - mCursor).c_str ());
|
||||
mCursor = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getLiteral (const std::string& literal)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue