Skip to content

Commit

Permalink
CLDR-17736 Update approximate widths (#3808)
Browse files Browse the repository at this point in the history
  • Loading branch information
macchiati committed Jun 17, 2024
1 parent e710b4c commit b62336e
Show file tree
Hide file tree
Showing 3 changed files with 6,072 additions and 4,441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public CheckCLDR handleCheck(
CheckStatus item =
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setMainType(errorOrIfBuildWarning())
.setSubtype(Subtype.abbreviatedDateFieldTooWide)
.setMessage(
"Abbreviated value \"{0}\" can't be longer than the corresponding wide value \"{1}\"",
Expand Down Expand Up @@ -468,7 +468,7 @@ && isTooMuchWiderThan(value, abbrValue)
CheckStatus item =
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setMainType(errorOrIfBuildWarning())
.setSubtype(Subtype.shortDateFieldInconsistentLength)
.setMessage(message, value, compareValue);
result.add(item);
Expand All @@ -481,7 +481,7 @@ && isTooMuchWiderThan(value, abbrValue)
CheckStatus item =
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setMainType(errorOrIfBuildWarning())
.setSubtype(Subtype.narrowDateFieldTooWide)
.setMessage(
"Narrow value \"{0}\" can't be longer than the corresponding abbreviated value \"{1}\"",
Expand All @@ -496,7 +496,7 @@ && isTooMuchWiderThan(value, abbrValue)
CheckStatus item =
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setMainType(errorOrIfBuildWarning())
.setSubtype(Subtype.abbreviatedDateFieldTooWide)
.setMessage(
"Abbreviated value \"{0}\" can't be longer than the corresponding wide value \"{1}\"",
Expand All @@ -510,7 +510,7 @@ && isTooMuchWiderThan(value, abbrValue)
result.add(
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setMainType(errorOrIfBuildWarning())
.setSubtype(Subtype.illegalDatePattern)
.setMessage(failure));
}
Expand Down Expand Up @@ -729,6 +729,10 @@ && isTooMuchWiderThan(value, abbrValue)
return this;
}

public org.unicode.cldr.test.CheckCLDR.CheckStatus.Type errorOrIfBuildWarning() {
return getPhase() != Phase.BUILD ? CheckStatus.errorType : CheckStatus.warningType;
}

private boolean isTooMuchWiderThan(String shortString, String longString) {
// We all 1/3 the width of the reference character as a "fudge factor" in determining the
// allowable width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,17 @@ private int getMetrics(int cp) {
// result = 1;
// adjusted.add(cp);
// }
if (result > 31 || result < -2) { // just to catch odd results
throw new IllegalArgumentException("Value too large " + result);
if (result > 31 || result < 0) { // just to catch odd results
System.out.println(
"Code point: "
+ Utility.hex(cp)
+ "; Value out of bounds (0..31)"
+ result);
if (result > 31) {
result = 31;
} else if (result < 0) {
result = 0;
}
}
return result;
}
Expand Down
Loading

0 comments on commit b62336e

Please sign in to comment.