Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
  • Loading branch information
younies committed Jan 21, 2025
1 parent 7c30dff commit c2e68d5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions icu4c/source/i18n/measunit_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class Token {
// If the value is not positive integer, it will return `kUnitIdentifierSyntaxError`.
uint64_t parseStrigToLong(const StringPiece str, UErrorCode &status) {
uint64_t result = 0;
int64_t max_int64 = ~((int64_t)1 << 63);
uint64_t max_int64 = ~((int64_t)1 << 63); // the maximum number of int64_t

// Check for empty string
if (str.empty()) {
Expand Down Expand Up @@ -636,7 +636,7 @@ class Token {
}

// Apply the exponent
for (size_t i = 0; i < exponent; ++i) {
for (int32_t i = 0; i < exponent; ++i) {
result *= 10;

if (result > max_int64) {
Expand All @@ -645,6 +645,11 @@ class Token {
}
}

if (result == 0) {
status = kUnitIdentifierSyntaxError;
return result; // add it for code consistency.
}

return result;
}

Expand Down Expand Up @@ -745,9 +750,7 @@ class Parser {
}

U_ASSERT(singleUnitOrConstant.isSingleUnit());
SingleUnitImpl singleUnit = singleUnitOrConstant.getSingleUnit();

bool added = result.appendSingleUnit(singleUnitOrConstant.singleUnit, status);
bool added = result.appendSingleUnit(singleUnitOrConstant.getSingleUnit(), status);
if (U_FAILURE(status)) {
return result;
}
Expand Down

0 comments on commit c2e68d5

Please sign in to comment.