| 1 | Retrieved from: <https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/main/intl/icu-patches/double-conversion.diff>
|
| 2 |
|
| 3 | diff --git a/source/i18n/measunit_extra.cpp b/source/i18n/measunit_extra.cpp
|
| 4 | |
| 5 | |
| 6 | @@ -10,17 +10,21 @@
|
| 7 |
|
| 8 | // Allow implicit conversion from char16_t* to UnicodeString for this file:
|
| 9 | // Helpful in toString methods and elsewhere.
|
| 10 | #define UNISTR_FROM_STRING_EXPLICIT
|
| 11 |
|
| 12 | #include "charstr.h"
|
| 13 | #include "cmemory.h"
|
| 14 | #include "cstring.h"
|
| 15 | +#ifdef JS_HAS_INTL_API
|
| 16 | +#include "double-conversion/string-to-double.h"
|
| 17 | +#else
|
| 18 | #include "double-conversion-string-to-double.h"
|
| 19 | +#endif
|
| 20 | #include "measunit_impl.h"
|
| 21 | #include "resource.h"
|
| 22 | #include "uarrsort.h"
|
| 23 | #include "uassert.h"
|
| 24 | #include "ucln_in.h"
|
| 25 | #include "umutex.h"
|
| 26 | #include "unicode/bytestrie.h"
|
| 27 | #include "unicode/bytestriebuilder.h"
|
| 28 | @@ -33,17 +37,21 @@
|
| 29 | #include "util.h"
|
| 30 | #include <limits.h>
|
| 31 | #include <cstdlib>
|
| 32 | U_NAMESPACE_BEGIN
|
| 33 |
|
| 34 |
|
| 35 | namespace {
|
| 36 |
|
| 37 | +#ifdef JS_HAS_INTL_API
|
| 38 | +using double_conversion::StringToDoubleConverter;
|
| 39 | +#else
|
| 40 | using icu::double_conversion::StringToDoubleConverter;
|
| 41 | +#endif
|
| 42 |
|
| 43 | // TODO: Propose a new error code for this?
|
| 44 | constexpr UErrorCode kUnitIdentifierSyntaxError = U_ILLEGAL_ARGUMENT_ERROR;
|
| 45 |
|
| 46 | // Trie value offset for SI or binary prefixes. This is big enough to ensure we only
|
| 47 | // insert positive integers into the trie.
|
| 48 | constexpr int32_t kPrefixOffset = 64;
|
| 49 | static_assert(kPrefixOffset + UMEASURE_PREFIX_INTERNAL_MIN_BIN > 0,
|
| 50 | diff --git a/source/i18n/number_decimalquantity.cpp b/source/i18n/number_decimalquantity.cpp
|
| 51 | |
| 52 | |
| 53 | @@ -11,28 +11,37 @@
|
| 54 | #include <stdlib.h>
|
| 55 |
|
| 56 | #include "unicode/plurrule.h"
|
| 57 | #include "cmemory.h"
|
| 58 | #include "number_decnum.h"
|
| 59 | #include "putilimp.h"
|
| 60 | #include "number_decimalquantity.h"
|
| 61 | #include "number_roundingutils.h"
|
| 62 | +#ifdef JS_HAS_INTL_API
|
| 63 | +#include "double-conversion/double-conversion.h"
|
| 64 | +#else
|
| 65 | #include "double-conversion.h"
|
| 66 | +#endif
|
| 67 | #include "charstr.h"
|
| 68 | #include "number_utils.h"
|
| 69 | #include "uassert.h"
|
| 70 | #include "util.h"
|
| 71 |
|
| 72 | using namespace icu;
|
| 73 | using namespace icu::number;
|
| 74 | using namespace icu::number::impl;
|
| 75 |
|
| 76 | +#ifdef JS_HAS_INTL_API
|
| 77 | +using double_conversion::DoubleToStringConverter;
|
| 78 | +using double_conversion::StringToDoubleConverter;
|
| 79 | +#else
|
| 80 | using icu::double_conversion::DoubleToStringConverter;
|
| 81 | using icu::double_conversion::StringToDoubleConverter;
|
| 82 | +#endif
|
| 83 |
|
| 84 | namespace {
|
| 85 |
|
| 86 | int8_t NEGATIVE_FLAG = 1;
|
| 87 | int8_t INFINITY_FLAG = 2;
|
| 88 | int8_t NAN_FLAG = 4;
|
| 89 |
|
| 90 | /** Helper function for safe subtraction (no overflow). */
|
| 91 | diff --git a/source/i18n/number_rounding.cpp b/source/i18n/number_rounding.cpp
|
| 92 | |
| 93 | |
| 94 | @@ -5,17 +5,21 @@
|
| 95 |
|
| 96 | #if !UCONFIG_NO_FORMATTING
|
| 97 |
|
| 98 | #include "charstr.h"
|
| 99 | #include "uassert.h"
|
| 100 | #include "unicode/numberformatter.h"
|
| 101 | #include "number_types.h"
|
| 102 | #include "number_decimalquantity.h"
|
| 103 | +#ifdef JS_HAS_INTL_API
|
| 104 | +#include "double-conversion/double-conversion.h"
|
| 105 | +#else
|
| 106 | #include "double-conversion.h"
|
| 107 | +#endif
|
| 108 | #include "number_roundingutils.h"
|
| 109 | #include "number_skeletons.h"
|
| 110 | #include "number_decnum.h"
|
| 111 | #include "putilimp.h"
|
| 112 | #include "string_segment.h"
|
| 113 |
|
| 114 | using namespace icu;
|
| 115 | using namespace icu::number;
|
| 116 | diff --git a/source/i18n/number_utils.cpp b/source/i18n/number_utils.cpp
|
| 117 | |
| 118 | |
| 119 | @@ -12,26 +12,34 @@
|
| 120 | #include <stdlib.h>
|
| 121 | #include <cmath>
|
| 122 | #include "number_decnum.h"
|
| 123 | #include "number_types.h"
|
| 124 | #include "number_utils.h"
|
| 125 | #include "charstr.h"
|
| 126 | #include "decContext.h"
|
| 127 | #include "decNumber.h"
|
| 128 | +#ifdef JS_HAS_INTL_API
|
| 129 | +#include "double-conversion/double-conversion.h"
|
| 130 | +#else
|
| 131 | #include "double-conversion.h"
|
| 132 | +#endif
|
| 133 | #include "fphdlimp.h"
|
| 134 | #include "uresimp.h"
|
| 135 | #include "ureslocs.h"
|
| 136 |
|
| 137 | using namespace icu;
|
| 138 | using namespace icu::number;
|
| 139 | using namespace icu::number::impl;
|
| 140 |
|
| 141 | +#ifdef JS_HAS_INTL_API
|
| 142 | +using double_conversion::DoubleToStringConverter;
|
| 143 | +#else
|
| 144 | using icu::double_conversion::DoubleToStringConverter;
|
| 145 | +#endif
|
| 146 |
|
| 147 |
|
| 148 | namespace {
|
| 149 |
|
| 150 | const char16_t*
|
| 151 | doGetPattern(UResourceBundle* res, const char* nsName, const char* patternKey, UErrorCode& publicStatus,
|
| 152 | UErrorCode& localStatus) {
|
| 153 | // Construct the path into the resource bundle
|
| 154 | diff --git a/source/i18n/units_converter.cpp b/source/i18n/units_converter.cpp
|
| 155 | |
| 156 | |
| 157 | @@ -2,17 +2,21 @@
|
| 158 | // License & terms of use: http://www.unicode.org/copyright.html
|
| 159 |
|
| 160 | #include "unicode/utypes.h"
|
| 161 |
|
| 162 | #if !UCONFIG_NO_FORMATTING
|
| 163 |
|
| 164 | #include "charstr.h"
|
| 165 | #include "cmemory.h"
|
| 166 | +#ifdef JS_HAS_INTL_API
|
| 167 | +#include "double-conversion/string-to-double.h"
|
| 168 | +#else
|
| 169 | #include "double-conversion-string-to-double.h"
|
| 170 | +#endif
|
| 171 | #include "measunit_impl.h"
|
| 172 | #include "putilimp.h"
|
| 173 | #include "uassert.h"
|
| 174 | #include "unicode/errorcode.h"
|
| 175 | #include "unicode/localpointer.h"
|
| 176 | #include "unicode/stringpiece.h"
|
| 177 | #include "units_converter.h"
|
| 178 | #include <algorithm>
|
| 179 | @@ -101,17 +105,21 @@ void U_I18N_API Factor::substituteConsta
|
| 180 | this->constantExponents[i] = 0;
|
| 181 | }
|
| 182 | }
|
| 183 |
|
| 184 | namespace {
|
| 185 |
|
| 186 | /* Helpers */
|
| 187 |
|
| 188 | +#ifdef JS_HAS_INTL_API
|
| 189 | +using double_conversion::StringToDoubleConverter;
|
| 190 | +#else
|
| 191 | using icu::double_conversion::StringToDoubleConverter;
|
| 192 | +#endif
|
| 193 |
|
| 194 | // TODO: Make this a shared-utility function.
|
| 195 | // Returns `double` from a scientific number(i.e. "1", "2.01" or "3.09E+4")
|
| 196 | double strToDouble(StringPiece strNum, UErrorCode &status) {
|
| 197 | // We are processing well-formed input, so we don't need any special options to
|
| 198 | // StringToDoubleConverter.
|
| 199 | StringToDoubleConverter converter(0, 0, 0, "", "");
|
| 200 | int32_t count;
|