Changeset View
Changeset View
Standalone View
Standalone View
src/util/strencodings.cpp
Show First 20 Lines • Show All 694 Lines • ▼ Show 20 Lines | if (ptr < end && val[ptr] == '-') { | ||||
mantissa_sign = true; | mantissa_sign = true; | ||||
++ptr; | ++ptr; | ||||
} | } | ||||
if (ptr < end) { | if (ptr < end) { | ||||
if (val[ptr] == '0') { | if (val[ptr] == '0') { | ||||
// pass single 0 | // pass single 0 | ||||
++ptr; | ++ptr; | ||||
} else if (val[ptr] >= '1' && val[ptr] <= '9') { | } else if (val[ptr] >= '1' && val[ptr] <= '9') { | ||||
while (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') { | while (ptr < end && IsDigit(val[ptr])) { | ||||
if (!ProcessMantissaDigit(val[ptr], mantissa, | if (!ProcessMantissaDigit(val[ptr], mantissa, | ||||
mantissa_tzeros)) { | mantissa_tzeros)) { | ||||
// overflow | // overflow | ||||
return false; | return false; | ||||
} | } | ||||
++ptr; | ++ptr; | ||||
} | } | ||||
} else { | } else { | ||||
// missing expected digit | // missing expected digit | ||||
return false; | return false; | ||||
} | } | ||||
} else { | } else { | ||||
// empty string or loose '-' | // empty string or loose '-' | ||||
return false; | return false; | ||||
} | } | ||||
if (ptr < end && val[ptr] == '.') { | if (ptr < end && val[ptr] == '.') { | ||||
++ptr; | ++ptr; | ||||
if (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') { | if (ptr < end && IsDigit(val[ptr])) { | ||||
while (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') { | while (ptr < end && IsDigit(val[ptr])) { | ||||
if (!ProcessMantissaDigit(val[ptr], mantissa, | if (!ProcessMantissaDigit(val[ptr], mantissa, | ||||
mantissa_tzeros)) { | mantissa_tzeros)) { | ||||
// overflow | // overflow | ||||
return false; | return false; | ||||
} | } | ||||
++ptr; | ++ptr; | ||||
++point_ofs; | ++point_ofs; | ||||
} | } | ||||
} else { | } else { | ||||
// missing expected digit | // missing expected digit | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
if (ptr < end && (val[ptr] == 'e' || val[ptr] == 'E')) { | if (ptr < end && (val[ptr] == 'e' || val[ptr] == 'E')) { | ||||
++ptr; | ++ptr; | ||||
if (ptr < end && val[ptr] == '+') { | if (ptr < end && val[ptr] == '+') { | ||||
++ptr; | ++ptr; | ||||
} else if (ptr < end && val[ptr] == '-') { | } else if (ptr < end && val[ptr] == '-') { | ||||
exponent_sign = true; | exponent_sign = true; | ||||
++ptr; | ++ptr; | ||||
} | } | ||||
if (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') { | if (ptr < end && IsDigit(val[ptr])) { | ||||
while (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') { | while (ptr < end && IsDigit(val[ptr])) { | ||||
if (exponent > (UPPER_BOUND / 10LL)) { | if (exponent > (UPPER_BOUND / 10LL)) { | ||||
// overflow | // overflow | ||||
return false; | return false; | ||||
} | } | ||||
exponent = exponent * 10 + val[ptr] - '0'; | exponent = exponent * 10 + val[ptr] - '0'; | ||||
++ptr; | ++ptr; | ||||
} | } | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |