Backed out 9 changesets (bug 1686831) for sanitizer failures on nsTSubstring.cpp. CLOSED TREE

Backed out changeset 0e03d508c8d4 (bug 1686831)
Backed out changeset cf6dd6eab427 (bug 1686831)
Backed out changeset 308000f1e14b (bug 1686831)
Backed out changeset c4d470be0184 (bug 1686831)
Backed out changeset 9751918b1ccb (bug 1686831)
Backed out changeset dd9b7e71dcfb (bug 1686831)
Backed out changeset 486a184530a7 (bug 1686831)
Backed out changeset b64d3e89bf68 (bug 1686831)
Backed out changeset dcc6396e455a (bug 1686831)
This commit is contained in:
Csoregi Natalia
2021-01-28 09:55:28 +02:00
parent c8cd29c6a8
commit b23b7186a3
25 changed files with 304 additions and 10531 deletions

View File

@@ -172,7 +172,6 @@ modules/woff2/.*
modules/xz-embedded/.*
modules/zlib/.*
mozglue/misc/decimal/.*
mozglue/tests/glibc_printf_tests/.*
netwerk/dns/nsIDNKitInterface.h
netwerk/sctp/src/.*
netwerk/srtp/src/.*

View File

@@ -1,12 +1,30 @@
commit bf4607277fa7133825cb7899015374917cd06b8f
Author: Mike Hommey <mhommey@mozilla.com>
Date: Tue Jan 26 19:46:13 2021 +0900
commit 4a51e730d3604c01637a9ff9e00b051e5f4e9b93
Author: Florian Loitsch <florian@loitsch.com>
Date: Mon Sep 2 18:06:17 2019 +0200
Add a flag to make precision mode like printf's %g (#149)
Add support for e2k architecture. (#118)
With this, %g can be emulated with:
```
DoubleToStringConverter cvt(
UNIQUE_ZERO | NO_TRAILING_ZERO | EMIT_POSITIVE_EXPONENT_SIGN,
"inf", "nan", 'e', 0, 0, 4, 0, 2)
```
diff --git a/Changelog b/Changelog
index 12b8a51..f774727 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,6 @@
+2019-09-02:
+ Add support for e2k architectur. Thanks to Michael Shigorin.
+
2019-08-01:
Add min exponent width option in double-to-string conversion.
diff --git a/double-conversion/utils.h b/double-conversion/utils.h
index a66289e..1a71df0 100644
--- a/double-conversion/utils.h
+++ b/double-conversion/utils.h
@@ -100,7 +100,7 @@ int main(int argc, char** argv) {
defined(__SH4__) || defined(__alpha__) || \
defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) ||\
defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \
- defined(__riscv) || \
+ defined(__riscv) || defined(__e2k__) || \
defined(__or1k__) || defined(__arc__) || \
defined(__EMSCRIPTEN__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1

View File

@@ -0,0 +1,62 @@
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.cc b/mfbt/double-conversion/double-conversion/double-to-string.cc
--- a/mfbt/double-conversion/double-conversion/double-to-string.cc
+++ b/mfbt/double-conversion/double-conversion/double-to-string.cc
@@ -290,17 +290,19 @@ bool DoubleToStringConverter::ToExponent
exponent,
result_builder);
return true;
}
bool DoubleToStringConverter::ToPrecision(double value,
int precision,
+ bool* used_exponential_notation,
StringBuilder* result_builder) const {
+ *used_exponential_notation = false;
if (Double(value).IsSpecial()) {
return HandleSpecialValues(value, result_builder);
}
if (precision < kMinPrecisionDigits || precision > kMaxPrecisionDigits) {
return false;
}
@@ -332,16 +334,17 @@ bool DoubleToStringConverter::ToPrecisio
max_trailing_padding_zeroes_in_precision_mode_)) {
// Fill buffer to contain 'precision' digits.
// Usually the buffer is already at the correct length, but 'DoubleToAscii'
// is allowed to return less characters.
for (int i = decimal_rep_length; i < precision; ++i) {
decimal_rep[i] = '0';
}
+ *used_exponential_notation = true;
CreateExponentialRepresentation(decimal_rep,
precision,
exponent,
result_builder);
} else {
CreateDecimalRepresentation(decimal_rep, decimal_rep_length, decimal_point,
(std::max)(0, precision - decimal_point),
result_builder);
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.h b/mfbt/double-conversion/double-conversion/double-to-string.h
--- a/mfbt/double-conversion/double-conversion/double-to-string.h
+++ b/mfbt/double-conversion/double-conversion/double-to-string.h
@@ -273,16 +273,17 @@ class DoubleToStringConverter {
// been provided to the constructor,
// - precision < kMinPericisionDigits
// - precision > kMaxPrecisionDigits
// The last condition implies that the result will never contain more than
// kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
// exponent character, the exponent's sign, and at most 3 exponent digits).
MFBT_API bool ToPrecision(double value,
int precision,
+ bool* used_exponential_notation,
StringBuilder* result_builder) const;
enum DtoaMode {
// Produce the shortest correct representation.
// For example the output of 0.299999999999999988897 is (the less accurate
// but correct) 0.3.
SHORTEST,
// Same as SHORTEST, but for single-precision floats.

View File

@@ -1,5 +1,4 @@
diff --git a/mfbt/double-conversion/double-conversion/double-to-string.h b/mfbt/double-conversion/double-conversion/double-to-string.h
index 6317a08a72aeb..52d7986fe9048 100644
--- a/mfbt/double-conversion/double-conversion/double-to-string.h
+++ b/mfbt/double-conversion/double-conversion/double-to-string.h
@@ -23,16 +23,17 @@
@@ -20,34 +19,15 @@ index 6317a08a72aeb..52d7986fe9048 100644
public:
// When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint
// or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the
@@ -51,17 +52,17 @@ class DoubleToStringConverter {
static const int kMaxPrecisionDigits = 120;
@@ -132,17 +133,17 @@ class DoubleToStringConverter {
min_exponent_width_(min_exponent_width) {
// When 'trailing zero after the point' is set, then 'trailing point'
// must be set too.
DOUBLE_CONVERSION_ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) ||
!((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0));
}
// The maximal number of digits that are needed to emit a double in base 10.
// A higher precision can be achieved by using more digits, but the shortest
// accurate representation of any double will never use more digits than
// kBase10MaximalLength.
// Note that DoubleToAscii null-terminates its input. So the given buffer
// should be at least kBase10MaximalLength + 1 characters long.
- static const int kBase10MaximalLength = 17;
+ static const MFBT_DATA int kBase10MaximalLength = 17;
// The maximal number of digits that are needed to emit a single in base 10.
// A higher precision can be achieved by using more digits, but the shortest
// accurate representation of any single will never use more digits than
// kBase10MaximalLengthSingle.
static const int kBase10MaximalLengthSingle = 9;
// The length of the longest string that 'ToShortest' can produce when the
@@ -167,17 +168,17 @@ class DoubleToStringConverter {
//
// Flags: UNIQUE_ZERO and EMIT_POSITIVE_EXPONENT_SIGN.
// Special values: "Infinity" and "NaN".
// Lower case 'e' for exponential values.
// decimal_in_shortest_low: -6
// decimal_in_shortest_high: 21
// max_leading_padding_zeroes_in_precision_mode: 6
// max_trailing_padding_zeroes_in_precision_mode: 0
// Returns a converter following the EcmaScript specification.
- static const DoubleToStringConverter& EcmaScriptConverter();
+ static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
@@ -58,15 +38,15 @@ index 6317a08a72aeb..52d7986fe9048 100644
// Example with decimal_in_shortest_low = -6,
// decimal_in_shortest_high = 21,
// EMIT_POSITIVE_EXPONENT_SIGN activated, and
@@ -252,17 +253,17 @@ class DoubleToStringConverter {
@@ -200,17 +201,17 @@ class DoubleToStringConverter {
// except for the following cases:
// - the input value is special and no infinity_symbol or nan_symbol has
// been provided to the constructor,
// - 'value' > 10^kMaxFixedDigitsBeforePoint, or
// - 'requested_digits' > kMaxFixedDigitsAfterPoint.
// The last two conditions imply that the result for non-special values never
// contains more than
// The last two conditions imply that the result will never contain more than
// 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
// (one additional character for the sign, and one for the decimal point).
// In addition, the buffer must be able to hold the trailing '\0' character.
- bool ToFixed(double value,
+ MFBT_API bool ToFixed(double value,
int requested_digits,
@@ -77,34 +57,34 @@ index 6317a08a72aeb..52d7986fe9048 100644
// If requested_digits equals -1, then the shortest exponential representation
// is computed.
//
@@ -286,17 +287,17 @@ class DoubleToStringConverter {
@@ -232,17 +233,17 @@ class DoubleToStringConverter {
// except for the following cases:
// - the input value is special and no infinity_symbol or nan_symbol has
// been provided to the constructor,
// - 'requested_digits' > kMaxExponentialDigits.
//
// The last condition implies that the result never contains more than
// The last condition implies that the result will never contain more than
// kMaxExponentialDigits + 8 characters (the sign, the digit before the
// decimal point, the decimal point, the exponent character, the
// exponent's sign, and at most 3 exponent digits).
// In addition, the buffer must be able to hold the trailing '\0' character.
- bool ToExponential(double value,
+ MFBT_API bool ToExponential(double value,
int requested_digits,
StringBuilder* result_builder) const;
// Computes 'precision' leading digits of the given 'value' and returns them
// either in exponential or decimal format, depending on
// max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the
// constructor).
@@ -327,17 +328,17 @@ class DoubleToStringConverter {
// The last computed digit is rounded.
@@ -270,17 +271,17 @@ class DoubleToStringConverter {
// except for the following cases:
// - the input value is special and no infinity_symbol or nan_symbol has
// been provided to the constructor,
// - precision < kMinPericisionDigits
// - precision > kMaxPrecisionDigits
//
// The last condition implies that the result never contains more than
// The last condition implies that the result will never contain more than
// kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
// exponent character, the exponent's sign, and at most 3 exponent digits).
// In addition, the buffer must be able to hold the trailing '\0' character.
- bool ToPrecision(double value,
+ MFBT_API bool ToPrecision(double value,
int precision,
@@ -115,7 +95,26 @@ index 6317a08a72aeb..52d7986fe9048 100644
// For example the output of 0.299999999999999988897 is (the less accurate
// but correct) 0.3.
SHORTEST,
@@ -389,44 +390,44 @@ class DoubleToStringConverter {
@@ -295,17 +296,17 @@ class DoubleToStringConverter {
};
// The maximal number of digits that are needed to emit a double in base 10.
// A higher precision can be achieved by using more digits, but the shortest
// accurate representation of any double will never use more digits than
// kBase10MaximalLength.
// Note that DoubleToAscii null-terminates its input. So the given buffer
// should be at least kBase10MaximalLength + 1 characters long.
- static const int kBase10MaximalLength = 17;
+ static const MFBT_DATA int kBase10MaximalLength = 17;
// Converts the given double 'v' to digit characters. 'v' must not be NaN,
// +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also
// applies to 'v' after it has been casted to a single-precision float. That
// is, in this mode static_cast<float>(v) must not be NaN, +Infinity or
// -Infinity.
//
// The result should be interpreted as buffer * 10^(point-length).
@@ -340,44 +341,44 @@ class DoubleToStringConverter {
// DoubleToAscii expects the given buffer to be big enough to hold all
// digits and a terminating null-character. In SHORTEST-mode it expects a
// buffer of at least kBase10MaximalLength + 1. In all other modes the

View File

@@ -1,8 +1,7 @@
diff --git a/mfbt/double-conversion/double-conversion/strtod.cc b/mfbt/double-conversion/double-conversion/strtod.cc
index 850bcdaac4ad1..6ed686c8d9bfb 100644
--- a/mfbt/double-conversion/double-conversion/strtod.cc
+++ b/mfbt/double-conversion/double-conversion/strtod.cc
@@ -447,32 +447,34 @@ static bool ComputeGuess(Vector<const char> trimmed, int exponent,
@@ -441,32 +441,34 @@ static bool ComputeGuess(Vector<const ch
return true;
}
if (*guess == Double::Infinity()) {

View File

@@ -370,7 +370,7 @@ static void BignumToFixed(int requested_digits, int* decimal_point,
// Returns an estimation of k such that 10^(k-1) <= v < 10^k where
// v = f * 2^exponent and 2^52 <= f < 2^53.
// v is hence a normalized double with the given exponent. The output is an
// approximation for the exponent of the decimal approximation .digits * 10^k.
// approximation for the exponent of the decimal approimation .digits * 10^k.
//
// The result might undershoot by 1 in which case 10^k <= v < 10^k+1.
// Note: this property holds for v's upper boundary m+ too.
@@ -548,7 +548,7 @@ static void InitialScaledStartValuesNegativeExponentNegativePower(
//
// Let ep == estimated_power, then the returned values will satisfy:
// v / 10^ep = numerator / denominator.
// v's boundaries m- and m+:
// v's boundarys m- and m+:
// m- / 10^ep == v / 10^ep - delta_minus / denominator
// m+ / 10^ep == v / 10^ep + delta_plus / denominator
// Or in other words:

View File

@@ -92,20 +92,20 @@ void DoubleToStringConverter::CreateExponentialRepresentation(
result_builder->AddCharacter('+');
}
}
if (exponent == 0) {
result_builder->AddCharacter('0');
return;
}
DOUBLE_CONVERSION_ASSERT(exponent < 1e4);
// Changing this constant requires updating the comment of DoubleToStringConverter constructor
const int kMaxExponentLength = 5;
char buffer[kMaxExponentLength + 1];
buffer[kMaxExponentLength] = '\0';
int first_char_pos = kMaxExponentLength;
if (exponent == 0) {
buffer[--first_char_pos] = '0';
} else {
while (exponent > 0) {
buffer[--first_char_pos] = '0' + (exponent % 10);
exponent /= 10;
}
}
// Add prefix '0' to make exponent width >= min(min_exponent_with_, kMaxExponentLength)
// For example: convert 1e+9 -> 1e+09, if min_exponent_with_ is set to 2
while(kMaxExponentLength - first_char_pos < std::min(min_exponent_width_, kMaxExponentLength)) {
@@ -295,7 +295,9 @@ bool DoubleToStringConverter::ToExponential(
bool DoubleToStringConverter::ToPrecision(double value,
int precision,
bool* used_exponential_notation,
StringBuilder* result_builder) const {
*used_exponential_notation = false;
if (Double(value).IsSpecial()) {
return HandleSpecialValues(value, result_builder);
}
@@ -327,21 +329,9 @@ bool DoubleToStringConverter::ToPrecision(double value,
int exponent = decimal_point - 1;
int extra_zero = ((flags_ & EMIT_TRAILING_ZERO_AFTER_POINT) != 0) ? 1 : 0;
bool as_exponential =
(-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) ||
if ((-decimal_point + 1 > max_leading_padding_zeroes_in_precision_mode_) ||
(decimal_point - precision + extra_zero >
max_trailing_padding_zeroes_in_precision_mode_);
if ((flags_ & NO_TRAILING_ZERO) != 0) {
// Truncate trailing zeros that occur after the decimal point (if exponential,
// that is everything after the first digit).
int stop = as_exponential ? 1 : std::max(1, decimal_point);
while (decimal_rep_length > stop && decimal_rep[decimal_rep_length - 1] == '0') {
--decimal_rep_length;
}
// Clamp precision to avoid the code below re-adding the zeros.
precision = std::min(precision, decimal_rep_length);
}
if (as_exponential) {
max_trailing_padding_zeroes_in_precision_mode_)) {
// Fill buffer to contain 'precision' digits.
// Usually the buffer is already at the correct length, but 'DoubleToAscii'
// is allowed to return less characters.
@@ -349,6 +339,7 @@ bool DoubleToStringConverter::ToPrecision(double value,
decimal_rep[i] = '0';
}
*used_exponential_notation = true;
CreateExponentialRepresentation(decimal_rep,
precision,
exponent,

View File

@@ -51,35 +51,12 @@ class DoubleToStringConverter {
static const int kMinPrecisionDigits = 1;
static const int kMaxPrecisionDigits = 120;
// The maximal number of digits that are needed to emit a double in base 10.
// A higher precision can be achieved by using more digits, but the shortest
// accurate representation of any double will never use more digits than
// kBase10MaximalLength.
// Note that DoubleToAscii null-terminates its input. So the given buffer
// should be at least kBase10MaximalLength + 1 characters long.
static const MFBT_DATA int kBase10MaximalLength = 17;
// The maximal number of digits that are needed to emit a single in base 10.
// A higher precision can be achieved by using more digits, but the shortest
// accurate representation of any single will never use more digits than
// kBase10MaximalLengthSingle.
static const int kBase10MaximalLengthSingle = 9;
// The length of the longest string that 'ToShortest' can produce when the
// converter is instantiated with EcmaScript defaults (see
// 'EcmaScriptConverter')
// This value does not include the trailing '\0' character.
// This amount of characters is needed for negative values that hit the
// 'decimal_in_shortest_low' limit. For example: "-0.0000033333333333333333"
static const int kMaxCharsEcmaScriptShortest = 25;
enum Flags {
NO_FLAGS = 0,
EMIT_POSITIVE_EXPONENT_SIGN = 1,
EMIT_TRAILING_DECIMAL_POINT = 2,
EMIT_TRAILING_ZERO_AFTER_POINT = 4,
UNIQUE_ZERO = 8,
NO_TRAILING_ZERO = 16
UNIQUE_ZERO = 8
};
// Flags should be a bit-or combination of the possible Flags-enum.
@@ -91,13 +68,9 @@ class DoubleToStringConverter {
// Example: 2345.0 is converted to "2345.".
// - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point
// emits a trailing '0'-character. This flag requires the
// EMIT_TRAILING_DECIMAL_POINT flag.
// EXMIT_TRAILING_DECIMAL_POINT flag.
// Example: 2345.0 is converted to "2345.0".
// - UNIQUE_ZERO: "-0.0" is converted to "0.0".
// - NO_TRAILING_ZERO: Trailing zeros are removed from the fractional portion
// of the result in precision mode. Matches printf's %g.
// When EMIT_TRAILING_ZERO_AFTER_POINT is also given, one trailing zero is
// preserved.
//
// Infinity symbol and nan_symbol provide the string representation for these
// special values. If the string is NULL and the special value is encountered
@@ -165,14 +138,6 @@ class DoubleToStringConverter {
}
// Returns a converter following the EcmaScript specification.
//
// Flags: UNIQUE_ZERO and EMIT_POSITIVE_EXPONENT_SIGN.
// Special values: "Infinity" and "NaN".
// Lower case 'e' for exponential values.
// decimal_in_shortest_low: -6
// decimal_in_shortest_high: 21
// max_leading_padding_zeroes_in_precision_mode: 6
// max_trailing_padding_zeroes_in_precision_mode: 0
static MFBT_API const DoubleToStringConverter& EcmaScriptConverter();
// Computes the shortest string of digits that correctly represent the input
@@ -198,21 +163,6 @@ class DoubleToStringConverter {
// Returns true if the conversion succeeds. The conversion always succeeds
// except when the input value is special and no infinity_symbol or
// nan_symbol has been given to the constructor.
//
// The length of the longest result is the maximum of the length of the
// following string representations (each with possible examples):
// - NaN and negative infinity: "NaN", "-Infinity", "-inf".
// - -10^(decimal_in_shortest_high - 1):
// "-100000000000000000000", "-1000000000000000.0"
// - the longest string in range [0; -10^decimal_in_shortest_low]. Generally,
// this string is 3 + kBase10MaximalLength - decimal_in_shortest_low.
// (Sign, '0', decimal point, padding zeroes for decimal_in_shortest_low,
// and the significant digits).
// "-0.0000033333333333333333", "-0.0012345678901234567"
// - the longest exponential representation. (A negative number with
// kBase10MaximalLength significant digits).
// "-1.7976931348623157e+308", "-1.7976931348623157E308"
// In addition, the buffer must be able to hold the trailing '\0' character.
bool ToShortest(double value, StringBuilder* result_builder) const {
return ToShortestIeeeNumber(value, result_builder, SHORTEST);
}
@@ -253,11 +203,9 @@ class DoubleToStringConverter {
// been provided to the constructor,
// - 'value' > 10^kMaxFixedDigitsBeforePoint, or
// - 'requested_digits' > kMaxFixedDigitsAfterPoint.
// The last two conditions imply that the result for non-special values never
// contains more than
// The last two conditions imply that the result will never contain more than
// 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters
// (one additional character for the sign, and one for the decimal point).
// In addition, the buffer must be able to hold the trailing '\0' character.
MFBT_API bool ToFixed(double value,
int requested_digits,
StringBuilder* result_builder) const;
@@ -286,17 +234,14 @@ class DoubleToStringConverter {
// - the input value is special and no infinity_symbol or nan_symbol has
// been provided to the constructor,
// - 'requested_digits' > kMaxExponentialDigits.
//
// The last condition implies that the result never contains more than
// The last condition implies that the result will never contain more than
// kMaxExponentialDigits + 8 characters (the sign, the digit before the
// decimal point, the decimal point, the exponent character, the
// exponent's sign, and at most 3 exponent digits).
// In addition, the buffer must be able to hold the trailing '\0' character.
MFBT_API bool ToExponential(double value,
int requested_digits,
StringBuilder* result_builder) const;
// Computes 'precision' leading digits of the given 'value' and returns them
// either in exponential or decimal format, depending on
// max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the
@@ -328,13 +273,12 @@ class DoubleToStringConverter {
// been provided to the constructor,
// - precision < kMinPericisionDigits
// - precision > kMaxPrecisionDigits
//
// The last condition implies that the result never contains more than
// The last condition implies that the result will never contain more than
// kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the
// exponent character, the exponent's sign, and at most 3 exponent digits).
// In addition, the buffer must be able to hold the trailing '\0' character.
MFBT_API bool ToPrecision(double value,
int precision,
bool* used_exponential_notation,
StringBuilder* result_builder) const;
enum DtoaMode {
@@ -352,6 +296,14 @@ class DoubleToStringConverter {
PRECISION
};
// The maximal number of digits that are needed to emit a double in base 10.
// A higher precision can be achieved by using more digits, but the shortest
// accurate representation of any double will never use more digits than
// kBase10MaximalLength.
// Note that DoubleToAscii null-terminates its input. So the given buffer
// should be at least kBase10MaximalLength + 1 characters long.
static const MFBT_DATA int kBase10MaximalLength = 17;
// Converts the given double 'v' to digit characters. 'v' must not be NaN,
// +Infinity, or -Infinity. In SHORTEST_SINGLE-mode this restriction also
// applies to 'v' after it has been casted to a single-precision float. That

View File

@@ -45,7 +45,6 @@ class Double {
static const uint64_t kExponentMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x7FF00000, 00000000);
static const uint64_t kSignificandMask = DOUBLE_CONVERSION_UINT64_2PART_C(0x000FFFFF, FFFFFFFF);
static const uint64_t kHiddenBit = DOUBLE_CONVERSION_UINT64_2PART_C(0x00100000, 00000000);
static const uint64_t kQuietNanBit = DOUBLE_CONVERSION_UINT64_2PART_C(0x00080000, 00000000);
static const int kPhysicalSignificandSize = 52; // Excludes the hidden bit.
static const int kSignificandSize = 53;
static const int kExponentBias = 0x3FF + kPhysicalSignificandSize;
@@ -149,15 +148,6 @@ class Double {
((d64 & kSignificandMask) != 0);
}
bool IsQuietNan() const {
return IsNan() && ((AsUint64() & kQuietNanBit) != 0);
}
bool IsSignalingNan() const {
return IsNan() && ((AsUint64() & kQuietNanBit) == 0);
}
bool IsInfinite() const {
uint64_t d64 = AsUint64();
return ((d64 & kExponentMask) == kExponentMask) &&
@@ -276,7 +266,6 @@ class Single {
static const uint32_t kExponentMask = 0x7F800000;
static const uint32_t kSignificandMask = 0x007FFFFF;
static const uint32_t kHiddenBit = 0x00800000;
static const uint32_t kQuietNanBit = 0x00400000;
static const int kPhysicalSignificandSize = 23; // Excludes the hidden bit.
static const int kSignificandSize = 24;
@@ -335,15 +324,6 @@ class Single {
((d32 & kSignificandMask) != 0);
}
bool IsQuietNan() const {
return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
}
bool IsSignalingNan() const {
return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
}
bool IsInfinite() const {
uint32_t d32 = AsUint32();
return ((d32 & kExponentMask) == kExponentMask) &&

View File

@@ -35,18 +35,6 @@
#include "strtod.h"
#include "utils.h"
#ifdef _MSC_VER
# if _MSC_VER >= 1900
// Fix MSVC >= 2015 (_MSC_VER == 1900) warning
// C4244: 'argument': conversion from 'const uc16' to 'char', possible loss of data
// against Advance and friends, when instantiated with **it as char, not uc16.
__pragma(warning(disable: 4244))
# endif
# if _MSC_VER <= 1700 // VS2012, see IsDecimalDigitForRadix warning fix, below
# define VS2012_RADIXWARN
# endif
#endif
namespace double_conversion {
namespace {
@@ -161,9 +149,9 @@ static double SignedZero(bool sign) {
//
// The function is small and could be inlined, but VS2012 emitted a warning
// because it constant-propagated the radix and concluded that the last
// condition was always true. Moving it into a separate function and
// suppressing optimisation keeps the compiler from warning.
#ifdef VS2012_RADIXWARN
// condition was always true. By moving it into a separate function the
// compiler wouldn't warn anymore.
#ifdef _MSC_VER
#pragma optimize("",off)
static bool IsDecimalDigitForRadix(int c, int radix) {
return '0' <= c && c <= '9' && (c - '0') < radix;
@@ -453,6 +441,11 @@ double StringToDoubleConverter::StringToIeee(
}
}
// The longest form of simplified number is: "-<significant digits>.1eXXX\0".
const int kBufferSize = kMaxSignificantDigits + 10;
char buffer[kBufferSize]; // NOLINT: size is known at compile time.
int buffer_pos = 0;
// Exponent will be adjusted if insignificant digits of the integer part
// or insignificant leading zeros of the fractional part are dropped.
int exponent = 0;
@@ -487,6 +480,7 @@ double StringToDoubleConverter::StringToIeee(
return junk_string_value_;
}
DOUBLE_CONVERSION_ASSERT(buffer_pos == 0);
*processed_characters_count = static_cast<int>(current - input);
return sign ? -Double::Infinity() : Double::Infinity();
}
@@ -505,6 +499,7 @@ double StringToDoubleConverter::StringToIeee(
return junk_string_value_;
}
DOUBLE_CONVERSION_ASSERT(buffer_pos == 0);
*processed_characters_count = static_cast<int>(current - input);
return sign ? -Double::NaN() : Double::NaN();
}
@@ -561,12 +556,6 @@ double StringToDoubleConverter::StringToIeee(
bool octal = leading_zero && (flags_ & ALLOW_OCTALS) != 0;
// The longest form of simplified number is: "-<significant digits>.1eXXX\0".
const int kBufferSize = kMaxSignificantDigits + 10;
DOUBLE_CONVERSION_STACK_UNINITIALIZED char
buffer[kBufferSize]; // NOLINT: size is known at compile time.
int buffer_pos = 0;
// Copy significant digits of the integer part (if any) to the buffer.
while (*current >= '0' && *current <= '9') {
if (significant_digits < kMaxSignificantDigits) {

View File

@@ -35,12 +35,10 @@
namespace double_conversion {
#if defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
// 2^53 = 9007199254740992.
// Any integer with at most 15 decimal digits will hence fit into a double
// (which has a 53bit significand) without loss of precision.
static const int kMaxExactDoubleIntegerDecimalDigits = 15;
#endif // #if defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
// 2^64 = 18446744073709551616 > 10^19
static const int kMaxUint64DecimalDigits = 19;
@@ -57,7 +55,6 @@ static const int kMinDecimalPower = -324;
static const uint64_t kMaxUint64 = DOUBLE_CONVERSION_UINT64_2PART_C(0xFFFFFFFF, FFFFFFFF);
#if defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
static const double exact_powers_of_ten[] = {
1.0, // 10^0
10.0,
@@ -85,7 +82,6 @@ static const double exact_powers_of_ten[] = {
10000000000000000000000.0
};
static const int kExactPowersOfTenSize = DOUBLE_CONVERSION_ARRAY_SIZE(exact_powers_of_ten);
#endif // #if defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
// Maximum number of significant digits in the decimal representation.
// In fact the value is 772 (see conversions.cc), but to give us some margin
@@ -202,14 +198,12 @@ static bool DoubleStrtod(Vector<const char> trimmed,
int exponent,
double* result) {
#if !defined(DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS)
// Avoid "unused parameter" warnings
(void) trimmed;
(void) exponent;
(void) result;
// On x86 the floating-point stack can be 64 or 80 bits wide. If it is
// 80 bits wide (as is the case on Linux) then double-rounding occurs and the
// result is not accurate.
// We know that Windows32 uses 64 bits and is therefore accurate.
// Note that the ARM simulator is compiled for 32bits. It therefore exhibits
// the same problem.
return false;
#else
if (trimmed.length() <= kMaxExactDoubleIntegerDecimalDigits) {

View File

@@ -56,28 +56,14 @@ inline void abort_noreturn() { MOZ_CRASH(); }
#endif
#endif
// Not all compilers support __has_attribute and combining a check for both
// ifdef and __has_attribute on the same preprocessor line isn't portable.
#ifdef __has_attribute
# define DOUBLE_CONVERSION_HAS_ATTRIBUTE(x) __has_attribute(x)
#else
# define DOUBLE_CONVERSION_HAS_ATTRIBUTE(x) 0
#endif
#ifndef DOUBLE_CONVERSION_UNUSED
#if DOUBLE_CONVERSION_HAS_ATTRIBUTE(unused)
#ifdef __GNUC__
#define DOUBLE_CONVERSION_UNUSED __attribute__((unused))
#else
#define DOUBLE_CONVERSION_UNUSED
#endif
#endif
#if DOUBLE_CONVERSION_HAS_ATTRIBUTE(uninitialized)
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED __attribute__((uninitialized))
#else
#define DOUBLE_CONVERSION_STACK_UNINITIALIZED
#endif
// Double operations detection based on target architecture.
// Linux uses a 80bit wide floating point stack on x86. This induces double
// rounding, which in turn leads to wrong results.
@@ -108,7 +94,6 @@ int main(int argc, char** argv) {
defined(__ARMEL__) || defined(__avr32__) || defined(_M_ARM) || defined(_M_ARM64) || \
defined(__hppa__) || defined(__ia64__) || \
defined(__mips__) || \
defined(__nios2__) || defined(__ghs) || \
defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \
defined(_POWER) || defined(_ARCH_PPC) || defined(_ARCH_PPC64) || \
defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
@@ -117,8 +102,7 @@ int main(int argc, char** argv) {
defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \
defined(__riscv) || defined(__e2k__) || \
defined(__or1k__) || defined(__arc__) || \
defined(__microblaze__) || defined(__XTENSA__) || \
defined(__EMSCRIPTEN__) || defined(__wasm32__)
defined(__EMSCRIPTEN__)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(__mc68000__) || \
defined(__pnacl__) || defined(__native_client__)

View File

@@ -12,6 +12,7 @@ LOCAL_PATCHES=""
LOCAL_PATCHES="$LOCAL_PATCHES add-mfbt-api-markers.patch"
LOCAL_PATCHES="$LOCAL_PATCHES use-mozilla-assertions.patch"
LOCAL_PATCHES="$LOCAL_PATCHES ToPrecision-exponential.patch"
LOCAL_PATCHES="$LOCAL_PATCHES debug-only-functions.patch"
TMPDIR=`mktemp --directory`
@@ -69,7 +70,7 @@ done
hg addremove "$DEST"
# Note the revision used in this update.
git -C "$LOCAL_CLONE" show -s > ./GIT-INFO
git -C "$LOCAL_CLONE" show > ./GIT-INFO
# Delete the tmpdir.
rm -rf "$TMPDIR"

View File

@@ -1,5 +1,4 @@
diff --git a/mfbt/double-conversion/double-conversion/utils.h b/mfbt/double-conversion/double-conversion/utils.h
index c72c333f020a1..6022132e2b495 100644
--- a/mfbt/double-conversion/double-conversion/utils.h
+++ b/mfbt/double-conversion/double-conversion/utils.h
@@ -26,38 +26,38 @@
@@ -41,8 +40,8 @@ index c72c333f020a1..6022132e2b495 100644
#endif
#endif
// Not all compilers support __has_attribute and combining a check for both
// ifdef and __has_attribute on the same preprocessor line isn't portable.
#ifdef __has_attribute
# define DOUBLE_CONVERSION_HAS_ATTRIBUTE(x) __has_attribute(x)
#ifndef DOUBLE_CONVERSION_UNUSED
#ifdef __GNUC__
#define DOUBLE_CONVERSION_UNUSED __attribute__((unused))
#else
#define DOUBLE_CONVERSION_UNUSED

View File

@@ -10,7 +10,6 @@
* Author: Kipp E.B. Hickman
*/
#include "double-conversion/double-conversion.h"
#include "mozilla/AllocPolicy.h"
#include "mozilla/Likely.h"
#include "mozilla/Printf.h"
@@ -27,9 +26,6 @@
# include <windows.h>
#endif
using double_conversion::DoubleToStringConverter;
using DTSC = DoubleToStringConverter;
/*
* Note: on some platforms va_list is defined as an array,
* and requires array notation.
@@ -53,8 +49,6 @@ struct NumArgState {
typedef mozilla::Vector<NumArgState, 20, mozilla::MallocAllocPolicy>
NumArgStateVector;
// For values up to and including TYPE_DOUBLE, the lowest bit indicates
// whether the type is signed (0) or unsigned (1).
#define TYPE_SHORT 0
#define TYPE_USHORT 1
#define TYPE_INTN 2
@@ -63,8 +57,8 @@ typedef mozilla::Vector<NumArgState, 20, mozilla::MallocAllocPolicy>
#define TYPE_ULONG 5
#define TYPE_LONGLONG 6
#define TYPE_ULONGLONG 7
#define TYPE_DOUBLE 8
#define TYPE_STRING 9
#define TYPE_STRING 8
#define TYPE_DOUBLE 9
#define TYPE_INTSTR 10
#define TYPE_POINTER 11
#if defined(XP_WIN)
@@ -132,14 +126,14 @@ bool mozilla::PrintfTarget::fill_n(const char* src, int srclen, int width,
}
cvtwidth = signwidth + srclen;
if (prec > 0 && (type != TYPE_DOUBLE)) {
if (prec > 0) {
if (prec > srclen) {
precwidth = prec - srclen; // Need zero filling
cvtwidth += precwidth;
}
}
if ((flags & FLAG_ZEROS) && ((type == TYPE_DOUBLE) || (prec < 0))) {
if ((flags & FLAG_ZEROS) && (prec < 0)) {
if (width > cvtwidth) {
zerowidth = width - cvtwidth; // Zero filling
cvtwidth += zerowidth;
@@ -233,9 +227,7 @@ bool mozilla::PrintfTarget::cvt_l(long num, int width, int prec, int radix,
int digits;
// according to the man page this needs to happen
if ((prec == 0) && (num == 0)) {
return fill_n("", 0, width, prec, type, flags);
}
if ((prec == 0) && (num == 0)) return true;
// Converting decimal is a little tricky. In the unsigned case we
// need to stop when we hit 10 digits. In the signed case, we can
@@ -262,9 +254,7 @@ bool mozilla::PrintfTarget::cvt_l(long num, int width, int prec, int radix,
bool mozilla::PrintfTarget::cvt_ll(int64_t num, int width, int prec, int radix,
int type, int flags, const char* hexp) {
// According to the man page, this needs to happen.
if (prec == 0 && num == 0) {
return fill_n("", 0, width, prec, type, flags);
}
if (prec == 0 && num == 0) return true;
// Converting decimal is a little tricky. In the unsigned case we
// need to stop when we hit 10 digits. In the signed case, we can
@@ -291,80 +281,57 @@ bool mozilla::PrintfTarget::cvt_ll(int64_t num, int width, int prec, int radix,
return fill_n(cvt, digits, width, prec, type, flags);
}
template <size_t N>
constexpr static size_t lengthof(const char (&)[N]) {
return N - 1;
}
// Longest possible output from ToFixed for positive numbers:
// [0-9]{kMaxFixedDigitsBeforePoint}\.[0-9]{kMaxFixedDigitsAfterPoint}?
constexpr int FIXED_MAX_CHARS =
DTSC::kMaxFixedDigitsBeforePoint + 1 + DTSC::kMaxFixedDigitsAfterPoint;
// Longest possible output from ToExponential:
// [1-9]\.[0-9]{kMaxExponentialDigits}e[+-][0-9]{1,3}
// (std::numeric_limits<double>::max() has exponent 308).
constexpr int EXPONENTIAL_MAX_CHARS =
lengthof("1.") + DTSC::kMaxExponentialDigits + lengthof("e+999");
// Longest possible output from ToPrecise:
// [0-9\.]{kMaxPrecisionDigits+1} or
// [1-9]\.[0-9]{kMaxPrecisionDigits-1}e[+-][0-9]{1,3}
constexpr int PRECISE_MAX_CHARS =
lengthof("1.") + DTSC::kMaxPrecisionDigits - 1 + lengthof("e+999");
constexpr int DTSC_MAX_CHARS =
std::max({FIXED_MAX_CHARS, EXPONENTIAL_MAX_CHARS, PRECISE_MAX_CHARS});
/*
* Convert a double precision floating point number into its printable
* form.
*/
bool mozilla::PrintfTarget::cvt_f(double d, char c, int width, int prec,
int flags) {
bool lower = islower(c);
const char* inf = lower ? "inf" : "INF";
const char* nan = lower ? "nan" : "NAN";
char e = lower ? 'e' : 'E';
DoubleToStringConverter converter(DTSC::UNIQUE_ZERO | DTSC::NO_TRAILING_ZERO |
DTSC::EMIT_POSITIVE_EXPONENT_SIGN,
inf, nan, e, 0, 0, 4, 0, 2);
// Longest of the above cases, plus space for a terminal nul character.
char buf[DTSC_MAX_CHARS + 1];
double_conversion::StringBuilder builder(buf, sizeof(buf));
bool success = false;
if (std::signbit(d)) {
d = std::abs(d);
flags |= FLAG_NEG;
bool mozilla::PrintfTarget::cvt_f(double d, const char* fmt0,
const char* fmt1) {
char fin[20];
// The size is chosen such that we can print DBL_MAX. See bug#1350097.
char fout[320];
int amount = fmt1 - fmt0;
MOZ_ASSERT((amount > 0) && (amount < (int)sizeof(fin)));
if (amount >= (int)sizeof(fin)) {
// Totally bogus % command to sprintf. Just ignore it
return true;
}
if (!std::isfinite(d)) {
flags &= ~FLAG_ZEROS;
memcpy(fin, fmt0, (size_t)amount);
fin[amount] = 0;
// Convert floating point using the native snprintf code
#ifdef DEBUG
{
const char* p = fin;
while (*p) {
MOZ_ASSERT(*p != 'L');
p++;
}
// "If the precision is missing, it shall be taken as 6."
if (prec < 0) {
prec = 6;
}
switch (c) {
case 'e':
case 'E':
success = converter.ToExponential(d, prec, &builder);
break;
case 'f':
case 'F':
success = converter.ToFixed(d, prec, &builder);
break;
case 'g':
case 'G':
// "If an explicit precision is zero, it shall be taken as 1."
success = converter.ToPrecision(d, prec ? prec : 1, &builder);
break;
#endif
size_t len = SprintfLiteral(fout, fin, d);
// Note that SprintfLiteral will always write a \0 at the end, so a
// "<=" check here would be incorrect -- the buffer size passed to
// snprintf includes the trailing \0, but the returned length does
// not.
if (MOZ_LIKELY(len < sizeof(fout))) {
return emit(fout, len);
}
if (!success) {
// Maybe the user used "%500.500f" or something like that.
size_t buf_size = len + 1;
UniqueFreePtr<char> buf((char*)malloc(buf_size));
if (!buf) {
return false;
}
int len = builder.position();
char* cvt = builder.Finalize();
return fill_n(cvt, len, width, prec, TYPE_DOUBLE, flags);
len = snprintf(buf.get(), buf_size, fin, d);
// If this assert fails, then SprintfLiteral has a bug -- and in
// this case we would like to learn of it, which is why there is a
// release assert.
MOZ_RELEASE_ASSERT(len < buf_size);
return emit(buf.get(), len);
}
/*
@@ -524,11 +491,8 @@ static bool BuildArgArray(const char* fmt, va_list ap, NumArgStateVector& nas) {
break;
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
nas[cn].type = TYPE_DOUBLE;
break;
@@ -648,8 +612,11 @@ bool mozilla::PrintfTarget::vprint(const char* fmt, va_list ap) {
const wchar_t* ws;
#endif
} u;
const char* fmt0;
const char* hexp;
int i;
char pattern[20];
const char* dolPt = nullptr; // in "%4$.2f", dolPt will point to '.'
// Build an argument array, IF the fmt is numbered argument
// list style, to contain the Numbered Argument list pointers.
@@ -666,6 +633,7 @@ bool mozilla::PrintfTarget::vprint(const char* fmt, va_list ap) {
continue;
}
fmt0 = fmt - 1;
// Gobble up the % format string. Hopefully we have handled all
// of the strange cases!
@@ -689,6 +657,7 @@ bool mozilla::PrintfTarget::vprint(const char* fmt, va_list ap) {
if (nas[i - 1].type == TYPE_UNKNOWN) MOZ_CRASH("Bad format string");
ap = nas[i - 1].ap;
dolPt = fmt;
c = *fmt++;
}
@@ -856,11 +825,18 @@ bool mozilla::PrintfTarget::vprint(const char* fmt, va_list ap) {
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
u.d = va_arg(ap, double);
if (!cvt_f(u.d, c, width, prec, flags)) return false;
if (!nas.empty()) {
i = fmt - dolPt;
if (i < int(sizeof(pattern))) {
pattern[0] = '%';
memcpy(&pattern[1], dolPt, size_t(i));
if (!cvt_f(u.d, pattern, &pattern[i + 1])) return false;
}
} else {
if (!cvt_f(u.d, fmt0, fmt)) return false;
}
break;

View File

@@ -115,7 +115,7 @@ class PrintfTarget {
const char* hxp);
bool cvt_ll(int64_t num, int width, int prec, int radix, int type, int flags,
const char* hexp);
bool cvt_f(double d, char c, int width, int prec, int flags);
bool cvt_f(double d, const char* fmt0, const char* fmt1);
bool cvt_s(const char* s, int width, int prec, int flags);
};

View File

@@ -7,31 +7,8 @@
#include "mozilla/Printf.h"
#include <cfloat>
#include <cmath>
#include <stdarg.h>
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wc++11-narrowing"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wnarrowing"
#endif
namespace tiformat {
#include "glibc_printf_tests/tiformat.c"
}
namespace tllformat {
#include "glibc_printf_tests/tllformat.c"
}
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
namespace tfformat {
#include "glibc_printf_tests/tfformat.c"
}
// A simple implementation of PrintfTarget, just for testing
// PrintfTarget::print.
class TestPrintfTarget : public mozilla::PrintfTarget {
@@ -65,32 +42,17 @@ static void TestPrintfTargetPrint() {
checker.print("test string");
}
static bool MOZ_FORMAT_PRINTF(5, 6)
check_print(const char* file, int line,
bool (*cmp)(const char* a, const char* b), const char* expect,
const char* fmt, ...) {
static bool MOZ_FORMAT_PRINTF(2, 3)
print_one(const char* expect, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
mozilla::SmprintfPointer output = mozilla::Vsmprintf(fmt, ap);
va_end(ap);
bool ret = output && cmp(output.get(), expect);
if (!ret && strcmp(expect, "ignore") != 0) {
printf("(actual) \"%s\" != (expected) \"%s\" (%s:%d)\n", output.get(),
expect, file, line);
}
return ret;
return output && !strcmp(output.get(), expect);
}
bool str_match(const char* a, const char* b) { return !strcmp(a, b); }
bool approx_match(const char* a, const char* b) {
return tfformat::matches(const_cast<char*>(a), b);
}
#define print_one(...) check_print(__FILE__, __LINE__, str_match, __VA_ARGS__)
static const char* zero() { return nullptr; }
static void TestPrintfFormats() {
@@ -189,49 +151,6 @@ static void TestPrintfFormats() {
print_one("7799 9977", "%2$zu %1$zu", (size_t)9977, (size_t)7799));
}
template <typename T, size_t N>
static void TestGlibcPrintf(T (&test_cases)[N], const char* file,
bool (*cmp)(const char* a, const char* b)) {
bool ok = true;
char fmt2[40];
for (auto& line : test_cases) {
// mozilla::PrintfTarget doesn't support the `#` flag character or the
// `a` conversion specifier.
if (!line.line || strchr(line.format_string, '#') ||
strchr(line.format_string, 'a')) {
continue;
}
// Derive the format string in the test case to add "2$" in the specifier
// (transforming e.g. "%f" into "%2$f"), and append "%1$.0d".
// The former will make the format string take the `line.value` as the
// second argument, and the latter will make the first argument formatted
// with no precision. We'll pass 0 as the first argument, such that the
// formatted value for it is "", which means the expected result string
// is still the same.
MOZ_RELEASE_ASSERT(sizeof(fmt2) > strlen(line.format_string) + 8);
const char* percent = strchr(line.format_string, '%');
MOZ_RELEASE_ASSERT(percent);
size_t percent_off = percent - line.format_string;
memcpy(fmt2, line.format_string, percent_off + 1);
memcpy(fmt2 + percent_off + 1, "2$", 2);
strcpy(fmt2 + percent_off + 3, percent + 1);
strcat(fmt2, "%1$.0d");
int l = line.line;
const char* res = line.result;
const char* fmt = line.format_string;
if (strchr(line.format_string, 'I')) {
ok = check_print(file, l, cmp, res, fmt, (size_t)line.value) && ok;
ok = check_print(file, l, cmp, res, fmt2, 0, (size_t)line.value) && ok;
} else {
ok = check_print(file, l, cmp, res, fmt, line.value) && ok;
ok = check_print(file, l, cmp, res, fmt2, 0, line.value) && ok;
}
}
MOZ_RELEASE_ASSERT(ok);
}
#if defined(XP_WIN)
int wmain()
#else
@@ -240,9 +159,6 @@ int main()
{
TestPrintfFormats();
TestPrintfTargetPrint();
TestGlibcPrintf(tiformat::sprint_ints, "tiformat.c", str_match);
TestGlibcPrintf(tllformat::sprint_ints, "tllformat.c", str_match);
TestGlibcPrintf(tfformat::sprint_doubles, "tfformat.c", approx_match);
return 0;
}

View File

@@ -1,339 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -1,502 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@@ -1,2 +0,0 @@
The files in this directory were copied from the stdio-common subdirectory
in glibc (https://sourceware.org/git/glibc.git).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,59 +0,0 @@
#include <stdio.h>
#include <string.h>
/* The original file was tiformat.c and it has been changed for long long tests\
. */
typedef struct
{
int line;
long long int value;
const char *result;
const char *format_string;
} sprint_int_type;
sprint_int_type sprint_ints[] =
{
{__LINE__, 0x00000000ULL, "0", "%llx"},
{__LINE__, 0xffff00000000208bULL, "ffff00000000208b", "%llx"},
{__LINE__, 0xffff00000000208bULL, "18446462598732849291", "%llu"},
{__LINE__, 18446462598732849291ULL, "ffff00000000208b", "%llx"},
{__LINE__, 18446462598732849291ULL, "18446462598732849291", "%llu"},
{__LINE__, 18359476226655002763ULL, "fec9f65b0000208b", "%llx"},
{__LINE__, 18359476226655002763ULL, "18359476226655002763", "%llu"},
{0},
};
int
main (void)
{
int errcount = 0;
int testcount = 0;
#define BSIZE 1024
char buffer[BSIZE];
sprint_int_type *iptr;
for (iptr = sprint_ints; iptr->line; iptr++)
{
sprintf (buffer, iptr->format_string, iptr->value);
if (strcmp (buffer, iptr->result) != 0)
{
++errcount;
printf ("\
Error in line %d using \"%s\". Result is \"%s\"; should be: \"%s\".\n",
iptr->line, iptr->format_string, buffer, iptr->result);
}
++testcount;
}
if (errcount == 0)
{
printf ("Encountered no errors in %d tests.\n", testcount);
return 0;
}
else
{
printf ("Encountered %d errors in %d tests.\n",
errcount, testcount);
return 1;
}
}

View File

@@ -134,7 +134,6 @@ modules/woff2/
modules/xz-embedded/
modules/zlib/
mozglue/misc/decimal/
mozglue/tests/glibc_printf_tests/
netwerk/dns/nsIDNKitInterface.h
netwerk/sctp/src/
netwerk/srtp/src/

View File

@@ -1297,13 +1297,64 @@ static int FormatWithoutTrailingZeros(char (&aBuf)[40], double aDouble,
int aPrecision) {
static const DoubleToStringConverter converter(
DoubleToStringConverter::UNIQUE_ZERO |
DoubleToStringConverter::NO_TRAILING_ZERO |
DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN,
"Infinity", "NaN", 'e', -6, 21, 6, 1);
double_conversion::StringBuilder builder(aBuf, sizeof(aBuf));
converter.ToPrecision(aDouble, aPrecision, &builder);
bool exponential_notation = false;
converter.ToPrecision(aDouble, aPrecision, &exponential_notation, &builder);
int length = builder.position();
builder.Finalize();
char* formattedDouble = builder.Finalize();
// If we have a shorter string than aPrecision, it means we have a special
// value (NaN or Infinity). All other numbers will be formatted with at
// least aPrecision digits.
if (length <= aPrecision) {
return length;
}
char* end = formattedDouble + length;
char* decimalPoint = strchr(aBuf, '.');
// No trailing zeros to remove.
if (!decimalPoint) {
return length;
}
if (MOZ_UNLIKELY(exponential_notation)) {
// We need to check for cases like 1.00000e-10 (yes, this is
// disgusting).
char* exponent = end - 1;
for (;; --exponent) {
if (*exponent == 'e') {
break;
}
}
char* zerosBeforeExponent = exponent - 1;
for (; zerosBeforeExponent != decimalPoint; --zerosBeforeExponent) {
if (*zerosBeforeExponent != '0') {
break;
}
}
if (zerosBeforeExponent == decimalPoint) {
--zerosBeforeExponent;
}
// Slide the exponent to the left over the trailing zeros. Don't
// worry about copying the trailing NUL character.
size_t exponentSize = end - exponent;
memmove(zerosBeforeExponent + 1, exponent, exponentSize);
length -= exponent - (zerosBeforeExponent + 1);
} else {
char* trailingZeros = end - 1;
for (; trailingZeros != decimalPoint; --trailingZeros) {
if (*trailingZeros != '0') {
break;
}
}
if (trailingZeros == decimalPoint) {
--trailingZeros;
}
length -= end - (trailingZeros + 1);
}
return length;
}