]> granicus.if.org Git - icu/commitdiff
ICU-13725 Additional MSVC compatibility fixes.
authorShane Carr <shane@unicode.org>
Wed, 25 Apr 2018 00:39:22 +0000 (00:39 +0000)
committerShane Carr <shane@unicode.org>
Wed, 25 Apr 2018 00:39:22 +0000 (00:39 +0000)
X-SVN-Rev: 41272

20 files changed:
icu4c/source/common/common.vcxproj
icu4c/source/common/common_uwp.vcxproj
icu4c/source/common/numparse_unisets.h
icu4c/source/i18n/decimfmt.cpp
icu4c/source/i18n/number_currencysymbols.h
icu4c/source/i18n/number_decimalquantity.cpp
icu4c/source/i18n/number_fluent.cpp
icu4c/source/i18n/number_integerwidth.cpp
icu4c/source/i18n/number_mapper.h
icu4c/source/i18n/number_multiplier.h
icu4c/source/i18n/number_utils.h
icu4c/source/i18n/numparse_affixes.h
icu4c/source/i18n/numparse_compositions.h
icu4c/source/i18n/numparse_impl.h
icu4c/source/i18n/numparse_parsednumber.cpp
icu4c/source/i18n/numparse_symbols.h
icu4c/source/i18n/numparse_types.h
icu4c/source/i18n/unicode/decimfmt.h
icu4c/source/test/intltest/numberformattesttuple.cpp
icu4c/source/test/intltest/numbertest_decimalquantity.cpp

index 894494d68691cc5150351f1ce421f7d922d1007d..f08bb065c590953bc35c4e22598139cb5e05803f 100644 (file)
     <ClInclude Include="uinvchar.h" />
     <ClInclude Include="ustr_cnv.h" />
     <ClInclude Include="ustr_imp.h" />
-    <ClCompile Include="numparse_unisets.h" />
+    <ClInclude Include="numparse_unisets.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="common.rc" />
index 690ed860f44ef0cda75f4bca2ac351ed3b6e7ab1..edddabe11c5306df97e902df619202a5d3ca3ce6 100644 (file)
     <ClInclude Include="uinvchar.h" />
     <ClInclude Include="ustr_cnv.h" />
     <ClInclude Include="ustr_imp.h" />
-    <ClCompile Include="numparse_unisets.h" />
+    <ClInclude Include="numparse_unisets.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="common.rc" />
index f02e9f5436b9431ef1709270dfcf6d0bfad81492..5a93b834524f5d8077469a5586684ff444d13411 100644 (file)
@@ -61,12 +61,14 @@ enum Key {
     COUNT
 };
 
-// Exported as U_COMMON_API for ucurr.h
-const U_COMMON_API UnicodeSet* get(Key key);
+// Exported as U_COMMON_API for ucurr.cpp
+U_COMMON_API const UnicodeSet* get(Key key);
 
-Key chooseFrom(UnicodeString str, Key key1);
+// Exported as U_COMMON_API for numparse_decimal.cpp
+U_COMMON_API Key chooseFrom(UnicodeString str, Key key1);
 
-Key chooseFrom(UnicodeString str, Key key1, Key key2);
+// Exported as U_COMMON_API for numparse_decimal.cpp
+U_COMMON_API Key chooseFrom(UnicodeString str, Key key1, Key key2);
 
 // Unused in C++:
 // Key chooseCurrency(UnicodeString str);
index dd2743441259bbc8ad18b4d6836c53369fbd5b8e..0c2e8adec4286759dae7771010a748589e863fe2 100644 (file)
@@ -30,6 +30,14 @@ using namespace icu::numparse::impl;
 using ERoundingMode = icu::DecimalFormat::ERoundingMode;
 using EPadPosition = icu::DecimalFormat::EPadPosition;
 
+// MSVC warns C4805 when comparing bool with UBool
+// TODO: Move this macro into a better place?
+#if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+#define UBOOL_TO_BOOL(b) static_cast<bool>(b)
+#else
+#define UBOOL_TO_BOOL(b) b
+#endif
+
 
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DecimalFormat)
 
@@ -89,7 +97,10 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols*
 DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorCode& status) {
     fProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status);
     fExportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status);
