ParseNumber() handles kParseNumbersAsStringsFlag
This commit is contained in:
parent
4abcfd1e28
commit
d2d5f6f919
@ -1097,6 +1097,8 @@ private:
|
|||||||
NumberStream<InputStream, (parseFlags & kParseFullPrecisionFlag) != 0> s(*this, copy.s);
|
NumberStream<InputStream, (parseFlags & kParseFullPrecisionFlag) != 0> s(*this, copy.s);
|
||||||
size_t startOffset = s.Tell();
|
size_t startOffset = s.Tell();
|
||||||
|
|
||||||
|
typename InputStream::Ch *head = is.PutBegin();
|
||||||
|
|
||||||
// Parse minus
|
// Parse minus
|
||||||
bool minus = Consume(s, '-');
|
bool minus = Consume(s, '-');
|
||||||
|
|
||||||
@ -1268,31 +1270,42 @@ private:
|
|||||||
|
|
||||||
// Finish parsing, call event according to the type of number.
|
// Finish parsing, call event according to the type of number.
|
||||||
bool cont = true;
|
bool cont = true;
|
||||||
size_t length = s.Length();
|
|
||||||
const char* decimal = s.Pop(); // Pop stack no matter if it will be used or not.
|
|
||||||
|
|
||||||
if (useDouble) {
|
if (parseFlags & kParseNumbersAsStringsFlag)
|
||||||
int p = exp + expFrac;
|
{
|
||||||
if (parseFlags & kParseFullPrecisionFlag)
|
s.Pop(); // Pop stack no matter if it will be used or not.
|
||||||
d = internal::StrtodFullPrecision(d, p, decimal, length, decimalPosition, exp);
|
const size_t length = s.Tell() - startOffset;
|
||||||
else
|
|
||||||
d = internal::StrtodNormalPrecision(d, p);
|
|
||||||
|
|
||||||
cont = handler.Double(minus ? -d : d);
|
cont = handler.Number(head, length, (parseFlags & kParseInsituFlag) ? false : true);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if (use64bit) {
|
{
|
||||||
if (minus)
|
size_t length = s.Length();
|
||||||
cont = handler.Int64(static_cast<int64_t>(~i64 + 1));
|
const char* decimal = s.Pop(); // Pop stack no matter if it will be used or not.
|
||||||
else
|
|
||||||
cont = handler.Uint64(i64);
|
if (useDouble) {
|
||||||
}
|
int p = exp + expFrac;
|
||||||
else {
|
if (parseFlags & kParseFullPrecisionFlag)
|
||||||
if (minus)
|
d = internal::StrtodFullPrecision(d, p, decimal, length, decimalPosition, exp);
|
||||||
cont = handler.Int(static_cast<int32_t>(~i + 1));
|
else
|
||||||
else
|
d = internal::StrtodNormalPrecision(d, p);
|
||||||
cont = handler.Uint(i);
|
|
||||||
}
|
cont = handler.Double(minus ? -d : d);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (use64bit) {
|
||||||
|
if (minus)
|
||||||
|
cont = handler.Int64(static_cast<int64_t>(~i64 + 1));
|
||||||
|
else
|
||||||
|
cont = handler.Uint64(i64);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (minus)
|
||||||
|
cont = handler.Int(static_cast<int32_t>(~i + 1));
|
||||||
|
else
|
||||||
|
cont = handler.Uint(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (RAPIDJSON_UNLIKELY(!cont))
|
if (RAPIDJSON_UNLIKELY(!cont))
|
||||||
RAPIDJSON_PARSE_ERROR(kParseErrorTermination, startOffset);
|
RAPIDJSON_PARSE_ERROR(kParseErrorTermination, startOffset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user