PP: Address #1456: Strip float suffixes before using platform library.

This commit is contained in:
John Kessenich 2018-07-27 13:08:05 -06:00
parent 994d4bf325
commit 7cdc24c06c

View File

@ -317,8 +317,19 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
} else { } else {
// slow path // slow path
ppToken->dval = 0.0; ppToken->dval = 0.0;
// remove suffix
TString numstr(ppToken->name);
if (numstr.back() == 'f' || numstr.back() == 'F')
numstr.pop_back();
if (numstr.back() == 'h' || numstr.back() == 'H')
numstr.pop_back();
if (numstr.back() == 'l' || numstr.back() == 'L')
numstr.pop_back();
// use platform library
strtodStream.clear(); strtodStream.clear();
strtodStream.str(ppToken->name); strtodStream.str(numstr.c_str());
strtodStream >> ppToken->dval; strtodStream >> ppToken->dval;
if (strtodStream.fail()) { if (strtodStream.fail()) {
// Assume failure combined with a large exponent was overflow, in // Assume failure combined with a large exponent was overflow, in