]> granicus.if.org Git - icu/commitdiff
ICU-20439 Updating double-conversion.
authorShane F. Carr <shane@unicode.org>
Sat, 16 Mar 2019 00:36:32 +0000 (17:36 -0700)
committerShane F. Carr <shane@unicode.org>
Tue, 19 Mar 2019 04:17:22 +0000 (21:17 -0700)
21 files changed:
icu4c/source/i18n/double-conversion.cpp
vendor/double-conversion/upstream/CMakeLists.txt
vendor/double-conversion/upstream/Changelog
vendor/double-conversion/upstream/double-conversion/bignum-dtoa.cc
vendor/double-conversion/upstream/double-conversion/bignum-dtoa.h
vendor/double-conversion/upstream/double-conversion/bignum.cc
vendor/double-conversion/upstream/double-conversion/bignum.h
vendor/double-conversion/upstream/double-conversion/cached-powers.cc
vendor/double-conversion/upstream/double-conversion/cached-powers.h
vendor/double-conversion/upstream/double-conversion/diy-fp.cc
vendor/double-conversion/upstream/double-conversion/diy-fp.h
vendor/double-conversion/upstream/double-conversion/double-conversion.cc
vendor/double-conversion/upstream/double-conversion/double-conversion.h
vendor/double-conversion/upstream/double-conversion/fast-dtoa.cc
vendor/double-conversion/upstream/double-conversion/fast-dtoa.h
vendor/double-conversion/upstream/double-conversion/fixed-dtoa.cc
vendor/double-conversion/upstream/double-conversion/fixed-dtoa.h
vendor/double-conversion/upstream/double-conversion/ieee.h
vendor/double-conversion/upstream/double-conversion/strtod.cc
vendor/double-conversion/upstream/double-conversion/strtod.h
vendor/double-conversion/upstream/test/cctest/test-conversions.cc

