Issue #1756 - Clean up ICU patch.

We don't need ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS because we don't support any
ICU other than the one in-tree.
pull/24/head
Moonchild 1 year ago committed by roytam1
parent bdcb9cc504
commit 4651d97342
  1. 7
      intl/icu-patches/unum_formatDoubleForFields.diff
  2. 5
      intl/icu/source/i18n/unicode/unum.h
  3. 26
      js/src/builtin/Intl.cpp

@ -23,7 +23,7 @@ diff --git a/intl/icu/source/i18n/unicode/unum.h b/intl/icu/source/i18n/unicode/
* <h2> Number Format C API </h2>
*
* Number Format C API Provides functions for
@@ -647,16 +648,67 @@ U_STABLE int32_t U_EXPORT2
@@ -647,16 +648,66 @@ U_STABLE int32_t U_EXPORT2
unum_formatUFormattable(const UNumberFormat* fmt,
const UFormattable *number,
UChar *result,
@ -71,16 +71,15 @@ diff --git a/intl/icu/source/i18n/unicode/unum.h b/intl/icu/source/i18n/unicode/
+* @see unum_parseDouble
+* @see UFieldPositionIterator
+* @see UNumberFormatFields
+* @draft ICU 59
+* @stable ICU 59
+*/
+U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
+unum_formatDoubleForFields(const UNumberFormat* format,
+ double number,
+ UChar* result,
+ int32_t resultLength,
+ UFieldPositionIterator* fpositer,
+ UErrorCode* status);
+#define ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS
+
+/**
* Parse a string into an integer using a UNumberFormat.

@ -692,16 +692,15 @@ unum_formatUFormattable(const UNumberFormat* fmt,
* @see unum_parseDouble
* @see UFieldPositionIterator
* @see UNumberFormatFields
* @draft ICU 59
* @stable ICU 59
*/
U_DRAFT int32_t U_EXPORT2
U_STABLE int32_t U_EXPORT2
unum_formatDoubleForFields(const UNumberFormat* format,
double number,
UChar* result,
int32_t resultLength,
UFieldPositionIterator* fpositer,
UErrorCode* status);
#define ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS
/**
* Parse a string into an integer using a UNumberFormat.

@ -1202,23 +1202,11 @@ PartitionNumberPattern(JSContext* cx, UNumberFormat* nf, double* x,
MOZ_ALWAYS_TRUE(formattedChars.resize(INITIAL_CHAR_BUFFER_SIZE));
UErrorCode status = U_ZERO_ERROR;
#if !defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
MOZ_ASSERT(fpositer == nullptr,
"shouldn't be requesting field information from an ICU that "
"can't provide it");
#endif
int32_t resultSize;
#if defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
resultSize =
unum_formatDoubleForFields(nf, *x,
Char16ToUChar(formattedChars.begin()), INITIAL_CHAR_BUFFER_SIZE,
fpositer, &status);
#else
resultSize =
unum_formatDouble(nf, *x, Char16ToUChar(formattedChars.begin()), INITIAL_CHAR_BUFFER_SIZE,
nullptr, &status);
#endif // defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
if (status == U_BUFFER_OVERFLOW_ERROR) {
if (!formattedChars.resize(size_t(resultSize)))
return false;
@ -1226,13 +1214,8 @@ PartitionNumberPattern(JSContext* cx, UNumberFormat* nf, double* x,
#ifdef DEBUG
int32_t size =
#endif
#if defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
unum_formatDoubleForFields(nf, *x, Char16ToUChar(formattedChars.begin()), resultSize,
fpositer, &status);
#else
unum_formatDouble(nf, *x, Char16ToUChar(formattedChars.begin()), resultSize,
nullptr, &status);
#endif // defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
MOZ_ASSERT(size == resultSize);
}
if (U_FAILURE(status)) {
@ -1262,8 +1245,6 @@ intl_FormatNumber(JSContext* cx, UNumberFormat* nf, double x, MutableHandleValue
using FieldType = ImmutablePropertyNamePtr JSAtomState::*;
#if defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
static FieldType
GetFieldTypeForNumberField(UNumberFormatFields fieldName, double d)
{
@ -1658,8 +1639,6 @@ intl_FormatNumberToParts(JSContext* cx, UNumberFormat* nf, double x, MutableHand
return true;
}
#endif // defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
bool
js::intl_FormatNumber(JSContext* cx, unsigned argc, Value* vp)
{
@ -1699,12 +1678,9 @@ js::intl_FormatNumber(JSContext* cx, unsigned argc, Value* vp)
RootedValue result(cx);
bool success;
#if defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
if (args[2].toBoolean()) {
success = intl_FormatNumberToParts(cx, nf, d, &result);
} else
#endif // defined(ICU_UNUM_HAS_FORMATDOUBLEFORFIELDS)
{
} else {
MOZ_ASSERT(!args[2].toBoolean(),
"shouldn't be doing formatToParts without an ICU that "
"supports it");

Loading…
Cancel
Save