Merge pull request #43 from icu-units/warnings

Fix some compiler warnings
This commit is contained in:
Hugo van der Merwe 2020-07-22 11:06:59 +02:00 committed by GitHub
commit be11edb0bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 39 deletions

View file

@ -112,40 +112,6 @@ class ConversionRateDataSink : public ResourceSink {
MaybeStackVector<ConversionRateInfo> *outVector;
};
UnitPreferenceMetadata::UnitPreferenceMetadata(StringPiece category, StringPiece usage,
StringPiece region, int32_t prefsOffset,
int32_t prefsCount, UErrorCode &status) {
this->category.append(category, status);
this->usage.append(usage, status);
this->region.append(region, status);
this->prefsOffset = prefsOffset;
this->prefsCount = prefsCount;
}
int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other) const {
int32_t cmp = uprv_strcmp(category.data(), other.category.data());
if (cmp == 0) { cmp = uprv_strcmp(usage.data(), other.usage.data()); }
if (cmp == 0) { cmp = uprv_strcmp(region.data(), other.region.data()); }
return cmp;
}
int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other, bool *foundCategory,
bool *foundUsage, bool *foundRegion) const {
int32_t cmp = uprv_strcmp(category.data(), other.category.data());
if (cmp == 0) {
*foundCategory = true;
cmp = uprv_strcmp(usage.data(), other.usage.data());
}
if (cmp == 0) {
*foundUsage = true;
cmp = uprv_strcmp(region.data(), other.region.data());
}
if (cmp == 0) {
*foundRegion = true;
}
return cmp;
}
bool operator<(const UnitPreferenceMetadata &a, const UnitPreferenceMetadata &b) {
return a.compareTo(b) < 0;
}
@ -357,6 +323,44 @@ int32_t getPreferenceMetadataIndex(const MaybeStackVector<UnitPreferenceMetadata
} // namespace
UnitPreferenceMetadata::UnitPreferenceMetadata(StringPiece category, StringPiece usage,
StringPiece region, int32_t prefsOffset,
int32_t prefsCount, UErrorCode &status) {
this->category.append(category, status);
this->usage.append(usage, status);
this->region.append(region, status);
this->prefsOffset = prefsOffset;
this->prefsCount = prefsCount;
}
int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other) const {
int32_t cmp = uprv_strcmp(category.data(), other.category.data());
if (cmp == 0) {
cmp = uprv_strcmp(usage.data(), other.usage.data());
}
if (cmp == 0) {
cmp = uprv_strcmp(region.data(), other.region.data());
}
return cmp;
}
int32_t UnitPreferenceMetadata::compareTo(const UnitPreferenceMetadata &other, bool *foundCategory,
bool *foundUsage, bool *foundRegion) const {
int32_t cmp = uprv_strcmp(category.data(), other.category.data());
if (cmp == 0) {
*foundCategory = true;
cmp = uprv_strcmp(usage.data(), other.usage.data());
}
if (cmp == 0) {
*foundUsage = true;
cmp = uprv_strcmp(region.data(), other.region.data());
}
if (cmp == 0) {
*foundRegion = true;
}
return cmp;
}
CharString U_I18N_API getUnitCategory(const char *baseUnitIdentifier, UErrorCode &status) {
CharString result;
LocalUResourceBundlePointer unitsBundle(ures_openDirect(NULL, "units", &status));

View file

@ -105,8 +105,6 @@ struct U_I18N_API UnitPreference : public UMemory {
UnicodeString skeleton;
};
namespace {
/**
* Metadata about the preferences in UnitPreferences::unitPrefs_.
*
@ -142,8 +140,6 @@ class U_I18N_API UnitPreferenceMetadata : public UMemory {
bool *foundRegion) const;
};
} // namespace
/**
* Unit Preferences information for various locales and usages.
*/

View file

@ -2183,7 +2183,7 @@ UBool IntlTest::assertEqualsNear(const char* message,
return FALSE;
}
bool bothNaN = std::isnan(expected) && std::isnan(actual);
double difference = abs(expected - actual);
double difference = std::abs(expected - actual);
if (expected != actual && (difference > delta || std::isnan(difference)) && !bothNaN) {
errln((UnicodeString)("FAIL: ") + message + "; got " + actual + "; expected " + expected +
"; acceptable delta " + delta);