Port from qlocale_data_p.h's isZero() to qIsNull()
... and mark the former for removal in 6.12 (LTS+1). I couldn't find more in-tree users than the ones this patch ports, but it doesn't cost much to defer removal of the function, so do it. Change-Id: I8a8762e65907d3f66c20cd733ecb55f7ac876960 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
743403cb6d
commit
c85d896257
@ -3827,7 +3827,7 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form,
|
||||
bool negative = false;
|
||||
qt_doubleToAscii(d, form, precision, buf.data(), bufSize, negative, length, decpt);
|
||||
|
||||
const QString prefix = signPrefix(negative && !isZero(d), flags);
|
||||
const QString prefix = signPrefix(negative && !qIsNull(d), flags);
|
||||
QString numStr;
|
||||
|
||||
if (length == 3
|
||||
|
@ -117,7 +117,7 @@ void qt_doubleToAscii(double d, QLocaleData::DoubleForm form, int precision,
|
||||
else if (precision == QLocale::FloatingPointShortest)
|
||||
precision = std::numeric_limits<double>::max_digits10; // snprintf lacks "shortest" mode
|
||||
|
||||
if (isZero(d)) {
|
||||
if (qIsNull(d)) {
|
||||
// Negative zero is expected as simple "0", not "-0". We cannot do d < 0, though.
|
||||
sign = false;
|
||||
buf[0] = '0';
|
||||
@ -356,7 +356,7 @@ QSimpleParsedNumber<double> qt_asciiToDouble(const char *num, qsizetype numLen,
|
||||
Q_ASSERT(strayCharMode == TrailingJunkAllowed || processed == numLen);
|
||||
|
||||
// Check if underflow has occurred.
|
||||
if (isZero(d)) {
|
||||
if (qIsNull(d)) {
|
||||
for (int i = 0; i < processed; ++i) {
|
||||
if (num[i] >= '1' && num[i] <= '9') {
|
||||
// if a digit before any 'e' is not 0, then a non-zero number was intended.
|
||||
@ -721,7 +721,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u
|
||||
T result;
|
||||
result.reserve(total);
|
||||
|
||||
if (negative && !isZero(d)) // We don't return "-0"
|
||||
if (negative && !qIsNull(d)) // We don't return "-0"
|
||||
result.append(Char('-'));
|
||||
if (!qt_is_finite(d)) {
|
||||
result.append(view);
|
||||
|
@ -63,10 +63,13 @@ void qt_doubleToAscii(double d, QLocaleData::DoubleForm form, int precision,
|
||||
int base = 10);
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 12, 0)
|
||||
[[deprecated("Use qIsNull(double) instead.")]]
|
||||
[[nodiscard]] constexpr inline bool isZero(double d)
|
||||
{
|
||||
return qIsNull(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Enough space for the digits before the decimal separator:
|
||||
[[nodiscard]] inline int wholePartSpace(double d)
|
||||
|
Loading…
x
Reference in New Issue
Block a user