mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Pig: Added ::getHexDigit
This commit is contained in:
parent
91b1d512a7
commit
a66e03e858
2 changed files with 31 additions and 0 deletions
30
src/Pig.cpp
30
src/Pig.cpp
|
@ -171,6 +171,36 @@ bool Pig::getDigits (int& result)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Pig::getHexDigit (int& result)
|
||||
{
|
||||
int c = _text[_cursor];
|
||||
if (c &&
|
||||
Lexer::isHexDigit (c))
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
result = c - '0';
|
||||
++_cursor;
|
||||
return true;
|
||||
}
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
{
|
||||
result = c - 'A' + 10;
|
||||
++_cursor;
|
||||
return true;
|
||||
}
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
{
|
||||
result = c - 'a' + 10;
|
||||
++_cursor;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// number:
|
||||
// int frac? exp?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue