From 6c86dc108db30dd7bbaa469d802f2898657a61d3 Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Fri, 15 Mar 2019 17:36:32 -0700 Subject: [PATCH] ICU-20439 Updating double-conversion. --- icu4c/source/i18n/double-conversion.cpp | 6 +- .../double-conversion/upstream/CMakeLists.txt | 2 +- vendor/double-conversion/upstream/Changelog | 22 +++++ .../upstream/double-conversion/bignum-dtoa.cc | 6 +- .../upstream/double-conversion/bignum-dtoa.h | 2 +- .../upstream/double-conversion/bignum.cc | 4 +- .../upstream/double-conversion/bignum.h | 2 +- .../double-conversion/cached-powers.cc | 4 +- .../double-conversion/cached-powers.h | 2 +- .../upstream/double-conversion/diy-fp.cc | 4 +- .../upstream/double-conversion/diy-fp.h | 2 +- .../double-conversion/double-conversion.cc | 20 ++-- .../double-conversion/double-conversion.h | 2 +- .../upstream/double-conversion/fast-dtoa.cc | 8 +- .../upstream/double-conversion/fast-dtoa.h | 2 +- .../upstream/double-conversion/fixed-dtoa.cc | 4 +- .../upstream/double-conversion/fixed-dtoa.h | 2 +- .../upstream/double-conversion/ieee.h | 2 +- .../upstream/double-conversion/strtod.cc | 8 +- .../upstream/double-conversion/strtod.h | 2 +- .../upstream/test/cctest/test-conversions.cc | 94 ++++++++++++++++++- 21 files changed, 157 insertions(+), 43 deletions(-) diff --git a/icu4c/source/i18n/double-conversion.cpp b/icu4c/source/i18n/double-conversion.cpp index f4b33e8c4ef..1a60afbd64b 100644 --- a/icu4c/source/i18n/double-conversion.cpp +++ b/icu4c/source/i18n/double-conversion.cpp @@ -579,7 +579,7 @@ static bool IsCharacterDigitForRadix(int c, int radix, char a_character) { // Returns true, when the iterator is equal to end. template -static bool Advance (Iterator* it, char separator, int base, Iterator& end) { +static bool Advance (Iterator* it, uc16 separator, int base, Iterator& end) { if (separator == StringToDoubleConverter::kNoSeparator) { ++(*it); return *it == end; @@ -607,7 +607,7 @@ static bool Advance (Iterator* it, char separator, int base, Iterator& end) { template static bool IsHexFloatString(Iterator start, Iterator end, - char separator, + uc16 separator, bool allow_trailing_junk) { ASSERT(start != end); @@ -648,7 +648,7 @@ template static double RadixStringToIeee(Iterator* current, Iterator end, bool sign, - char separator, + uc16 separator, bool parse_as_hex_float, bool allow_trailing_junk, double junk_string_value, diff --git a/vendor/double-conversion/upstream/CMakeLists.txt b/vendor/double-conversion/upstream/CMakeLists.txt index 3cd74241090..d9f4be8f3f1 100644 --- a/vendor/double-conversion/upstream/CMakeLists.txt +++ b/vendor/double-conversion/upstream/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -project(double-conversion VERSION 3.1.1) +project(double-conversion VERSION 3.1.4) set(headers double-conversion/bignum.h diff --git a/vendor/double-conversion/upstream/Changelog b/vendor/double-conversion/upstream/Changelog index 16e92d5fd56..943db268680 100644 --- a/vendor/double-conversion/upstream/Changelog +++ b/vendor/double-conversion/upstream/Changelog @@ -1,3 +1,25 @@ +2019-03-11: + Use relative includes in the library. This shouldn't have any visible effect + for consumers of the library. + + Update version number. + +2019-03-06: + Fix typo in test. + Update version number. + +2019-03-03: + Fix separator characters when they they don't fit into 8 bits. + Update version number. + +2019-02-16: + Check correctly for _MSC_VER. + Patch by Ben Boeckel + +2019-01-17: + Allow the library to be compiled for Emscripten. + Patch by Tim Paine. + 2018-09-15: Update version numbers. This also updates the shared-library version number. diff --git a/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.cc b/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.cc index 526f96edf54..d99ac2aaf9d 100644 --- a/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.cc +++ b/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.cc @@ -27,10 +27,10 @@ #include -#include +#include "bignum-dtoa.h" -#include -#include +#include "bignum.h" +#include "ieee.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.h b/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.h index 9d15ce3dce9..34b961992d6 100644 --- a/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.h +++ b/vendor/double-conversion/upstream/double-conversion/bignum-dtoa.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_ #define DOUBLE_CONVERSION_BIGNUM_DTOA_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/bignum.cc b/vendor/double-conversion/upstream/double-conversion/bignum.cc index a7bc86d0c0e..d077eef3f55 100644 --- a/vendor/double-conversion/upstream/double-conversion/bignum.cc +++ b/vendor/double-conversion/upstream/double-conversion/bignum.cc @@ -25,8 +25,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include -#include +#include "bignum.h" +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/bignum.h b/vendor/double-conversion/upstream/double-conversion/bignum.h index 238a351196e..7c289fa2f6b 100644 --- a/vendor/double-conversion/upstream/double-conversion/bignum.h +++ b/vendor/double-conversion/upstream/double-conversion/bignum.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_BIGNUM_H_ #define DOUBLE_CONVERSION_BIGNUM_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/cached-powers.cc b/vendor/double-conversion/upstream/double-conversion/cached-powers.cc index 6f771e9c73d..8ab281a1ba0 100644 --- a/vendor/double-conversion/upstream/double-conversion/cached-powers.cc +++ b/vendor/double-conversion/upstream/double-conversion/cached-powers.cc @@ -29,9 +29,9 @@ #include #include -#include +#include "utils.h" -#include +#include "cached-powers.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/cached-powers.h b/vendor/double-conversion/upstream/double-conversion/cached-powers.h index eabff4a15af..61a50614cf1 100644 --- a/vendor/double-conversion/upstream/double-conversion/cached-powers.h +++ b/vendor/double-conversion/upstream/double-conversion/cached-powers.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_ #define DOUBLE_CONVERSION_CACHED_POWERS_H_ -#include +#include "diy-fp.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/diy-fp.cc b/vendor/double-conversion/upstream/double-conversion/diy-fp.cc index 82b0d08af4e..ddd1891b168 100644 --- a/vendor/double-conversion/upstream/double-conversion/diy-fp.cc +++ b/vendor/double-conversion/upstream/double-conversion/diy-fp.cc @@ -26,8 +26,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include -#include +#include "diy-fp.h" +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/diy-fp.h b/vendor/double-conversion/upstream/double-conversion/diy-fp.h index e2011d43e5a..2edf34674ee 100644 --- a/vendor/double-conversion/upstream/double-conversion/diy-fp.h +++ b/vendor/double-conversion/upstream/double-conversion/diy-fp.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DIY_FP_H_ #define DOUBLE_CONVERSION_DIY_FP_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/double-conversion.cc b/vendor/double-conversion/upstream/double-conversion/double-conversion.cc index 854f4b60ef2..d5a04f6ca1a 100644 --- a/vendor/double-conversion/upstream/double-conversion/double-conversion.cc +++ b/vendor/double-conversion/upstream/double-conversion/double-conversion.cc @@ -29,14 +29,14 @@ #include #include -#include +#include "double-conversion.h" -#include -#include -#include -#include -#include -#include +#include "bignum-dtoa.h" +#include "fast-dtoa.h" +#include "fixed-dtoa.h" +#include "ieee.h" +#include "strtod.h" +#include "utils.h" namespace double_conversion { @@ -553,7 +553,7 @@ static bool IsCharacterDigitForRadix(int c, int radix, char a_character) { // Returns true, when the iterator is equal to end. template -static bool Advance (Iterator* it, char separator, int base, Iterator& end) { +static bool Advance (Iterator* it, uc16 separator, int base, Iterator& end) { if (separator == StringToDoubleConverter::kNoSeparator) { ++(*it); return *it == end; @@ -581,7 +581,7 @@ static bool Advance (Iterator* it, char separator, int base, Iterator& end) { template static bool IsHexFloatString(Iterator start, Iterator end, - char separator, + uc16 separator, bool allow_trailing_junk) { ASSERT(start != end); @@ -622,7 +622,7 @@ template static double RadixStringToIeee(Iterator* current, Iterator end, bool sign, - char separator, + uc16 separator, bool parse_as_hex_float, bool allow_trailing_junk, double junk_string_value, diff --git a/vendor/double-conversion/upstream/double-conversion/double-conversion.h b/vendor/double-conversion/upstream/double-conversion/double-conversion.h index 7495d17a1d5..6dbc0997c61 100644 --- a/vendor/double-conversion/upstream/double-conversion/double-conversion.h +++ b/vendor/double-conversion/upstream/double-conversion/double-conversion.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/fast-dtoa.cc b/vendor/double-conversion/upstream/double-conversion/fast-dtoa.cc index e5c222291f5..61350383a95 100644 --- a/vendor/double-conversion/upstream/double-conversion/fast-dtoa.cc +++ b/vendor/double-conversion/upstream/double-conversion/fast-dtoa.cc @@ -25,11 +25,11 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include "fast-dtoa.h" -#include -#include -#include +#include "cached-powers.h" +#include "diy-fp.h" +#include "ieee.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/fast-dtoa.h b/vendor/double-conversion/upstream/double-conversion/fast-dtoa.h index ac4317c04dd..5f1e8eee5e5 100644 --- a/vendor/double-conversion/upstream/double-conversion/fast-dtoa.h +++ b/vendor/double-conversion/upstream/double-conversion/fast-dtoa.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_FAST_DTOA_H_ #define DOUBLE_CONVERSION_FAST_DTOA_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.cc b/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.cc index 8c111aca642..0f989bceaf2 100644 --- a/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.cc +++ b/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.cc @@ -27,8 +27,8 @@ #include -#include -#include +#include "fixed-dtoa.h" +#include "ieee.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.h b/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.h index a9436fc9f61..3bdd08e21f5 100644 --- a/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.h +++ b/vendor/double-conversion/upstream/double-conversion/fixed-dtoa.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_ #define DOUBLE_CONVERSION_FIXED_DTOA_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/ieee.h b/vendor/double-conversion/upstream/double-conversion/ieee.h index baaeced31ce..4a5fe8f9c0a 100644 --- a/vendor/double-conversion/upstream/double-conversion/ieee.h +++ b/vendor/double-conversion/upstream/double-conversion/ieee.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_DOUBLE_H_ #define DOUBLE_CONVERSION_DOUBLE_H_ -#include +#include "diy-fp.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/strtod.cc b/vendor/double-conversion/upstream/double-conversion/strtod.cc index e8cc13f2de9..a75cf5d9f1b 100644 --- a/vendor/double-conversion/upstream/double-conversion/strtod.cc +++ b/vendor/double-conversion/upstream/double-conversion/strtod.cc @@ -28,10 +28,10 @@ #include #include -#include -#include -#include -#include +#include "bignum.h" +#include "cached-powers.h" +#include "ieee.h" +#include "strtod.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/double-conversion/strtod.h b/vendor/double-conversion/upstream/double-conversion/strtod.h index 322651621fb..ed0293b8f54 100644 --- a/vendor/double-conversion/upstream/double-conversion/strtod.h +++ b/vendor/double-conversion/upstream/double-conversion/strtod.h @@ -28,7 +28,7 @@ #ifndef DOUBLE_CONVERSION_STRTOD_H_ #define DOUBLE_CONVERSION_STRTOD_H_ -#include +#include "utils.h" namespace double_conversion { diff --git a/vendor/double-conversion/upstream/test/cctest/test-conversions.cc b/vendor/double-conversion/upstream/test/cctest/test-conversions.cc index 9ebc823f26a..878fd0f6bed 100644 --- a/vendor/double-conversion/upstream/test/cctest/test-conversions.cc +++ b/vendor/double-conversion/upstream/test/cctest/test-conversions.cc @@ -1735,6 +1735,33 @@ static double StrToD16(const uc16* str16, int length, int flags, } +static double StrToD16(const char* str, int flags, + double empty_string_value, + int* processed_characters_count, bool* processed_all, + char char_separator, uc16 separator) { + uc16 str16[256]; + int length = -1; + for (int i = 0;; i++) { + if (str[i] == char_separator) { + str16[i] = separator; + } else { + str16[i] = str[i]; + } + if (str[i] == '\0') { + length = i; + break; + } + } + ASSERT(length < 256); + StringToDoubleConverter converter(flags, empty_string_value, Double::NaN(), + NULL, NULL, separator); + double result = + converter.StringToDouble(str16, length, processed_characters_count); + *processed_all = (length == *processed_characters_count); + return result; +} + + static double StrToD(const char* str, int flags, double empty_string_value, int* processed_characters_count, bool* processed_all, uc16 separator = StringToDoubleConverter::kNoSeparator) { @@ -3207,7 +3234,7 @@ TEST(StringToDoubleSeparator) { int flags; int processed; bool all_used; - char separator; + uc16 separator; separator = '\''; flags = StringToDoubleConverter::NO_FLAGS; @@ -3518,6 +3545,71 @@ TEST(StringToDoubleSeparator) { CHECK_EQ(Double::NaN(), StrToD("0x0 3.p -0", flags, 0.0, &processed, &all_used)); CHECK_EQ(0, processed); + + separator = 0x202F; + char char_separator = '@'; + flags = StringToDoubleConverter::ALLOW_HEX | + StringToDoubleConverter::ALLOW_HEX_FLOATS | + StringToDoubleConverter::ALLOW_LEADING_SPACES | + StringToDoubleConverter::ALLOW_TRAILING_SPACES; + + CHECK_EQ(18.0, + StrToD16("0x1@2", flags, 0.0, &processed, &all_used, + char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(0.0, StrToD16("0x0@0", flags, 1.0, &processed, &all_used, + char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(static_cast(0x123456789), + StrToD16("0x1@2@3@4@5@6@7@8@9", flags, Double::NaN(), + &processed, &all_used, char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(18.0, StrToD16(" 0x1@2 ", flags, 0.0, + &processed, &all_used, char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(static_cast(0xabcdef), + StrToD16("0xa@b@c@d@e@f", flags, 0.0, + &processed, &all_used, char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(Double::NaN(), + StrToD16("0x@1@2", flags, 0.0, + &processed, &all_used, char_separator, separator)); + CHECK_EQ(0, processed); + + CHECK_EQ(Double::NaN(), + StrToD16("0@x0", flags, 1.0, + &processed, &all_used, char_separator, separator)); + CHECK_EQ(0, processed); + + CHECK_EQ(Double::NaN(), + StrToD16("0x1@2@@3@4@5@6@7@8@9", flags, Double::NaN(), + &processed, &all_used, char_separator, separator)); + CHECK_EQ(0, processed); + + CHECK_EQ(3.0, + StrToD16("0x0@3p0", flags, 0.0, &processed, &all_used, + char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(0.0, + StrToD16("0x.0@0p0", flags, 0.0, &processed, &all_used, + char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(3.0, + StrToD16("0x3.0@0p0", flags, 0.0, &processed, &all_used, + char_separator, separator)); + CHECK(all_used); + + CHECK_EQ(3.0, + StrToD16("0x0@3.p0", flags, 0.0, &processed, &all_used, + char_separator, separator)); + CHECK(all_used); } TEST(StringToDoubleSpecialValues) {