-    fWarehouse.adoptInsteadAndCheckErrorCode(new DecimalFormatWarehouse(), status);
+    fWarehouse = new DecimalFormatWarehouse();
+       if (fWarehouse == nullptr) {
+               status = U_MEMORY_ALLOCATION_ERROR;
+       }
     if (symbolsToAdopt == nullptr) {
         fSymbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(status), status);
     } else {
@@ -331,14 +342,14 @@ int32_t DecimalFormat::getAttribute(UNumberFormatAttribute attr, UErrorCode& sta
 }
 
 void DecimalFormat::setGroupingUsed(UBool enabled) {
-    if (enabled == fProperties->groupingUsed) { return; }
+    if (UBOOL_TO_BOOL(enabled) == fProperties->groupingUsed) { return; }
     NumberFormat::setGroupingUsed(enabled); // to set field for compatibility
     fProperties->groupingUsed = enabled;
     touchNoError();
 }
 
 void DecimalFormat::setParseIntegerOnly(UBool value) {
-    if (value == fProperties->parseIntegerOnly) { return; }
+    if (UBOOL_TO_BOOL(value) == fProperties->parseIntegerOnly) { return; }
     NumberFormat::setParseIntegerOnly(value); // to set field for compatibility
     fProperties->parseIntegerOnly = value;
     touchNoError();
@@ -374,7 +385,7 @@ DecimalFormat::DecimalFormat(const DecimalFormat& source) : NumberFormat(source)
     fProperties.adoptInstead(new DecimalFormatProperties(*source.fProperties));
     fSymbols.adoptInstead(new DecimalFormatSymbols(*source.fSymbols));
     fExportedProperties.adoptInstead(new DecimalFormatProperties());
-    fWarehouse.adoptInstead(new DecimalFormatWarehouse());
+    fWarehouse = new DecimalFormatWarehouse();
     if (fProperties == nullptr || fSymbols == nullptr || fExportedProperties == nullptr ||
         fWarehouse == nullptr) {
         return;
@@ -391,8 +402,9 @@ DecimalFormat& DecimalFormat::operator=(const DecimalFormat& rhs) {
 }
 
 DecimalFormat::~DecimalFormat() {
-    delete fAtomicParser.exchange(nullptr);
-    delete fAtomicCurrencyParser.exchange(nullptr);
+    delete fWarehouse->fAtomicParser.exchange(nullptr);
+    delete fWarehouse->fAtomicCurrencyParser.exchange(nullptr);
+       delete fWarehouse;
 };
 
 Format* DecimalFormat::clone() const {
@@ -665,7 +677,7 @@ UBool DecimalFormat::isSignAlwaysShown() const {
 }
 
 void DecimalFormat::setSignAlwaysShown(UBool value) {
-    if (value == fProperties->signAlwaysShown) { return; }
+    if (UBOOL_TO_BOOL(value) == fProperties->signAlwaysShown) { return; }
     fProperties->signAlwaysShown = value;
     touchNoError();
 }
@@ -819,7 +831,7 @@ UBool DecimalFormat::isExponentSignAlwaysShown(void) const {
 }
 
 void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) {
-    if (expSignAlways == fProperties->exponentSignAlwaysShown) { return; }
+    if (UBOOL_TO_BOOL(expSignAlways) == fProperties->exponentSignAlwaysShown) { return; }
     fProperties->exponentSignAlwaysShown = expSignAlways;
     touchNoError();
 }
@@ -866,7 +878,7 @@ UBool DecimalFormat::isDecimalSeparatorAlwaysShown(void) const {
 }
 
 void DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) {
-    if (newValue == fProperties->decimalSeparatorAlwaysShown) { return; }
+    if (UBOOL_TO_BOOL(newValue) == fProperties->decimalSeparatorAlwaysShown) { return; }
     fProperties->decimalSeparatorAlwaysShown = newValue;
     touchNoError();
 }
@@ -876,7 +888,7 @@ UBool DecimalFormat::isDecimalPatternMatchRequired(void) const {
 }
 
 void DecimalFormat::setDecimalPatternMatchRequired(UBool newValue) {
-    if (newValue == fProperties->decimalPatternMatchRequired) { return; }
+    if (UBOOL_TO_BOOL(newValue) == fProperties->decimalPatternMatchRequired) { return; }
     fProperties->decimalPatternMatchRequired = newValue;
     touchNoError();
 }
@@ -886,7 +898,7 @@ UBool DecimalFormat::isParseNoExponent() const {
 }
 
 void DecimalFormat::setParseNoExponent(UBool value) {
-    if (value == fProperties->parseNoExponent) { return; }
+    if (UBOOL_TO_BOOL(value) == fProperties->parseNoExponent) { return; }
     fProperties->parseNoExponent = value;
     touchNoError();
 }
@@ -896,7 +908,7 @@ UBool DecimalFormat::isParseCaseSensitive() const {
 }
 
 void DecimalFormat::setParseCaseSensitive(UBool value) {
-    if (value == fProperties->parseCaseSensitive) { return; }
+    if (UBOOL_TO_BOOL(value) == fProperties->parseCaseSensitive) { return; }
     fProperties->parseCaseSensitive = value;
     touchNoError();
 }
@@ -906,7 +918,7 @@ UBool DecimalFormat::isFormatFailIfMoreThanMaxDigits() const {
 }
 
 void DecimalFormat::setFormatFailIfMoreThanMaxDigits(UBool value) {
-    if (value == fProperties->formatFailIfMoreThanMaxDigits) { return; }
+    if (UBOOL_TO_BOOL(value) == fProperties->formatFailIfMoreThanMaxDigits) { return; }
     fProperties->formatFailIfMoreThanMaxDigits = value;
     touchNoError();
 }
@@ -1129,8 +1141,8 @@ void DecimalFormat::touch(UErrorCode& status) {
     setupFastFormat();
 
     // Delete the parsers if they were made previously
-    delete fAtomicParser.exchange(nullptr);
-    delete fAtomicCurrencyParser.exchange(nullptr);
+    delete fWarehouse->fAtomicParser.exchange(nullptr);
+    delete fWarehouse->fAtomicCurrencyParser.exchange(nullptr);
 
     // In order for the getters to work, we need to populate some fields in NumberFormat.
     NumberFormat::setCurrency(fExportedProperties->currency.get(status).getISOCurrency(), status);
@@ -1158,7 +1170,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getParser(UErrorCode& sta
     if (U_FAILURE(status)) { return nullptr; }
 
     // First try to get the pre-computed parser
-    auto* ptr = fAtomicParser.load();
+    auto* ptr = fWarehouse->fAtomicParser.load();
     if (ptr != nullptr) {
         return ptr;
     }
@@ -1173,7 +1185,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getParser(UErrorCode& sta
     // Note: ptr starts as nullptr; during compare_exchange, it is set to what is actually stored in the
     // atomic if another thread beat us to computing the parser object.
     auto* nonConstThis = const_cast<DecimalFormat*>(this);
-    if (!nonConstThis->fAtomicParser.compare_exchange_strong(ptr, temp)) {
+    if (!nonConstThis->fWarehouse->fAtomicParser.compare_exchange_strong(ptr, temp)) {
         // Another thread beat us to computing the parser
         delete temp;
         return ptr;
@@ -1187,7 +1199,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getCurrencyParser(UErrorC
     if (U_FAILURE(status)) { return nullptr; }
 
     // First try to get the pre-computed parser
-    auto* ptr = fAtomicCurrencyParser.load();
+    auto* ptr = fWarehouse->fAtomicCurrencyParser.load();
     if (ptr != nullptr) {
         return ptr;
     }
@@ -1202,7 +1214,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getCurrencyParser(UErrorC
     // Note: ptr starts as nullptr; during compare_exchange, it is set to what is actually stored in the
     // atomic if another thread beat us to computing the parser object.
     auto* nonConstThis = const_cast<DecimalFormat*>(this);
-    if (!nonConstThis->fAtomicCurrencyParser.compare_exchange_strong(ptr, temp)) {
+    if (!nonConstThis->fWarehouse->fAtomicCurrencyParser.compare_exchange_strong(ptr, temp)) {
         // Another thread beat us to computing the parser
         delete temp;
         return ptr;
index 9383cd3c164157da9faf395ed774c2d642141a38..9996bf96ae08a12f1d70edf1388520597ec1a6ea 100644 (file)
@@ -15,7 +15,8 @@ U_NAMESPACE_BEGIN namespace number {
 namespace impl {
 
 
-class CurrencySymbols : public UMemory {
+// Exported as U_I18N_API for tests
+class U_I18N_API CurrencySymbols : public UMemory {
   public:
     CurrencySymbols() = default; // default constructor: leaves class in valid but undefined state
 
index 9f11b0d0973cdef36aa0b5445c2fe6cc9683bf3e..aae5e07668691f36beaf685e86a4d4695406640c 100644 (file)
@@ -509,9 +509,9 @@ int64_t DecimalQuantity::toLong(bool truncateIfOverflow) const {
         result = result * 10 + getDigitPos(magnitude - scale);
     }
     if (isNegative()) {
-        return -result;
+        return static_cast<int64_t>(-result);
     }
-    return result;
+    return static_cast<int64_t>(result);
 }
 
 uint64_t DecimalQuantity::toFractionLong(bool includeTrailingZeros) const {
index e0945f9ba918ff127e0a8b704362baada87b50c9..c0aacf46b5d27eb98069c7a1c19ba63a152c6de4 100644 (file)
@@ -1,7 +1,6 @@
 // © 2017 and later: Unicode, Inc. and others.
 // License & terms of use: http://www.unicode.org/copyright.html
 
-#include <unicode/numberformatter.h>
 #include "unicode/utypes.h"
 
 #if !UCONFIG_NO_FORMATTING
index 6ed930af96b28e59375c7f9fbcf376eaef328fbe..6416b292982e56927ca79f299fa0fd8a7dfd8b5d 100644 (file)
@@ -1,7 +1,6 @@
 // © 2017 and later: Unicode, Inc. and others.
 // License & terms of use: http://www.unicode.org/copyright.html
 
-#include <unicode/numberformatter.h>
 #include "unicode/utypes.h"
 
 #if !UCONFIG_NO_FORMATTING
index 9d7784ee28c29ce3cbc24c104039ef4a06012593..275359b0c376938e6cd7c4b08c05ee9a518b4adf 100644 (file)
@@ -114,6 +114,10 @@ struct DecimalFormatWarehouse {
     PropertiesAffixPatternProvider propertiesAPP;
     CurrencyPluralInfoAffixProvider currencyPluralInfoAPP;
     CurrencySymbols currencySymbols;
+
+    // Can't have std::atomic in public header files, so put it here in the warehouse.
+    std::atomic<numparse::impl::NumberParserImpl*> fAtomicParser = {};
+    std::atomic<numparse::impl::NumberParserImpl*> fAtomicCurrencyParser = {};
 };
 
 
index 4e3415cb45eb1a831093a9c72a5687310758c4ff..15e0dd0dfda678f613222ba69c38ab8af4ae1438 100644 (file)
@@ -17,7 +17,8 @@ namespace impl {
 /**
  * Wraps a {@link Multiplier} for use in the number formatting pipeline.
  */
-class MultiplierFormatHandler : public MicroPropsGenerator, public UMemory {
+// Exported as U_I18N_API for tests
+class U_I18N_API MultiplierFormatHandler : public MicroPropsGenerator, public UMemory {
   public:
     void setAndChain(const Scale& multiplier, const MicroPropsGenerator* parent);
 
index 5c6be2d73c05976edf37059f83e5f1213aa3edf4..bd35e21c7056172e1d532d59b3e9db1553ccde21 100644 (file)
@@ -116,7 +116,8 @@ getPatternForStyle(const Locale& locale, const char* nsName, CldrPatternStyle st
 
 
 /** A very thin C++ wrapper around decNumber.h */
-class DecNum : public UMemory {
+// Exported as U_I18N_API for tests
+class U_I18N_API DecNum : public UMemory {
   public:
     DecNum();  // leaves object in valid but undefined state
 
index add421be70c0c6a89d60b9020bd0d04584523ead..933dcc7ea4574424a03f25bbc2097a7709a5f315 100644 (file)
@@ -47,7 +47,8 @@ class CodePointMatcher : public NumberParseMatcher, public UMemory {
 /**
  * A warehouse to retain ownership of CodePointMatchers.
  */
-class CodePointMatcherWarehouse : public UMemory {
+// Exported as U_I18N_API for tests
+class U_I18N_API CodePointMatcherWarehouse : public UMemory {
   private:
     static constexpr int32_t CODE_POINT_STACK_CAPACITY = 5; // Number of entries directly on the stack
     static constexpr int32_t CODE_POINT_BATCH_SIZE = 10; // Number of entries per heap allocation
@@ -92,7 +93,8 @@ struct AffixTokenMatcherSetupData {
  *
  * @author sffc
  */
-class AffixTokenMatcherWarehouse : public UMemory {
+// Exported as U_I18N_API for tests
+class U_I18N_API AffixTokenMatcherWarehouse : public UMemory {
   public:
     AffixTokenMatcherWarehouse() = default;  // WARNING: Leaves the object in an unusable state
 
@@ -154,7 +156,8 @@ class AffixPatternMatcherBuilder : public TokenConsumer, public MutableMatcherCo
 };
 
 
-class AffixPatternMatcher : public ArraySeriesMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API AffixPatternMatcher : public ArraySeriesMatcher {
   public:
     AffixPatternMatcher() = default;  // WARNING: Leaves the object in an unusable state
 
index 252b007c19a8d8c88e832166db91e9d7ea2d81b5..39a33d40fd22a232ee5eb3ad515c3288c0904622 100644 (file)
@@ -61,7 +61,8 @@ class CompositionMatcher : public NumberParseMatcher {
  * @author sffc
  * @see AnyMatcher
  */
-class SeriesMatcher : public CompositionMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API SeriesMatcher : public CompositionMatcher {
   public:
     bool match(StringSegment& segment, ParsedNumber& result, UErrorCode& status) const override;
 
@@ -82,7 +83,8 @@ class SeriesMatcher : public CompositionMatcher {
  *
  * The object adopts the array, but NOT the matchers contained inside the array.
  */
-class ArraySeriesMatcher : public SeriesMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API ArraySeriesMatcher : public SeriesMatcher {
   public:
     ArraySeriesMatcher();  // WARNING: Leaves the object in an unusable state
 
index 5a28ff5dbc77aacf31780b804a6e4f5dc252693d..e4eac0e9c09681a90869ffcdcb0da2197c7c333c 100644 (file)
@@ -22,7 +22,8 @@
 U_NAMESPACE_BEGIN namespace numparse {
 namespace impl {
 
-class NumberParserImpl : public MutableMatcherCollection {
+// Exported as U_I18N_API for tests
+class U_I18N_API NumberParserImpl : public MutableMatcherCollection {
   public:
     virtual ~NumberParserImpl();
 
index 6e0478c749840176c05de6d47adfe13e1f85ef68..f0e063b8b85c35e8ad044ac7ba27bff8d31341df 100644 (file)
@@ -72,7 +72,7 @@ double ParsedNumber::getDouble() const {
     }
 
     if (quantity.fitsInLong()) {
-        return quantity.toLong();
+        return static_cast<double>(quantity.toLong());
     } else {
         return quantity.toDouble();
     }
index 16a009ccd7c2cdef686bd4fedd16d605111c2587..9c39156d5cbdf14db78ec8c0a5bcac2c18ad202c 100644 (file)
@@ -44,7 +44,8 @@ class SymbolMatcher : public NumberParseMatcher, public UMemory {
 };
 
 
-class IgnorablesMatcher : public SymbolMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API IgnorablesMatcher : public SymbolMatcher {
   public:
     IgnorablesMatcher() = default;  // WARNING: Leaves the object in an unusable state
 
@@ -74,7 +75,8 @@ class InfinityMatcher : public SymbolMatcher {
 };
 
 
-class MinusSignMatcher : public SymbolMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API MinusSignMatcher : public SymbolMatcher {
   public:
     MinusSignMatcher() = default;  // WARNING: Leaves the object in an unusable state
 
@@ -118,7 +120,8 @@ class PaddingMatcher : public SymbolMatcher {
 };
 
 
-class PercentMatcher : public SymbolMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API PercentMatcher : public SymbolMatcher {
   public:
     PercentMatcher() = default;  // WARNING: Leaves the object in an unusable state
 
@@ -144,7 +147,8 @@ class PermilleMatcher : public SymbolMatcher {
 };
 
 
-class PlusSignMatcher : public SymbolMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API PlusSignMatcher : public SymbolMatcher {
   public:
     PlusSignMatcher() = default;  // WARNING: Leaves the object in an unusable state
 
index 3b3fe13cc33c62f6811153f161f01bd85cbdef69..5859afa18497e6d873179bb9ca1f1bf5c8572007 100644 (file)
@@ -84,7 +84,8 @@ class CompactUnicodeString {
  *
  * @author sffc
  */
-class ParsedNumber {
+// Exported as U_I18N_API for tests
+class U_I18N_API ParsedNumber {
   public:
 
     /**
@@ -171,7 +172,8 @@ class ParsedNumber {
  *
  * @author sffc
  */
-class StringSegment : public UMemory {
+// Exported as U_I18N_API for tests
+class U_I18N_API StringSegment : public UMemory {
   public:
     StringSegment(const UnicodeString& str, bool ignoreCase);
 
@@ -282,7 +284,8 @@ class StringSegment : public UMemory {
  *
  * @author sffc
  */
-class NumberParseMatcher {
+// Exported as U_I18N_API for tests
+class U_I18N_API NumberParseMatcher {
   public:
     /**
      * Matchers can override this method to return true to indicate that they are optional and can be run
index a8339559d1f1712cb7366326f0a3ea98779e5cfe..a446e6ff951a675b1b5ef4727f93cda1130e7e6c 100644 (file)
@@ -78,6 +78,14 @@ class NumberParserImpl;
 // explicit template instantiation. see digitlst.h
 // (When building DLLs for Windows this is required.)
 #if U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
+// Ignore warning 4661 as LocalPointerBase does not use operator== or operator!=
+#pragma warning(suppress: 4661)
+template class U_I18N_API LocalPointerBase<number::LocalizedNumberFormatter>;
+template class U_I18N_API LocalPointer<number::LocalizedNumberFormatter>;
+template class U_I18N_API LocalPointerBase<number::impl::DecimalFormatProperties>;
+template class U_I18N_API LocalPointer<number::impl::DecimalFormatProperties>;
+template class U_I18N_API LocalPointerBase<DecimalFormatSymbols>;
+template class U_I18N_API LocalPointer<DecimalFormatSymbols>;
 template class U_I18N_API    EnumSet<UNumberFormatAttribute,
             UNUM_MAX_NONBOOLEAN_ATTRIBUTE+1,
             UNUM_LIMIT_BOOLEAN_ATTRIBUTE>;
@@ -2144,11 +2152,11 @@ class U_I18N_API DecimalFormat : public NumberFormat {
      */
     LocalPointer<number::impl::DecimalFormatProperties> fExportedProperties;
 
-    /** A field for a few additional helper object that need ownership. */
-    LocalPointer<number::impl::DecimalFormatWarehouse> fWarehouse;
-
-    std::atomic<numparse::impl::NumberParserImpl*> fAtomicParser = {};
-    std::atomic<numparse::impl::NumberParserImpl*> fAtomicCurrencyParser = {};
+    /**
+        * A field for a few additional helper object that need ownership.
+        * Can't be a LocalPointer because it is an internal class.
+        */
+    number::impl::DecimalFormatWarehouse* fWarehouse;
 
     // Data for fastpath
     bool fCanUseFastFormat;
index 45d0d8de40bc6d566fc522aaa37c6f888a645a20..b9dc11b142ca39e36f747b11807a74f99553294f 100644 (file)
@@ -152,7 +152,7 @@ static void strToInt(
         }
         value = value * 10 - 0x30 + (int32_t) ch;
     }
-    int32_t signedValue = neg ? -value : static_cast<int32_t>(value);
+    int32_t signedValue = neg ? static_cast<int32_t>(-value) : static_cast<int32_t>(value);
     *static_cast<int32_t *>(intPtr) = signedValue;
 }
 
index 4fdd8ab85b17efaa979be2c1d21b794cdc380ba6..cb34e2605cc6c4269f965cb42556413afb0501e8 100644 (file)
@@ -367,7 +367,7 @@ void DecimalQuantityTest::testMaxDigits() {
     assertEquals("Should trim, toPlainString", "76.54", dq.toPlainString());
     assertEquals("Should trim, toScientificString", "7.654E+1", dq.toScientificString());
     assertEquals("Should trim, toLong", 76LL, dq.toLong(true));
-    assertEquals("Should trim, toFractionLong", 54L, dq.toFractionLong(false));
+    assertEquals("Should trim, toFractionLong", 54LL, dq.toFractionLong(false));
     assertEquals("Should trim, toDouble", 76.54, dq.toDouble());
     // To test DecNum output, check the round-trip.
     DecNum dn;