index f4b33e8c4ef51f519ec7908252a0e1c6ece48b73..1a60afbd64b6b7f83ddfdddd9095f8fd3c0d8653 100644 (file)
@@ -579,7 +579,7 @@ static bool IsCharacterDigitForRadix(int c, int radix, char a_character) {
 
 // Returns true, when the iterator is equal to end.
 template<class Iterator>
-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<class Iterator>
 static bool IsHexFloatString(Iterator start,
                              Iterator end,
-                             char separator,
+                             uc16 separator,
                              bool allow_trailing_junk) {
   ASSERT(start != end);
 
@@ -648,7 +648,7 @@ template <int radix_log_2, class Iterator>
 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,
index 3cd74241090b2c9d3a14a668df9922ff74e09865..d9f4be8f3f1ae8312126b0650061c39c284a9db5 100644 (file)
@@ -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
index 16e92d5fd563fa495d4867a6965694027b16f823..943db2686803ba34d2eb0aaff82209ee09c9aeee 100644 (file)
@@ -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.
 
index 526f96edf5459199de3f898bfce4ccb92d86209c..d99ac2aaf9dddb9445fe9a7411e3a70d1e75d529 100644 (file)
 
 #include <cmath>
 
-#include <double-conversion/bignum-dtoa.h>
+#include "bignum-dtoa.h"
 
-#include <double-conversion/bignum.h>
-#include <double-conversion/ieee.h>
+#include "bignum.h"
+#include "ieee.h"
 
 namespace double_conversion {
 
index 9d15ce3dce97969964056426af6d5da776c83abb..34b961992d672c1713bc19dde430939d28dffb53 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_BIGNUM_DTOA_H_
 #define DOUBLE_CONVERSION_BIGNUM_DTOA_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index a7bc86d0c0e155c22741dc42c925a39673ada96b..d077eef3f55c446f288c13f17762f58f3cd53910 100644 (file)
@@ -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 <double-conversion/bignum.h>
-#include <double-conversion/utils.h>
+#include "bignum.h"
+#include "utils.h"
 
 namespace double_conversion {
 
index 238a351196e4733dd0ae035deab1a83bbb71a672..7c289fa2f6bd7b0118db8209f998f1d3b2449742 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_BIGNUM_H_
 #define DOUBLE_CONVERSION_BIGNUM_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index 6f771e9c73d95f0db32c906331e379c4f46cd0e7..8ab281a1ba088e1343929a8d669c4dda8e699b26 100644 (file)
@@ -29,9 +29,9 @@
 #include <cmath>
 #include <cstdarg>
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
-#include <double-conversion/cached-powers.h>
+#include "cached-powers.h"
 
 namespace double_conversion {
 
index eabff4a15afd982eaa30088fc69d2ae04925b093..61a50614cf10c730829467007be06c6e66a6d44e 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_CACHED_POWERS_H_
 #define DOUBLE_CONVERSION_CACHED_POWERS_H_
 
-#include <double-conversion/diy-fp.h>
+#include "diy-fp.h"
 
 namespace double_conversion {
 
index 82b0d08af4efaf7d4f07d7030582624d5e608c40..ddd1891b168ada0b67b3d124ff3c63b352d7fda6 100644 (file)
@@ -26,8 +26,8 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-#include <double-conversion/diy-fp.h>
-#include <double-conversion/utils.h>
+#include "diy-fp.h"
+#include "utils.h"
 
 namespace double_conversion {
 
index e2011d43e5aa55bf2e774a314191c3ef3194d934..2edf34674ee25c34969406d6f4bdcfb215924730 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_DIY_FP_H_
 #define DOUBLE_CONVERSION_DIY_FP_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index 854f4b60ef275863a7b3d808fef17c30b15b6e17..d5a04f6ca1a87269aa6fccf4db4233a7e176e042 100644 (file)
 #include <locale>
 #include <cmath>
 
-#include <double-conversion/double-conversion.h>
+#include "double-conversion.h"
 
-#include <double-conversion/bignum-dtoa.h>
-#include <double-conversion/fast-dtoa.h>
-#include <double-conversion/fixed-dtoa.h>
-#include <double-conversion/ieee.h>
-#include <double-conversion/strtod.h>
-#include <double-conversion/utils.h>
+#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<class Iterator>
-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<class Iterator>
 static bool IsHexFloatString(Iterator start,
                              Iterator end,
-                             char separator,
+                             uc16 separator,
                              bool allow_trailing_junk) {
   ASSERT(start != end);
 
@@ -622,7 +622,7 @@ template <int radix_log_2, class Iterator>
 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,
index 7495d17a1d5970acf4a9b01649963810e5f206a4..6dbc0997c617f38be9d8ed348ad9d1d9a1b7499d 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
 #define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index e5c222291f5e92d5b44c6e8d2936c56bfae5d83e..61350383a95ea69e73604bd692ae2037ff4b7b14 100644 (file)
 // (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 <double-conversion/fast-dtoa.h>
+#include "fast-dtoa.h"
 
-#include <double-conversion/cached-powers.h>
-#include <double-conversion/diy-fp.h>
-#include <double-conversion/ieee.h>
+#include "cached-powers.h"
+#include "diy-fp.h"
+#include "ieee.h"
 
 namespace double_conversion {
 
index ac4317c04dd4e925e9b62944bf717def606c9942..5f1e8eee5e56e7c496c84dc0a5bf9dad0b97fc9f 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_FAST_DTOA_H_
 #define DOUBLE_CONVERSION_FAST_DTOA_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index 8c111aca6425783728c96fa726b03d1a76f7ccc3..0f989bceaf2082dc3388431ffc346d84a473de2a 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <cmath>
 
-#include <double-conversion/fixed-dtoa.h>
-#include <double-conversion/ieee.h>
+#include "fixed-dtoa.h"
+#include "ieee.h"
 
 namespace double_conversion {
 
index a9436fc9f617157786f539955475e7498215a655..3bdd08e21f59d5fece37eb14a6f510f464c3f2ba 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_FIXED_DTOA_H_
 #define DOUBLE_CONVERSION_FIXED_DTOA_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index baaeced31ce7b04a4e83b0cfefed8c7da49c5ddb..4a5fe8f9c0a4e43ea152fe8667f4efa389f348a9 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_DOUBLE_H_
 #define DOUBLE_CONVERSION_DOUBLE_H_
 
-#include <double-conversion/diy-fp.h>
+#include "diy-fp.h"
 
 namespace double_conversion {
 
index e8cc13f2de97c5692f43001b6c33881cfc800058..a75cf5d9f1bfac8845c5e4668e7460256a920ead 100644 (file)
 #include <climits>
 #include <cstdarg>
 
-#include <double-conversion/bignum.h>
-#include <double-conversion/cached-powers.h>
-#include <double-conversion/ieee.h>
-#include <double-conversion/strtod.h>
+#include "bignum.h"
+#include "cached-powers.h"
+#include "ieee.h"
+#include "strtod.h"
 
 namespace double_conversion {
 
index 322651621fb29c7ac4e30981f1cc037eb3af412c..ed0293b8f54a373762f17fe4dd70f2896eb1d193 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DOUBLE_CONVERSION_STRTOD_H_
 #define DOUBLE_CONVERSION_STRTOD_H_
 
-#include <double-conversion/utils.h>
+#include "utils.h"
 
 namespace double_conversion {
 
index 9ebc823f26a7ee04313d20f127a4a0342e802c69..878fd0f6bed2ae2a39e469a93d277bfbc47c1c77 100644 (file)
@@ -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<double>(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<double>(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) {