diff --git a/.github/workflows/icu4c.yml b/.github/workflows/icu4c.yml index b8e54683af8d..d4e42be6e99b 100644 --- a/.github/workflows/icu4c.yml +++ b/.github/workflows/icu4c.yml @@ -314,8 +314,8 @@ jobs: run: | cd icu4c/source && ./runConfigureICU --enable-debug --disable-release Linux/clang && make -j -l4.5 check - # Clang Linux 16 with CPP20 and treat warnings as errors - clang16-cpp20-warning-as-errors: + # Clang Linux 18 with CPP20 and treat warnings as errors + clang18-cpp20-warning-as-errors: runs-on: ubuntu-latest strategy: fail-fast: false @@ -325,21 +325,19 @@ jobs: - '-std=c++20 -stdlib=libc++' steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Install Clang-16 + - name: Install Clang-18 run: | - curl -Ls https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-16 main' - sudo apt update - sudo apt install -qy clang-16 lld-16 libc++-16-dev libc++abi-16-dev - - name: Clang-16 build and Test + wget https://apt.llvm.org/llvm.sh + chmod u+x llvm.sh + sudo ./llvm.sh 18 all + - name: Clang-18 build and Test env: - CC: clang-16 - CXX: clang++-16 - # TODO: add '-Werror' after fixing ICU-22873 - CPPFLAGS: '-Wall -Wextra -Wctad-maybe-unsupported' + CC: clang-18 + CXX: clang++-18 + CPPFLAGS: '-Wall -Wextra -Wctad-maybe-unsupported -Werror' CXXFLAGS: ${{ matrix.flags }} run: | - cd icu4c/source && ./runConfigureICU --enable-debug --disable-release Linux/clang && make -j -l4.5 check + cd icu4c/source && ./runConfigureICU --enable-debug --disable-release Linux && make -j -l4.5 check # MacOS with clang macos-clang: diff --git a/docs/processes/release/tasks/versions.md b/docs/processes/release/tasks/versions.md index ecc85b15c65c..f64fc28c94bb 100644 --- a/docs/processes/release/tasks/versions.md +++ b/docs/processes/release/tasks/versions.md @@ -161,7 +161,12 @@ Changing the version for Java starting with ICU 74 requires a few steps: public static final String ICU_DATA_VERSION_PATH = "74b"; -2. When creating the final release of a major ICU version, +2. [icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java](https://github.com/unicode-org/icu/blob/main/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java) + + There is a public string named `ICU4C_VERSION` which should be updated accordingly. + 'public static final String ICU4C_VERSION="74.0.1";' + +3. When creating the final release of a major ICU version, or a point release (minor version update on a maintenance branch), update the Maven project version for ICU4J at the root (`icu4j/pom.xml`) and all of the submodules with the following Maven command. @@ -185,7 +190,7 @@ The command requires a version number string that follows the typical Java / Mav mvn versions:set -DnewVersion=74.1 -DgenerateBackupPoms=false ``` -3. Immediately after creating the final release of a major ICU version, update the value that represents just the major version number of the semantic version. To do this, update the value of the ICU `icu.major.version` property in the root Maven pom.xml file at `icu4j/pom.xml`. +4. Immediately after creating the final release of a major ICU version, update the value that represents just the major version number of the semantic version. To do this, update the value of the ICU `icu.major.version` property in the root Maven pom.xml file at `icu4j/pom.xml`. This can be done by running the following command: @@ -198,13 +203,17 @@ The command requires a version number string that follows the typical Java / Mav In other words, the above `versions:set-property` step should be executed at the same time `mvn versions:set -DnewVersion=74.0.1-SNAPSHOT` is executed. -4. Update the following variables in `icu4j/releases_tools/shared.sh` +5. Update the following variables in `icu4j/releases_tools/shared.sh` * `artifact_version` - The version used in the Maven `pom.xml` files. You can alternatively produce this value by running `mvn help:evaluate -Dexpression=project.version -q -DforceStdout`. * `github_rel_version` - The version used in the name of the GitHub downloadable artifacts. For example "73_2" or "74rc". * `api_report_version` - The major version of the new version. Change during RC BRS. * `api_report_prev_version` - The major version of the previous version. Change during RC BRS. +6. cldr-to-icu build tool has a dependency on the icu4j packages which needs to be updated in [`tools/cldr/cldr-to-icu/pom.xml`](https://github.com/unicode-org/icu/blob/main/tools/cldr/cldr-to-icu/pom.xml). Please update it to match the version that was updated in `icu4j/pom.xml` in the steps above. + + `74.0.1-SNAPSHOT` + #### Until ICU 73 (inclusive) diff --git a/docs/userguide/assets/gha_run_workflow.png b/docs/userguide/assets/gha_run_workflow.png index 3923cf4fe674..8b145be439ad 100644 Binary files a/docs/userguide/assets/gha_run_workflow.png and b/docs/userguide/assets/gha_run_workflow.png differ diff --git a/docs/userguide/assets/gha_tab.png b/docs/userguide/assets/gha_tab.png deleted file mode 100644 index c8750967e947..000000000000 Binary files a/docs/userguide/assets/gha_tab.png and /dev/null differ diff --git a/docs/userguide/dev/ci.md b/docs/userguide/dev/ci.md index 339a75f86fb3..378fbcba3fe9 100644 --- a/docs/userguide/dev/ci.md +++ b/docs/userguide/dev/ci.md @@ -128,8 +128,7 @@ which is a part of the release process. It may be desirable to run exhaustive tests manually on a PR for areas of code that are known to need the extra test coverage provided by exhaustive tests. To trigger exhaustive tests manually: -1. Go to your respective fork of the project (username/icu) if the PR is not already merged. Otherwise, go to https://github.com/unicode-org/icu +1. Go to your respective fork of the project (username/icu) if the PR is not already merged. Otherwise, go to https://github.com/unicode-org/icu (Note: your fork's default (main) branch should be in sync with upstream main branch for new actions to appear in your fork) 2. Select on the "Actions" tab from the top bar - ![GHA Actions](../assets/gha_tab.png) 3. On the left pane under All workflows, find "Exhaustive Tests for ICU" and click on run workflow, select branch and click 'Run workflow'. ![Run Workflow](../assets/gha_run_workflow.png) diff --git a/docs/userguide/format_parse/datetime/index.md b/docs/userguide/format_parse/datetime/index.md index e2d7806019fa..ea5c5e33bddd 100644 --- a/docs/userguide/format_parse/datetime/index.md +++ b/docs/userguide/format_parse/datetime/index.md @@ -205,7 +205,7 @@ Note that the examples may not reflect current CLDR data. | --- | --- | --- | --- | | `G` | era designator | `G`, `GG`, or `GGG`
`GGGG`
`GGGGG` | AD
Anno Domini
A | | `y` | year | `yy`
`y` or `yyyy` | 96
1996 | -| `Y` | year of "Week of Year" | `Y` | 1997 | +| `Y` | year in “Week of Year” based calendars in which the year transition occurs on a week boundary; may differ from calendar year ‘y’ near a year transition. This year designation is used with pattern character ‘w’ in the ISO 8601 year-week calendar, for example. | `Y` | 1997 | | `u` | extended year | `u` | 4601 | | `U` | cyclic year name, as in Chinese lunar calendar | `U` | 甲子 | | `r` | related Gregorian year | `r` | 1996 | diff --git a/icu4c/source/common/bmpset.cpp b/icu4c/source/common/bmpset.cpp index bab4cff41728..9b2a2967f0dd 100644 --- a/icu4c/source/common/bmpset.cpp +++ b/icu4c/source/common/bmpset.cpp @@ -293,14 +293,14 @@ BMPSet::contains(UChar32 c) const { if (static_cast(c) <= 0xff) { return latin1Contains[c]; } else if (static_cast(c) <= 0x7ff) { - return static_cast((table7FF[c & 0x3f] & (static_cast(1) << (c >> 6))) != 0); + return (table7FF[c & 0x3f] & (static_cast(1) << (c >> 6))) != 0; } else if (static_cast(c) < 0xd800 || (c >= 0xe000 && c <= 0xffff)) { int lead=c>>12; uint32_t twoBits=(bmpBlockBits[(c>>6)&0x3f]>>lead)&0x10001; if(twoBits<=1) { // All 64 code points with the same bits 15..6 // are either in the set or not. - return static_cast(twoBits); + return twoBits; } else { // Look up the code point in its 4k block of code points. return containsSlow(c, list4kStarts[lead], list4kStarts[lead+1]); diff --git a/icu4c/source/common/bmpset.h b/icu4c/source/common/bmpset.h index 440a7a81b087..00253f97c126 100644 --- a/icu4c/source/common/bmpset.h +++ b/icu4c/source/common/bmpset.h @@ -156,7 +156,7 @@ class BMPSet : public UMemory { }; inline UBool BMPSet::containsSlow(UChar32 c, int32_t lo, int32_t hi) const { - return static_cast(findCodePoint(c, lo, hi) & 1); + return findCodePoint(c, lo, hi) & 1; } U_NAMESPACE_END diff --git a/icu4c/source/common/normalizer2impl.h b/icu4c/source/common/normalizer2impl.h index 7bd733dee92e..5999190bae9b 100644 --- a/icu4c/source/common/normalizer2impl.h +++ b/icu4c/source/common/normalizer2impl.h @@ -364,7 +364,7 @@ class U_COMMON_API Normalizer2Impl : public UObject { // 0<=lead<=0xffff uint8_t bits=smallFCD[lead>>8]; if(bits==0) { return false; } - return static_cast((bits >> ((lead >> 5) & 7)) & 1); + return (bits >> ((lead >> 5) & 7)) & 1; } /** Returns the FCD value from the regular normalization data. */ uint16_t getFCD16FromNormData(UChar32 c) const; diff --git a/icu4c/source/common/patternprops.cpp b/icu4c/source/common/patternprops.cpp index 19998574cc55..782d3366f93d 100644 --- a/icu4c/source/common/patternprops.cpp +++ b/icu4c/source/common/patternprops.cpp @@ -120,12 +120,12 @@ PatternProps::isSyntax(UChar32 c) { if(c<0) { return false; } else if(c<=0xff) { - return static_cast(latin1[c] >> 1) & 1; + return (latin1[c] >> 1) & 1; } else if(c<0x2010) { return false; } else if(c<=0x3030) { uint32_t bits=syntax2000[index2000[(c-0x2000)>>5]]; - return static_cast((bits >> (c & 0x1f)) & 1); + return (bits >> (c & 0x1f)) & 1; } else if(0xfd3e<=c && c<=0xfe46) { return c<=0xfd3f || 0xfe45<=c; } else { @@ -138,12 +138,12 @@ PatternProps::isSyntaxOrWhiteSpace(UChar32 c) { if(c<0) { return false; } else if(c<=0xff) { - return static_cast(latin1[c] & 1); + return latin1[c] & 1; } else if(c<0x200e) { return false; } else if(c<=0x3030) { uint32_t bits=syntaxOrWhiteSpace2000[index2000[(c-0x2000)>>5]]; - return static_cast((bits >> (c & 0x1f)) & 1); + return (bits >> (c & 0x1f)) & 1; } else if(0xfd3e<=c && c<=0xfe46) { return c<=0xfd3f || 0xfe45<=c; } else { @@ -156,7 +156,7 @@ PatternProps::isWhiteSpace(UChar32 c) { if(c<0) { return false; } else if(c<=0xff) { - return static_cast(latin1[c] >> 2) & 1; + return (latin1[c] >> 2) & 1; } else if(0x200e<=c && c<=0x2029) { return c<=0x200f || 0x2028<=c; } else { diff --git a/icu4c/source/common/propsvec.cpp b/icu4c/source/common/propsvec.cpp index 11ef8df575b6..64997313f9e3 100644 --- a/icu4c/source/common/propsvec.cpp +++ b/icu4c/source/common/propsvec.cpp @@ -194,8 +194,8 @@ upvec_setValue(UPropsVectors *pv, * input range (only possible for the first and last rows) * and if their value differs from the input value. */ - splitFirstRow= (UBool)(start!=(UChar32)firstRow[0] && value!=(firstRow[column]&mask)); - splitLastRow= (UBool)(limit!=(UChar32)lastRow[1] && value!=(lastRow[column]&mask)); + splitFirstRow = start != static_cast(firstRow[0]) && value != (firstRow[column] & mask); + splitLastRow = limit != static_cast(lastRow[1]) && value != (lastRow[column] & mask); /* split first/last rows if necessary */ if(splitFirstRow || splitLastRow) { diff --git a/icu4c/source/common/punycode.cpp b/icu4c/source/common/punycode.cpp index 742d48de18b1..aa02298c5e6d 100644 --- a/icu4c/source/common/punycode.cpp +++ b/icu4c/source/common/punycode.cpp @@ -353,10 +353,10 @@ u_strToPunycode(const char16_t *src, int32_t srcLength, } if(destLength gInf.i64); + return (convertedNumber.i64 & U_INT64_MAX) > gInf.i64; #elif U_PLATFORM == U_PF_OS390 uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, @@ -368,7 +368,7 @@ uprv_isInfinite(double number) BitPatternConversion convertedNumber; convertedNumber.d64 = number; /* Infinity is exactly 0x7FF0000000000000U. */ - return (UBool)((convertedNumber.i64 & U_INT64_MAX) == gInf.i64); + return (convertedNumber.i64 & U_INT64_MAX) == gInf.i64; #elif U_PLATFORM == U_PF_OS390 uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, sizeof(uint32_t)); @@ -389,7 +389,7 @@ U_CAPI UBool U_EXPORT2 uprv_isPositiveInfinity(double number) { #if IEEE_754 || U_PLATFORM == U_PF_OS390 - return (UBool)(number > 0 && uprv_isInfinite(number)); + return number > 0 && uprv_isInfinite(number); #else return uprv_isInfinite(number); #endif @@ -399,7 +399,7 @@ U_CAPI UBool U_EXPORT2 uprv_isNegativeInfinity(double number) { #if IEEE_754 || U_PLATFORM == U_PF_OS390 - return (UBool)(number < 0 && uprv_isInfinite(number)); + return number < 0 && uprv_isInfinite(number); #else uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, @@ -744,11 +744,11 @@ static UBool isValidOlsonID(const char *id) { The timezone is sometimes set to "CST-7CDT", "CST6CDT5,J129,J131/19:30", "GRNLNDST3GRNLNDDT" or similar, so we cannot use it. The rest of the time it could be an Olson ID. George */ - return static_cast(id[idx] == 0 + return id[idx] == 0 || uprv_strcmp(id, "PST8PDT") == 0 || uprv_strcmp(id, "MST7MDT") == 0 || uprv_strcmp(id, "CST6CDT") == 0 - || uprv_strcmp(id, "EST5EDT") == 0); + || uprv_strcmp(id, "EST5EDT") == 0; } /* On some Unix-like OS, 'posix' subdirectory in diff --git a/icu4c/source/common/ubidi.cpp b/icu4c/source/common/ubidi.cpp index bcf4d2e36507..400e049d781a 100644 --- a/icu4c/source/common/ubidi.cpp +++ b/icu4c/source/common/ubidi.cpp @@ -304,7 +304,7 @@ ubidi_setReorderingMode(UBiDi *pBiDi, UBiDiReorderingMode reorderingMode) UPRV_N if ((pBiDi!=nullptr) && (reorderingMode >= UBIDI_REORDER_DEFAULT) && (reorderingMode < UBIDI_REORDER_COUNT)) { pBiDi->reorderingMode = reorderingMode; - pBiDi->isInverse = (UBool)(reorderingMode == UBIDI_REORDER_INVERSE_NUMBERS_AS_L); + pBiDi->isInverse = reorderingMode == UBIDI_REORDER_INVERSE_NUMBERS_AS_L; } } diff --git a/icu4c/source/common/ubidi_props.cpp b/icu4c/source/common/ubidi_props.cpp index 80044cca5413..1ac4ab12a2c3 100644 --- a/icu4c/source/common/ubidi_props.cpp +++ b/icu4c/source/common/ubidi_props.cpp @@ -139,7 +139,7 @@ ubidi_getClass(UChar32 c) { U_CFUNC UBool ubidi_isMirrored(UChar32 c) { uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c); - return (UBool)UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT); + return UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT); } static UChar32 @@ -183,13 +183,13 @@ ubidi_getMirror(UChar32 c) { U_CFUNC UBool ubidi_isBidiControl(UChar32 c) { uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c); - return (UBool)UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT); + return UBIDI_GET_FLAG(props, UBIDI_BIDI_CONTROL_SHIFT); } U_CFUNC UBool ubidi_isJoinControl(UChar32 c) { uint16_t props=UTRIE2_GET16(&ubidi_props_singleton.trie, c); - return (UBool)UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT); + return UBIDI_GET_FLAG(props, UBIDI_JOIN_CONTROL_SHIFT); } U_CFUNC UJoiningType diff --git a/icu4c/source/common/ucase.cpp b/icu4c/source/common/ucase.cpp index 40b43cd89275..5a2feaee840b 100644 --- a/icu4c/source/common/ucase.cpp +++ b/icu4c/source/common/ucase.cpp @@ -696,17 +696,17 @@ getDotType(UChar32 c) { U_CAPI UBool U_EXPORT2 ucase_isSoftDotted(UChar32 c) { - return (UBool)(getDotType(c)==UCASE_SOFT_DOTTED); + return getDotType(c)==UCASE_SOFT_DOTTED; } U_CAPI UBool U_EXPORT2 ucase_isCaseSensitive(UChar32 c) { uint16_t props=UTRIE2_GET16(&ucase_props_singleton.trie, c); if(!UCASE_HAS_EXCEPTION(props)) { - return (UBool)((props&UCASE_SENSITIVE)!=0); + return (props&UCASE_SENSITIVE)!=0; } else { const uint16_t *pe=GET_EXCEPTIONS(&ucase_props_singleton, props); - return (UBool)((*pe&UCASE_EXC_SENSITIVE)!=0); + return (*pe&UCASE_EXC_SENSITIVE)!=0; } } @@ -1623,12 +1623,12 @@ ucase_toFullFolding(UChar32 c, U_CAPI UBool U_EXPORT2 u_isULowercase(UChar32 c) { - return (UBool)(UCASE_LOWER==ucase_getType(c)); + return UCASE_LOWER==ucase_getType(c); } U_CAPI UBool U_EXPORT2 u_isUUppercase(UChar32 c) { - return (UBool)(UCASE_UPPER==ucase_getType(c)); + return UCASE_UPPER==ucase_getType(c); } /* Transforms the Unicode character to its lower case equivalent.*/ diff --git a/icu4c/source/common/uchar.cpp b/icu4c/source/common/uchar.cpp index f22d861c96e9..3b2ae8c8af5d 100644 --- a/icu4c/source/common/uchar.cpp +++ b/icu4c/source/common/uchar.cpp @@ -91,7 +91,7 @@ U_CAPI UBool U_EXPORT2 u_islower(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_LOWERCASE_LETTER); + return GET_CATEGORY(props)==U_LOWERCASE_LETTER; } /* Checks if ch is an upper case letter.*/ @@ -99,7 +99,7 @@ U_CAPI UBool U_EXPORT2 u_isupper(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_UPPERCASE_LETTER); + return GET_CATEGORY(props)==U_UPPERCASE_LETTER; } /* Checks if ch is a title case letter; usually upper case letters.*/ @@ -107,7 +107,7 @@ U_CAPI UBool U_EXPORT2 u_istitle(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_TITLECASE_LETTER); + return GET_CATEGORY(props)==U_TITLECASE_LETTER; } /* Checks if ch is a decimal digit. */ @@ -115,7 +115,7 @@ U_CAPI UBool U_EXPORT2 u_isdigit(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER); + return GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER; } U_CAPI UBool U_EXPORT2 @@ -131,7 +131,7 @@ u_isxdigit(UChar32 c) { } GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER); + return GET_CATEGORY(props)==U_DECIMAL_DIGIT_NUMBER; } /* Checks if the Unicode character is a letter.*/ @@ -139,7 +139,7 @@ U_CAPI UBool U_EXPORT2 u_isalpha(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_L_MASK)!=0); + return (CAT_MASK(props)&U_GC_L_MASK)!=0; } U_CAPI UBool U_EXPORT2 @@ -152,7 +152,7 @@ U_CAPI UBool U_EXPORT2 u_isalnum(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_ND_MASK))!=0); + return (CAT_MASK(props)&(U_GC_L_MASK|U_GC_ND_MASK))!=0; } /** @@ -161,7 +161,7 @@ u_isalnum(UChar32 c) { */ U_CFUNC UBool u_isalnumPOSIX(UChar32 c) { - return (UBool)(u_isUAlphabetic(c) || u_isdigit(c)); + return u_isUAlphabetic(c) || u_isdigit(c); } /* Checks if ch is a unicode character with assigned character type.*/ @@ -169,7 +169,7 @@ U_CAPI UBool U_EXPORT2 u_isdefined(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)!=0); + return GET_CATEGORY(props)!=0; } /* Checks if the Unicode character is a base form character that can take a diacritic.*/ @@ -177,7 +177,7 @@ U_CAPI UBool U_EXPORT2 u_isbase(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_N_MASK|U_GC_MC_MASK|U_GC_ME_MASK))!=0); + return (CAT_MASK(props)&(U_GC_L_MASK|U_GC_N_MASK|U_GC_MC_MASK|U_GC_ME_MASK))!=0; } /* Checks if the Unicode character is a control character.*/ @@ -185,7 +185,7 @@ U_CAPI UBool U_EXPORT2 u_iscntrl(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_CC_MASK|U_GC_CF_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK))!=0); + return (CAT_MASK(props)&(U_GC_CC_MASK|U_GC_CF_MASK|U_GC_ZL_MASK|U_GC_ZP_MASK))!=0; } U_CAPI UBool U_EXPORT2 @@ -206,14 +206,14 @@ U_CAPI UBool U_EXPORT2 u_isspace(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_Z_MASK)!=0 || IS_THAT_CONTROL_SPACE(c)); + return (CAT_MASK(props)&U_GC_Z_MASK)!=0 || IS_THAT_CONTROL_SPACE(c); } U_CAPI UBool U_EXPORT2 u_isJavaSpaceChar(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_Z_MASK)!=0); + return (CAT_MASK(props)&U_GC_Z_MASK)!=0; } /* Checks if the Unicode character is a whitespace character.*/ @@ -221,11 +221,9 @@ U_CAPI UBool U_EXPORT2 u_isWhitespace(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)( - ((CAT_MASK(props)&U_GC_Z_MASK)!=0 && - c!=NBSP && c!=FIGURESP && c!=NNBSP) || /* exclude no-break spaces */ - IS_THAT_ASCII_CONTROL_SPACE(c) - ); + return ((CAT_MASK(props)&U_GC_Z_MASK)!=0 && + c!=NBSP && c!=FIGURESP && c!=NNBSP) || /* exclude no-break spaces */ + IS_THAT_ASCII_CONTROL_SPACE(c); } U_CAPI UBool U_EXPORT2 @@ -236,7 +234,7 @@ u_isblank(UChar32 c) { /* Zs */ uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_SPACE_SEPARATOR); + return GET_CATEGORY(props)==U_SPACE_SEPARATOR; } } @@ -251,7 +249,7 @@ u_isprint(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* comparing ==0 returns false for the categories mentioned */ - return (UBool)((CAT_MASK(props)&U_GC_C_MASK)==0); + return (CAT_MASK(props)&U_GC_C_MASK)==0; } /** @@ -267,7 +265,7 @@ u_isprintPOSIX(UChar32 c) { * The only cntrl character in graph+blank is TAB (in blank). * Here we implement (blank-TAB)=Zs instead of calling u_isblank(). */ - return (UBool)((GET_CATEGORY(props)==U_SPACE_SEPARATOR) || u_isgraphPOSIX(c)); + return (GET_CATEGORY(props)==U_SPACE_SEPARATOR) || u_isgraphPOSIX(c); } U_CAPI UBool U_EXPORT2 @@ -275,9 +273,9 @@ u_isgraph(UChar32 c) { uint32_t props; GET_PROPS(c, props); /* comparing ==0 returns false for the categories mentioned */ - return (UBool)((CAT_MASK(props)& - (U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) - ==0); + return (CAT_MASK(props)& + (U_GC_CC_MASK|U_GC_CF_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) + ==0; } /** @@ -293,16 +291,16 @@ u_isgraphPOSIX(UChar32 c) { GET_PROPS(c, props); /* \p{space}\p{gc=Control} == \p{gc=Z}\p{Control} */ /* comparing ==0 returns false for the categories mentioned */ - return (UBool)((CAT_MASK(props)& - (U_GC_CC_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) - ==0); + return (CAT_MASK(props)& + (U_GC_CC_MASK|U_GC_CS_MASK|U_GC_CN_MASK|U_GC_Z_MASK)) + ==0; } U_CAPI UBool U_EXPORT2 u_ispunct(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&U_GC_P_MASK)!=0); + return (CAT_MASK(props)&U_GC_P_MASK)!=0; } /*Checks if the Unicode character can be ignorable in a Java or Unicode identifier.*/ @@ -313,7 +311,7 @@ u_isIDIgnorable(UChar32 c) { } else { uint32_t props; GET_PROPS(c, props); - return (UBool)(GET_CATEGORY(props)==U_FORMAT_CHAR); + return GET_CATEGORY(props)==U_FORMAT_CHAR; } } @@ -322,7 +320,7 @@ U_CAPI UBool U_EXPORT2 u_isJavaIDStart(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)((CAT_MASK(props)&(U_GC_L_MASK|U_GC_SC_MASK|U_GC_PC_MASK))!=0); + return (CAT_MASK(props)&(U_GC_L_MASK|U_GC_SC_MASK|U_GC_PC_MASK))!=0; } /*Checks if the Unicode character can be a Java identifier part other than starting the @@ -332,14 +330,13 @@ U_CAPI UBool U_EXPORT2 u_isJavaIDPart(UChar32 c) { uint32_t props; GET_PROPS(c, props); - return (UBool)( - (CAT_MASK(props)& + return (CAT_MASK(props)& (U_GC_ND_MASK|U_GC_NL_MASK| U_GC_L_MASK| U_GC_SC_MASK|U_GC_PC_MASK| U_GC_MC_MASK|U_GC_MN_MASK) )!=0 || - u_isIDIgnorable(c)); + u_isIDIgnorable(c); } U_CAPI int32_t U_EXPORT2 diff --git a/icu4c/source/common/uchriter.cpp b/icu4c/source/common/uchriter.cpp index b3402989011b..903eb46c3b34 100644 --- a/icu4c/source/common/uchriter.cpp +++ b/icu4c/source/common/uchriter.cpp @@ -172,7 +172,7 @@ UCharCharacterIterator::nextPostInc() { UBool UCharCharacterIterator::hasNext() { - return static_cast(pos < end); + return pos < end; } char16_t @@ -186,7 +186,7 @@ UCharCharacterIterator::previous() { UBool UCharCharacterIterator::hasPrevious() { - return static_cast(pos > begin); + return pos > begin; } UChar32 diff --git a/icu4c/source/common/ucnv.cpp b/icu4c/source/common/ucnv.cpp index 2ea88cca691a..c66200b79323 100644 --- a/icu4c/source/common/ucnv.cpp +++ b/icu4c/source/common/ucnv.cpp @@ -2684,7 +2684,7 @@ ucnv_fixFileSeparator(const UConverter *cnv, U_CAPI UBool U_EXPORT2 ucnv_isAmbiguous(const UConverter *cnv) { - return (UBool)(ucnv_getAmbiguous(cnv)!=nullptr); + return ucnv_getAmbiguous(cnv)!=nullptr; } U_CAPI void U_EXPORT2 diff --git a/icu4c/source/common/ucnv_bld.cpp b/icu4c/source/common/ucnv_bld.cpp index eb7ae1eaa9da..1e768ae22411 100644 --- a/icu4c/source/common/ucnv_bld.cpp +++ b/icu4c/source/common/ucnv_bld.cpp @@ -270,7 +270,7 @@ static UBool U_CALLCONV isCnvAcceptable(void * /*context*/, const char * /*type*/, const char * /*name*/, const UDataInfo *pInfo) { - return static_cast( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -279,7 +279,7 @@ isCnvAcceptable(void * /*context*/, pInfo->dataFormat[1]==0x6e && pInfo->dataFormat[2]==0x76 && pInfo->dataFormat[3]==0x74 && - pInfo->formatVersion[0]==6); /* Everything will be version 6 */ + pInfo->formatVersion[0]==6; /* Everything will be version 6 */ } /** @@ -1440,7 +1440,7 @@ ucnv_swap(const UDataSwapper *ds, MBCS_OPT_UNKNOWN_INCOMPATIBLE_MASK)==0 ) { mbcsHeaderLength=mbcsHeader.options&MBCS_OPT_LENGTH_MASK; - noFromU=(UBool)((mbcsHeader.options&MBCS_OPT_NO_FROM_U)!=0); + noFromU = (mbcsHeader.options & MBCS_OPT_NO_FROM_U) != 0; } else { udata_printError(ds, "ucnv_swap(): unsupported _MBCSHeader.version %d.%d\n", inMBCSHeader->version[0], inMBCSHeader->version[1]); diff --git a/icu4c/source/common/ucnv_io.cpp b/icu4c/source/common/ucnv_io.cpp index abd19022ebb3..7207de397eb1 100644 --- a/icu4c/source/common/ucnv_io.cpp +++ b/icu4c/source/common/ucnv_io.cpp @@ -205,7 +205,7 @@ static UBool U_CALLCONV isAcceptable(void * /*context*/, const char * /*type*/, const char * /*name*/, const UDataInfo *pInfo) { - return static_cast( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -213,7 +213,7 @@ isAcceptable(void * /*context*/, pInfo->dataFormat[1]==0x76 && pInfo->dataFormat[2]==0x41 && pInfo->dataFormat[3]==0x6c && - pInfo->formatVersion[0]==3); + pInfo->formatVersion[0]==3; } static UBool U_CALLCONV ucnv_io_cleanup() @@ -321,7 +321,7 @@ isAlias(const char *alias, UErrorCode *pErrorCode) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return false; } - return static_cast(*alias != 0); + return *alias != 0; } static uint32_t getTagNumber(const char *tagname) { diff --git a/icu4c/source/common/ucnv_u8.cpp b/icu4c/source/common/ucnv_u8.cpp index 18c57c61482a..cca6e603ae32 100644 --- a/icu4c/source/common/ucnv_u8.cpp +++ b/icu4c/source/common/ucnv_u8.cpp @@ -58,7 +58,7 @@ static UBool hasCESU8Data(const UConverter *cnv) #if UCONFIG_ONLY_HTML_CONVERSION return false; #else - return static_cast(cnv->sharedData == &_CESU8Data); + return cnv->sharedData == &_CESU8Data; #endif } U_CDECL_BEGIN diff --git a/icu4c/source/common/ucnvhz.cpp b/icu4c/source/common/ucnvhz.cpp index cfef63272cb6..aea5da65c1f4 100644 --- a/icu4c/source/common/ucnvhz.cpp +++ b/icu4c/source/common/ucnvhz.cpp @@ -389,7 +389,7 @@ UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, } } if (targetUniChar != missingCharMarker){ - myConverterData->isTargetUCharDBCS = isTargetUCharDBCS = (UBool)(targetUniChar>0x00FF); + myConverterData->isTargetUCharDBCS = isTargetUCharDBCS = targetUniChar > 0x00FF; if(oldIsTargetUCharDBCS != isTargetUCharDBCS || !myConverterData->isEscapeAppended ){ /*Shifting from a double byte to single byte mode*/ if(!isTargetUCharDBCS){ diff --git a/icu4c/source/common/ucnvisci.cpp b/icu4c/source/common/ucnvisci.cpp index 9f3a8125e28d..c5f5832dcfcc 100644 --- a/icu4c/source/common/ucnvisci.cpp +++ b/icu4c/source/common/ucnvisci.cpp @@ -174,7 +174,7 @@ isPNJConsonant(UChar32 c) { if (c < 0xa00 || 0xa50 <= c) { return false; } else { - return static_cast(pnjMap[c - 0xa00] & 1); + return pnjMap[c - 0xa00] & 1; } } @@ -183,7 +183,7 @@ isPNJBindiTippi(UChar32 c) { if (c < 0xa00 || 0xa50 <= c) { return false; } else { - return static_cast(pnjMap[c - 0xa00] >> 1); + return pnjMap[c - 0xa00] >> 1; } } U_CDECL_BEGIN diff --git a/icu4c/source/common/ucnvmbcs.cpp b/icu4c/source/common/ucnvmbcs.cpp index 6b4d1491a2a6..f5507043bf35 100644 --- a/icu4c/source/common/ucnvmbcs.cpp +++ b/icu4c/source/common/ucnvmbcs.cpp @@ -924,7 +924,7 @@ ucnv_MBCSGetFilteredUnicodeSetForUnicode(const UConverterSharedData *sharedData, bytes=mbcsTable->fromUnicodeBytes; - useFallback=(UBool)(which==UCNV_ROUNDTRIP_AND_FALLBACK_SET); + useFallback = which == UCNV_ROUNDTRIP_AND_FALLBACK_SET; switch(mbcsTable->outputType) { case MBCS_OUTPUT_3: @@ -2823,7 +2823,7 @@ ucnv_MBCSToUnicodeWithOffsets(UConverterToUnicodeArgs *pArgs, * - If any of the non-initial bytes could be the start of a character, * we stop the illegal sequence before the first one of those. */ - UBool isDBCSOnly=(UBool)(cnv->sharedData->mbcs.dbcsOnlyState!=0); + UBool isDBCSOnly = cnv->sharedData->mbcs.dbcsOnlyState != 0; int8_t i; for(i=1; imbcs.stateTable[0][(uint8_t)byte]); + return MBCS_ENTRY_IS_TRANSITION(sharedData->mbcs.stateTable[0][(uint8_t)byte]); } static void U_CALLCONV diff --git a/icu4c/source/common/ucnvscsu.cpp b/icu4c/source/common/ucnvscsu.cpp index 6dd1654636a1..5412136a346a 100644 --- a/icu4c/source/common/ucnvscsu.cpp +++ b/icu4c/source/common/ucnvscsu.cpp @@ -893,9 +893,9 @@ getWindow(const uint32_t offsets[8], uint32_t c) { /* is the character in the dynamic window starting at the offset, or in the direct-encoded range? */ static UBool isInOffsetWindowOrDirect(uint32_t offset, uint32_t c) { - return static_cast(c<=offset+0x7f && + return c<=offset+0x7f && (c>=offset || (c<=0x7f && - (c>=0x20 || (1UL<=0x20 || (1UL<( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -188,7 +188,7 @@ isAcceptable(void * /*context*/, pInfo->dataFormat[1]==0x6e && pInfo->dataFormat[2]==0x61 && pInfo->dataFormat[3]==0x6d && - pInfo->formatVersion[0]==1); + pInfo->formatVersion[0]==1; } static void U_CALLCONV @@ -415,7 +415,7 @@ compareName(UCharNames *names, } /* complete match? */ - return static_cast(*otherName == 0); + return *otherName == 0; } static uint8_t getCharCat(UChar32 cp) { diff --git a/icu4c/source/common/unicode/uniset.h b/icu4c/source/common/unicode/uniset.h index c45f93d19674..d070fd631a22 100644 --- a/icu4c/source/common/unicode/uniset.h +++ b/icu4c/source/common/unicode/uniset.h @@ -1843,7 +1843,7 @@ inline bool UnicodeSet::operator!=(const UnicodeSet& o) const { } inline UBool UnicodeSet::isFrozen() const { - return static_cast(bmpSet != nullptr || stringSpan != nullptr); + return bmpSet != nullptr || stringSpan != nullptr; } inline UBool UnicodeSet::containsSome(UChar32 start, UChar32 end) const { @@ -1859,7 +1859,7 @@ inline UBool UnicodeSet::containsSome(const UnicodeString& s) const { } inline UBool UnicodeSet::isBogus() const { - return static_cast(fFlags & kIsBogus); + return fFlags & kIsBogus; } inline UnicodeSet *UnicodeSet::fromUSet(USet *uset) { diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index a65d467c07dc..39d789fd6ef7 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -3033,7 +3033,7 @@ class U_COMMON_API UnicodeString : public Replaceable * @draft ICU 76 */ inline operator std::u16string_view() const { - return { getBuffer(), (std::u16string_view::size_type)length() }; + return {getBuffer(), static_cast(length())}; } #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) @@ -4227,18 +4227,18 @@ UnicodeString::hashCode() const inline UBool UnicodeString::isBogus() const -{ return static_cast(fUnion.fFields.fLengthAndFlags & kIsBogus); } +{ return fUnion.fFields.fLengthAndFlags & kIsBogus; } inline UBool UnicodeString::isWritable() const -{ return static_cast(!(fUnion.fFields.fLengthAndFlags & (kOpenGetBuffer | kIsBogus))); } +{ return !(fUnion.fFields.fLengthAndFlags & (kOpenGetBuffer | kIsBogus)); } inline UBool UnicodeString::isBufferWritable() const { - return static_cast( + return !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) && - (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1)); + (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1); } inline const char16_t * diff --git a/icu4c/source/common/unicode/uset.h b/icu4c/source/common/unicode/uset.h index cca2b0278a80..c8f9b5592df2 100644 --- a/icu4c/source/common/unicode/uset.h +++ b/icu4c/source/common/unicode/uset.h @@ -1657,7 +1657,7 @@ class USetStringIterator { int32_t length; const UChar *uchars = uset_getString(uset, index, &length); // assert uchars != nullptr; - return { ConstChar16Ptr(uchars), (uint32_t)length }; + return {ConstChar16Ptr(uchars), static_cast(length)}; } return {}; } diff --git a/icu4c/source/common/unicode/utypes.h b/icu4c/source/common/unicode/utypes.h index fcec29546af7..87fa5ddf7e87 100644 --- a/icu4c/source/common/unicode/utypes.h +++ b/icu4c/source/common/unicode/utypes.h @@ -729,13 +729,13 @@ typedef enum UErrorCode { * @stable ICU 2.0 */ static - inline UBool U_SUCCESS(UErrorCode code) { return static_cast(code <= U_ZERO_ERROR); } + inline UBool U_SUCCESS(UErrorCode code) { return code <= U_ZERO_ERROR; } /** * Does the error code indicate a failure? * @stable ICU 2.0 */ static - inline UBool U_FAILURE(UErrorCode code) { return static_cast(code > U_ZERO_ERROR); } + inline UBool U_FAILURE(UErrorCode code) { return code > U_ZERO_ERROR; } #else /** * Does the error code indicate success? diff --git a/icu4c/source/common/unicode/uvernum.h b/icu4c/source/common/unicode/uvernum.h index bed63586c93f..a3cb882623be 100644 --- a/icu4c/source/common/unicode/uvernum.h +++ b/icu4c/source/common/unicode/uvernum.h @@ -59,13 +59,13 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.6 */ -#define U_ICU_VERSION_MINOR_NUM 0 +#define U_ICU_VERSION_MINOR_NUM 1 /** The current ICU patchlevel version as an integer. * This value will change in the subsequent releases of ICU * @stable ICU 2.4 */ -#define U_ICU_VERSION_PATCHLEVEL_NUM 1 +#define U_ICU_VERSION_PATCHLEVEL_NUM 0 /** The current ICU build level version as an integer. * This value is for use by ICU clients. It defaults to 0. @@ -132,7 +132,7 @@ * This value will change in the subsequent releases of ICU * @stable ICU 2.4 */ -#define U_ICU_VERSION "76.0.1" +#define U_ICU_VERSION "76.1" /** * The current ICU library major version number as a string, for library name suffixes. @@ -151,7 +151,7 @@ /** Data version in ICU4C. * @internal ICU 4.4 Internal Use Only **/ -#define U_ICU_DATA_VERSION "76.0.1" +#define U_ICU_DATA_VERSION "76.1" #endif /* U_HIDE_INTERNAL_API */ /*=========================================================================== diff --git a/icu4c/source/common/uniset.cpp b/icu4c/source/common/uniset.cpp index ef78ce33b195..2d6610cb355d 100644 --- a/icu4c/source/common/uniset.cpp +++ b/icu4c/source/common/uniset.cpp @@ -355,7 +355,7 @@ UBool UnicodeSet::contains(UChar32 c) const { return false; } int32_t i = findCodePoint(c); - return static_cast(i & 1); // return true if odd + return i & 1; // return true if odd } /** @@ -460,7 +460,7 @@ UBool UnicodeSet::containsAll(const UnicodeSet& c) const { * @return true if the test condition is met */ UBool UnicodeSet::containsAll(const UnicodeString& s) const { - return static_cast(span(s.getBuffer(), s.length(), USET_SPAN_CONTAINED) == s.length()); + return span(s.getBuffer(), s.length(), USET_SPAN_CONTAINED) == s.length(); } /** @@ -505,7 +505,7 @@ UBool UnicodeSet::containsNone(const UnicodeSet& c) const { * @return true if the test condition is met */ UBool UnicodeSet::containsNone(const UnicodeString& s) const { - return static_cast(span(s.getBuffer(), s.length(), USET_SPAN_NOT_CONTAINED) == s.length()); + return span(s.getBuffer(), s.length(), USET_SPAN_NOT_CONTAINED) == s.length(); } /** diff --git a/icu4c/source/common/unisetspan.cpp b/icu4c/source/common/unisetspan.cpp index dc4e89e5ca4a..209f0a86b541 100644 --- a/icu4c/source/common/unisetspan.cpp +++ b/icu4c/source/common/unisetspan.cpp @@ -84,7 +84,7 @@ class OffsetList { // Only ever stack-allocated, does not need to inherit UMemo } UBool isEmpty() const { - return static_cast(length == 0); + return length == 0; } // Reduce all stored offsets by delta, used when the current position diff --git a/icu4c/source/common/unisetspan.h b/icu4c/source/common/unisetspan.h index ecf8a9b00ffc..482782ebf75e 100644 --- a/icu4c/source/common/unisetspan.h +++ b/icu4c/source/common/unisetspan.h @@ -141,11 +141,11 @@ class UnicodeSetStringSpan : public UMemory { }; UBool UnicodeSetStringSpan::needsStringSpanUTF16() { - return static_cast(maxLength16 != 0); + return maxLength16 != 0; } UBool UnicodeSetStringSpan::needsStringSpanUTF8() { - return static_cast(maxLength8 != 0); + return maxLength8 != 0; } UBool UnicodeSetStringSpan::contains(UChar32 c) const { diff --git a/icu4c/source/common/unistr.cpp b/icu4c/source/common/unistr.cpp index a9d5f81cb2f0..a720245772e6 100644 --- a/icu4c/source/common/unistr.cpp +++ b/icu4c/source/common/unistr.cpp @@ -125,7 +125,7 @@ U_COMMON_API UnicodeString U_EXPORT2 unistr_internalConcat(const UnicodeString &s1, std::u16string_view s2) { int32_t sumLengths; if (s2.length() > INT32_MAX || - uprv_add32_overflow(s1.length(), (int32_t)s2.length(), &sumLengths)) { + uprv_add32_overflow(s1.length(), static_cast(s2.length()), &sumLengths)) { UnicodeString bogus; bogus.setToBogus(); return bogus; @@ -301,7 +301,7 @@ UnicodeString::UnicodeString(const char *src, int32_t length, EInvariant) { UnicodeString UnicodeString::readOnlyAliasFromU16StringView(std::u16string_view text) { UnicodeString result; if (text.length() <= INT32_MAX) { - result.setTo(false, text.data(), (int32_t)text.length()); + result.setTo(false, text.data(), static_cast(text.length())); } else { result.setToBogus(); } @@ -1622,7 +1622,7 @@ UnicodeString::doReplace(int32_t start, int32_t length, std::u16string_view src) setToBogus(); return *this; } - return doReplace(start, length, src.data(), 0, (int32_t)src.length()); + return doReplace(start, length, src.data(), 0, static_cast(src.length())); } // Versions of doReplace() only for append() variants. @@ -1722,7 +1722,7 @@ UnicodeString::doAppend(std::u16string_view src) { setToBogus(); return *this; } - return doAppend(src.data(), 0, (int32_t)src.length()); + return doAppend(src.data(), 0, static_cast(src.length())); } /** diff --git a/icu4c/source/common/uprops.cpp b/icu4c/source/common/uprops.cpp index 36aaba698d05..0f80d742d657 100644 --- a/icu4c/source/common/uprops.cpp +++ b/icu4c/source/common/uprops.cpp @@ -171,7 +171,7 @@ static UBool defaultContains(const BinaryProperty &prop, UChar32 c, UProperty /* } static UBool caseBinaryPropertyContains(const BinaryProperty &/*prop*/, UChar32 c, UProperty which) { - return static_cast(ucase_hasBinaryProperty(c, which)); + return ucase_hasBinaryProperty(c, which); } static UBool isBidiControl(const BinaryProperty &/*prop*/, UChar32 c, UProperty /*which*/) { @@ -242,7 +242,7 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP if(c>=0) { /* single code point */ const char16_t *resultString; - return static_cast(ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT) >= 0); + return ucase_toFullFolding(c, &resultString, U_FOLD_CASE_DEFAULT) >= 0; } else { /* guess some large but stack-friendly capacity */ char16_t dest[2*UCASE_MAX_STRING_LENGTH]; @@ -250,9 +250,9 @@ static UBool changesWhenCasefolded(const BinaryProperty &/*prop*/, UChar32 c, UP destLength=u_strFoldCase(dest, UPRV_LENGTHOF(dest), nfd.getBuffer(), nfd.length(), U_FOLD_CASE_DEFAULT, &errorCode); - return static_cast(U_SUCCESS(errorCode) && + return U_SUCCESS(errorCode) && 0!=u_strCompare(nfd.getBuffer(), nfd.length(), - dest, destLength, false)); + dest, destLength, false); } } #endif diff --git a/icu4c/source/common/uresbund.cpp b/icu4c/source/common/uresbund.cpp index cfe2f4a4d20f..3a09cbf3bcaa 100644 --- a/icu4c/source/common/uresbund.cpp +++ b/icu4c/source/common/uresbund.cpp @@ -72,8 +72,7 @@ static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) { name2.pointer = b2->fName; path1.pointer = b1->fPath; path2.pointer = b2->fPath; - return static_cast(uhash_compareChars(name1, name2) && - uhash_compareChars(path1, path2)); + return uhash_compareChars(name1, name2) && uhash_compareChars(path1, path2); } @@ -1730,7 +1729,7 @@ U_CAPI UBool U_EXPORT2 ures_hasNext(const UResourceBundle *resB) { if(resB == nullptr) { return false; } - return (UBool)(resB->fIndex < resB->fSize-1); + return resB->fIndex < resB->fSize-1; } U_CAPI const char16_t* U_EXPORT2 ures_getNextString(UResourceBundle *resB, int32_t* len, const char ** key, UErrorCode *status) { diff --git a/icu4c/source/common/uresdata.cpp b/icu4c/source/common/uresdata.cpp index 896e4ed1d6f1..11faddf1ade9 100644 --- a/icu4c/source/common/uresdata.cpp +++ b/icu4c/source/common/uresdata.cpp @@ -140,7 +140,7 @@ isAcceptable(void *context, const char * /*type*/, const char * /*name*/, const UDataInfo *pInfo) { uprv_memcpy(context, pInfo->formatVersion, 4); - return static_cast( + return pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && @@ -149,7 +149,7 @@ isAcceptable(void *context, pInfo->dataFormat[1]==0x65 && pInfo->dataFormat[2]==0x73 && pInfo->dataFormat[3]==0x42 && - (1<=pInfo->formatVersion[0] && pInfo->formatVersion[0]<=3)); + (1<=pInfo->formatVersion[0] && pInfo->formatVersion[0]<=3); } /* semi-public functions ---------------------------------------------------- */ diff --git a/icu4c/source/common/uset.cpp b/icu4c/source/common/uset.cpp index 8712da8b07fe..29b8655ac965 100644 --- a/icu4c/source/common/uset.cpp +++ b/icu4c/source/common/uset.cpp @@ -496,7 +496,7 @@ uset_serializedContains(const USerializedSet* set, UChar32 c) { } else { hi += 1; } - return (UBool)(hi&1); + return hi&1; } else { /* find c in the supplementary part */ uint16_t high=(uint16_t)(c>>16), low=(uint16_t)c; @@ -521,7 +521,7 @@ uset_serializedContains(const USerializedSet* set, UChar32 c) { hi += 2; } /* count pairs of 16-bit units even per BMP and check if the number of pairs is odd */ - return (UBool)(((hi+(base<<1))&2)!=0); + return ((hi+(base<<1))&2)!=0; } } diff --git a/icu4c/source/common/ushape.cpp b/icu4c/source/common/ushape.cpp index 0843889d2dd4..00125635cb26 100644 --- a/icu4c/source/common/ushape.cpp +++ b/icu4c/source/common/ushape.cpp @@ -1709,13 +1709,13 @@ u_shapeArabic(const char16_t *source, int32_t sourceLength, case U_SHAPE_DIGITS_ALEN2AN_INIT_LR: _shapeToArabicDigitsWithContext(dest, destLength, digitBase, - (UBool)((options&U_SHAPE_TEXT_DIRECTION_MASK)==U_SHAPE_TEXT_DIRECTION_LOGICAL), + (options & U_SHAPE_TEXT_DIRECTION_MASK) == U_SHAPE_TEXT_DIRECTION_LOGICAL, false); break; case U_SHAPE_DIGITS_ALEN2AN_INIT_AL: _shapeToArabicDigitsWithContext(dest, destLength, digitBase, - (UBool)((options&U_SHAPE_TEXT_DIRECTION_MASK)==U_SHAPE_TEXT_DIRECTION_LOGICAL), + (options & U_SHAPE_TEXT_DIRECTION_MASK) == U_SHAPE_TEXT_DIRECTION_LOGICAL, true); break; default: diff --git a/icu4c/source/common/usprep.cpp b/icu4c/source/common/usprep.cpp index 82dd7a4ca0fd..477b8f2309db 100644 --- a/icu4c/source/common/usprep.cpp +++ b/icu4c/source/common/usprep.cpp @@ -126,8 +126,7 @@ compareEntries(const UHashTok p1, const UHashTok p2) { name2.pointer = b2->name; path1.pointer = b1->path; path2.pointer = b2->path; - return ((UBool)(uhash_compareChars(name1, name2) & - uhash_compareChars(path1, path2))); + return uhash_compareChars(name1, name2) & uhash_compareChars(path1, path2); } static void diff --git a/icu4c/source/common/ustr_wcs.cpp b/icu4c/source/common/ustr_wcs.cpp index efbbbc2f1878..8ce0855226d6 100644 --- a/icu4c/source/common/ustr_wcs.cpp +++ b/icu4c/source/common/ustr_wcs.cpp @@ -57,7 +57,7 @@ u_growAnyBufferFromStatic(void *context, } *pBuffer=newBuffer; - return (UBool)(newBuffer!=nullptr); + return newBuffer!=nullptr; } /* helper function */ diff --git a/icu4c/source/common/utext.cpp b/icu4c/source/common/utext.cpp index 4b09c3714f17..0a4248c4e459 100644 --- a/icu4c/source/common/utext.cpp +++ b/icu4c/source/common/utext.cpp @@ -1937,7 +1937,7 @@ repTextReplace(UText *ut, } // Do the actual replace operation using methods of the Replaceable class - UnicodeString replStr((UBool)(length<0), src, length); // read-only alias + UnicodeString replStr(length < 0, src, length); // read-only alias rep->handleReplaceBetween(start32, limit32, replStr); int32_t newLength = rep->length(); int32_t lengthDelta = newLength - oldLength; diff --git a/icu4c/source/common/utrie.cpp b/icu4c/source/common/utrie.cpp index 88c01a53d2df..6a2cf1a9d995 100644 --- a/icu4c/source/common/utrie.cpp +++ b/icu4c/source/common/utrie.cpp @@ -40,7 +40,7 @@ equal_uint32(const uint32_t *s, const uint32_t *t, int32_t length) { ++t; --length; } - return static_cast(length == 0); + return length == 0; } /* Building a trie ----------------------------------------------------------*/ @@ -68,7 +68,7 @@ utrie_open(UNewTrie *fillIn, } } uprv_memset(trie, 0, sizeof(UNewTrie)); - trie->isAllocated= (UBool)(fillIn==nullptr); + trie->isAllocated = fillIn == nullptr; if(aliasData!=nullptr) { trie->data=aliasData; @@ -250,7 +250,7 @@ utrie_get32(UNewTrie *trie, UChar32 c, UBool *pInBlockZero) { block=trie->index[c>>UTRIE_SHIFT]; if(pInBlockZero!=nullptr) { - *pInBlockZero= (UBool)(block==0); + *pInBlockZero = block == 0; } return trie->data[ABS(block)+(c&UTRIE_MASK)]; @@ -884,7 +884,7 @@ utrie_unserialize(UTrie *trie, const void *data, int32_t length, UErrorCode *pEr *pErrorCode=U_INVALID_FORMAT_ERROR; return -1; } - trie->isLatin1Linear= (UBool)((options&UTRIE_OPTIONS_LATIN1_IS_LINEAR)!=0); + trie->isLatin1Linear = (options & UTRIE_OPTIONS_LATIN1_IS_LINEAR) != 0; /* get the length values */ trie->indexLength=header->indexLength; diff --git a/icu4c/source/common/utrie2.cpp b/icu4c/source/common/utrie2.cpp index f8ed7cfc70fe..35be698fbb5d 100644 --- a/icu4c/source/common/utrie2.cpp +++ b/icu4c/source/common/utrie2.cpp @@ -389,7 +389,7 @@ utrie2_close(UTrie2 *trie) { U_CAPI UBool U_EXPORT2 utrie2_isFrozen(const UTrie2 *trie) { - return (UBool)(trie->newTrie==nullptr); + return trie->newTrie==nullptr; } U_CAPI int32_t U_EXPORT2 diff --git a/icu4c/source/common/utrie2_builder.cpp b/icu4c/source/common/utrie2_builder.cpp index 92e9fd733c4f..4bd49c7adfa4 100644 --- a/icu4c/source/common/utrie2_builder.cpp +++ b/icu4c/source/common/utrie2_builder.cpp @@ -506,7 +506,7 @@ isInNullBlock(UNewTrie2 *trie, UChar32 c, UBool forLSCP) { ((c>>UTRIE2_SHIFT_2)&UTRIE2_INDEX_2_MASK); } block=trie->index2[i2]; - return static_cast(block == trie->dataNullOffset); + return block == trie->dataNullOffset; } static int32_t @@ -603,7 +603,7 @@ releaseDataBlock(UNewTrie2 *trie, int32_t block) { static inline UBool isWritableBlock(UNewTrie2 *trie, int32_t block) { - return static_cast(block != trie->dataNullOffset && 1 == trie->map[block >> UTRIE2_SHIFT_2]); + return block != trie->dataNullOffset && 1 == trie->map[block >> UTRIE2_SHIFT_2]; } static inline void @@ -891,7 +891,7 @@ equal_int32(const int32_t *s, const int32_t *t, int32_t length) { ++t; --length; } - return static_cast(length == 0); + return length == 0; } static inline UBool @@ -901,7 +901,7 @@ equal_uint32(const uint32_t *s, const uint32_t *t, int32_t length) { ++t; --length; } - return static_cast(length == 0); + return length == 0; } static int32_t diff --git a/icu4c/source/common/utrie_swap.cpp b/icu4c/source/common/utrie_swap.cpp index c61d3af8c319..bb060203fde0 100644 --- a/icu4c/source/common/utrie_swap.cpp +++ b/icu4c/source/common/utrie_swap.cpp @@ -64,7 +64,7 @@ utrie_swap(const UDataSwapper *ds, return 0; } - dataIs32=(UBool)((trie.options&UTRIE_OPTIONS_DATA_IS_32_BIT)!=0); + dataIs32 = (trie.options & UTRIE_OPTIONS_DATA_IS_32_BIT) != 0; size=sizeof(UTrieHeader)+trie.indexLength*2+trie.dataLength*(dataIs32?4:2); if(length>=0) { diff --git a/icu4c/source/common/uts46.cpp b/icu4c/source/common/uts46.cpp index ff7f382c6f2d..018c0e19b778 100644 --- a/icu4c/source/common/uts46.cpp +++ b/icu4c/source/common/uts46.cpp @@ -1366,7 +1366,7 @@ uidna_labelToASCII(const UIDNA *idna, if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), label, length); + UnicodeString src(length < 0, label, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast(idna)->labelToASCII(src, destString, info, *pErrorCode); @@ -1382,7 +1382,7 @@ uidna_labelToUnicode(const UIDNA *idna, if(!checkArgs(label, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), label, length); + UnicodeString src(length < 0, label, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast(idna)->labelToUnicode(src, destString, info, *pErrorCode); @@ -1398,7 +1398,7 @@ uidna_nameToASCII(const UIDNA *idna, if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), name, length); + UnicodeString src(length < 0, name, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast(idna)->nameToASCII(src, destString, info, *pErrorCode); @@ -1414,7 +1414,7 @@ uidna_nameToUnicode(const UIDNA *idna, if(!checkArgs(name, length, dest, capacity, pInfo, pErrorCode)) { return 0; } - UnicodeString src((UBool)(length<0), name, length); + UnicodeString src(length < 0, name, length); UnicodeString destString(dest, 0, capacity); IDNAInfo info; reinterpret_cast(idna)->nameToUnicode(src, destString, info, *pErrorCode); diff --git a/icu4c/source/configure b/icu4c/source/configure index b33b1926d998..5f6fd3958ecd 100755 --- a/icu4c/source/configure +++ b/icu4c/source/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for ICU 76.0.1. +# Generated by GNU Autoconf 2.72 for ICU 76.1. # # Report bugs to . # @@ -606,8 +606,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ICU' PACKAGE_TARNAME='icu4c' -PACKAGE_VERSION='76.0.1' -PACKAGE_STRING='ICU 76.0.1' +PACKAGE_VERSION='76.1' +PACKAGE_STRING='ICU 76.1' PACKAGE_BUGREPORT='https://icu.unicode.org/bugs' PACKAGE_URL='https://icu.unicode.org/' @@ -1387,7 +1387,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures ICU 76.0.1 to adapt to many kinds of systems. +'configure' configures ICU 76.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1453,7 +1453,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ICU 76.0.1:";; + short | recursive ) echo "Configuration of ICU 76.1:";; esac cat <<\_ACEOF @@ -1592,7 +1592,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ICU configure 76.0.1 +ICU configure 76.1 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -2184,7 +2184,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ICU $as_me 76.0.1, which was +It was created by ICU $as_me 76.1, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -9018,7 +9018,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ICU $as_me 76.0.1, which was +This file was extended by ICU $as_me 76.1, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -9074,7 +9074,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -ICU config.status 76.0.1 +ICU config.status 76.1 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/icu4c/source/data/misc/icuver.txt b/icu4c/source/data/misc/icuver.txt index 240ab60e49c9..048da6a25ce9 100644 --- a/icu4c/source/data/misc/icuver.txt +++ b/icu4c/source/data/misc/icuver.txt @@ -9,6 +9,6 @@ // *************************************************************************** icuver:table(nofallback){ CLDRVersion{"46"} - DataVersion{"76.0.1.0"} - ICUVersion{"76.0.1.0"} + DataVersion{"76.1.0.0"} + ICUVersion{"76.1.0.0"} } diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index f74446b43765..96247174f70d 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -2849,7 +2849,7 @@ Calendar::inDaylightTime(UErrorCode& status) const // Force an update of the state of the Calendar. const_cast(this)->complete(status); // cast away const - return static_cast(U_SUCCESS(status) ? internalGet(UCAL_DST_OFFSET) != 0 : false); + return U_SUCCESS(status) ? internalGet(UCAL_DST_OFFSET) != 0 : false; } bool diff --git a/icu4c/source/i18n/collationbuilder.cpp b/icu4c/source/i18n/collationbuilder.cpp index 54c41385755e..0f7043340be3 100644 --- a/icu4c/source/i18n/collationbuilder.cpp +++ b/icu4c/source/i18n/collationbuilder.cpp @@ -1675,7 +1675,7 @@ ucol_openRules(const char16_t *rules, int32_t rulesLength, *pErrorCode = U_MEMORY_ALLOCATION_ERROR; return nullptr; } - UnicodeString r((UBool)(rulesLength < 0), rules, rulesLength); + UnicodeString r(rulesLength < 0, rules, rulesLength); coll->internalBuildTailoring(r, strength, normalizationMode, parseError, nullptr, *pErrorCode); if(U_FAILURE(*pErrorCode)) { delete coll; diff --git a/icu4c/source/i18n/datefmt.cpp b/icu4c/source/i18n/datefmt.cpp index 80f74ede65df..655cfbd1239d 100644 --- a/icu4c/source/i18n/datefmt.cpp +++ b/icu4c/source/i18n/datefmt.cpp @@ -763,7 +763,7 @@ DateFormat::setBooleanAttribute(UDateFormatBooleanAttribute attr, UBool DateFormat::getBooleanAttribute(UDateFormatBooleanAttribute attr, UErrorCode &/*status*/) const { - return static_cast(fBoolFlags.get(attr)); + return fBoolFlags.get(attr); } U_NAMESPACE_END diff --git a/icu4c/source/i18n/dtptngen.cpp b/icu4c/source/i18n/dtptngen.cpp index 976e8d28b305..50c0b050b92e 100644 --- a/icu4c/source/i18n/dtptngen.cpp +++ b/icu4c/source/i18n/dtptngen.cpp @@ -1874,7 +1874,7 @@ DateTimePatternGenerator::setAvailableFormat(const UnicodeString &key, UErrorCod UBool DateTimePatternGenerator::isAvailableFormatSet(const UnicodeString &key) const { - return static_cast(fAvailableFormatKeyHash->geti(key) == 1); + return fAvailableFormatKeyHash->geti(key) == 1; } void @@ -2576,7 +2576,7 @@ FormatParser::getCanonicalIndex(const UnicodeString& s, UBool strict) { UBool FormatParser::isQuoteLiteral(const UnicodeString& s) { - return static_cast(s.charAt(0) == SINGLE_QUOTE); + return s.charAt(0) == SINGLE_QUOTE; } // This function assumes the current itemIndex points to the quote literal. diff --git a/icu4c/source/i18n/messageformat2.cpp b/icu4c/source/i18n/messageformat2.cpp index 7c337133780e..2febdf0ade15 100644 --- a/icu4c/source/i18n/messageformat2.cpp +++ b/icu4c/source/i18n/messageformat2.cpp @@ -814,7 +814,12 @@ UnicodeString MessageFormatter::formatToString(const MessageArguments& arguments } } // Update status according to all errors seen while formatting - context.checkErrors(status); + if (signalErrors) { + context.checkErrors(status); + } + if (U_FAILURE(status)) { + result.remove(); + } return result; } @@ -869,7 +874,7 @@ void MessageFormatter::checkDeclarations(MessageContext& context, Environment*& CHECK_ERROR(status); const Binding* decls = getDataModel().getLocalVariablesInternal(); - U_ASSERT(env != nullptr && decls != nullptr); + U_ASSERT(env != nullptr && (decls != nullptr || getDataModel().bindingsLen == 0)); for (int32_t i = 0; i < getDataModel().bindingsLen; i++) { const Binding& decl = decls[i]; diff --git a/icu4c/source/i18n/messageformat2_data_model.cpp b/icu4c/source/i18n/messageformat2_data_model.cpp index a8762e4004f6..523ff1b39384 100644 --- a/icu4c/source/i18n/messageformat2_data_model.cpp +++ b/icu4c/source/i18n/messageformat2_data_model.cpp @@ -930,9 +930,10 @@ const Pattern& MFDataModel::getPattern() const { return *(std::get_if(&body)); } +// Returns nullptr if no bindings const Binding* MFDataModel::getLocalVariablesInternal() const { U_ASSERT(!bogus); - U_ASSERT(bindings.isValid()); + U_ASSERT(bindingsLen == 0 || bindings.isValid()); return bindings.getAlias(); } @@ -948,9 +949,10 @@ const Variant* MFDataModel::getVariantsInternal() const { return std::get_if(&body)->variants.getAlias(); } +// Returns nullptr if no unsupported statements const UnsupportedStatement* MFDataModel::getUnsupportedStatementsInternal() const { U_ASSERT(!bogus); - U_ASSERT(unsupportedStatements.isValid()); + U_ASSERT(unsupportedStatementsLen == 0 || unsupportedStatements != nullptr); return unsupportedStatements.getAlias(); } @@ -1056,7 +1058,6 @@ MFDataModel::MFDataModel(const MFDataModel& other) : body(Pattern()) { UErrorCode localErrorCode = U_ZERO_ERROR; if (other.hasPattern()) { - // body.emplace(Pattern(*std::get_if(&other.body))); body = *std::get_if(&other.body); } else { const Expression* otherSelectors = other.getSelectorsInternal(); @@ -1069,17 +1070,17 @@ MFDataModel::MFDataModel(const MFDataModel& other) : body(Pattern()) { bogus = true; return; } - // body.emplace(Matcher(copiedSelectors, numSelectors, copiedVariants, numVariants)); body = Matcher(copiedSelectors, numSelectors, copiedVariants, numVariants); } bindingsLen = other.bindingsLen; - bindings.adoptInstead(copyArray(other.bindings.getAlias(), bindingsLen, localErrorCode)); - if (U_FAILURE(localErrorCode)) { - bogus = true; + if (bindingsLen > 0) { + bindings.adoptInstead(copyArray(other.bindings.getAlias(), bindingsLen, localErrorCode)); } unsupportedStatementsLen = other.unsupportedStatementsLen; - unsupportedStatements.adoptInstead(copyArray(other.unsupportedStatements.getAlias(), unsupportedStatementsLen, localErrorCode)); + if (unsupportedStatementsLen > 0) { + unsupportedStatements.adoptInstead(copyArray(other.unsupportedStatements.getAlias(), unsupportedStatementsLen, localErrorCode)); + } if (U_FAILURE(localErrorCode)) { bogus = true; } @@ -1106,9 +1107,14 @@ MFDataModel::MFDataModel(const MFDataModel::Builder& builder, UErrorCode& errorC U_ASSERT(builder.bindings != nullptr); bindingsLen = builder.bindings->size(); - bindings.adoptInstead(copyVectorToArray(*builder.bindings, errorCode)); + if (bindingsLen > 0) { + bindings.adoptInstead(copyVectorToArray(*builder.bindings, errorCode)); + } unsupportedStatementsLen = builder.unsupportedStatements->size(); - unsupportedStatements.adoptInstead(copyVectorToArray(*builder.unsupportedStatements, errorCode)); + if (unsupportedStatementsLen > 0) { + unsupportedStatements.adoptInstead(copyVectorToArray(*builder.unsupportedStatements, + errorCode)); + } if (U_FAILURE(errorCode)) { bogus = true; } diff --git a/icu4c/source/i18n/messageformat2_errors.cpp b/icu4c/source/i18n/messageformat2_errors.cpp index 1fb31377cd1c..32990a670b11 100644 --- a/icu4c/source/i18n/messageformat2_errors.cpp +++ b/icu4c/source/i18n/messageformat2_errors.cpp @@ -121,41 +121,10 @@ namespace message2 { if (count() == 0) { return; } - if (staticErrors.syntaxAndDataModelErrors->size() > 0) { - switch (staticErrors.first().type) { - case StaticErrorType::DuplicateDeclarationError: { - status = U_MF_DUPLICATE_DECLARATION_ERROR; - break; - } - case StaticErrorType::DuplicateOptionName: { - status = U_MF_DUPLICATE_OPTION_NAME_ERROR; - break; - } - case StaticErrorType::VariantKeyMismatchError: { - status = U_MF_VARIANT_KEY_MISMATCH_ERROR; - break; - } - case StaticErrorType::DuplicateVariant: { - status = U_MF_DUPLICATE_VARIANT_ERROR; - break; - } - case StaticErrorType::NonexhaustivePattern: { - status = U_MF_NONEXHAUSTIVE_PATTERN_ERROR; - break; - } - case StaticErrorType::MissingSelectorAnnotation: { - status = U_MF_MISSING_SELECTOR_ANNOTATION_ERROR; - break; - } - case StaticErrorType::SyntaxError: { - status = U_MF_SYNTAX_ERROR; - break; - } - case StaticErrorType::UnsupportedStatementError: { - status = U_MF_UNSUPPORTED_STATEMENT_ERROR; - } - } - } else { + staticErrors.checkErrors(status); + if (U_FAILURE(status)) { + return; + } U_ASSERT(resolutionAndFormattingErrors->size() > 0); switch (first().type) { case DynamicErrorType::UnknownFunction: { @@ -183,7 +152,6 @@ namespace message2 { break; } } - } } void StaticErrors::addSyntaxError(UErrorCode& status) { @@ -277,6 +245,47 @@ namespace message2 { } } + void StaticErrors::checkErrors(UErrorCode& status) const { + if (U_FAILURE(status)) { + return; + } + if (syntaxAndDataModelErrors->size() > 0) { + switch (first().type) { + case StaticErrorType::DuplicateDeclarationError: { + status = U_MF_DUPLICATE_DECLARATION_ERROR; + break; + } + case StaticErrorType::DuplicateOptionName: { + status = U_MF_DUPLICATE_OPTION_NAME_ERROR; + break; + } + case StaticErrorType::VariantKeyMismatchError: { + status = U_MF_VARIANT_KEY_MISMATCH_ERROR; + break; + } + case StaticErrorType::DuplicateVariant: { + status = U_MF_DUPLICATE_VARIANT_ERROR; + break; + } + case StaticErrorType::NonexhaustivePattern: { + status = U_MF_NONEXHAUSTIVE_PATTERN_ERROR; + break; + } + case StaticErrorType::MissingSelectorAnnotation: { + status = U_MF_MISSING_SELECTOR_ANNOTATION_ERROR; + break; + } + case StaticErrorType::SyntaxError: { + status = U_MF_SYNTAX_ERROR; + break; + } + case StaticErrorType::UnsupportedStatementError: { + status = U_MF_UNSUPPORTED_STATEMENT_ERROR; + } + } + } + } + const StaticError& StaticErrors::first() const { U_ASSERT(syntaxAndDataModelErrors.isValid() && syntaxAndDataModelErrors->size() > 0); return *static_cast(syntaxAndDataModelErrors->elementAt(0)); diff --git a/icu4c/source/i18n/messageformat2_errors.h b/icu4c/source/i18n/messageformat2_errors.h index 604c8bcf57ac..d1766af184d1 100644 --- a/icu4c/source/i18n/messageformat2_errors.h +++ b/icu4c/source/i18n/messageformat2_errors.h @@ -100,8 +100,9 @@ namespace message2 { bool hasSyntaxError() const { return syntaxError; } bool hasMissingSelectorAnnotationError() const { return missingSelectorAnnotationError; } void addError(StaticError&&, UErrorCode&); - void checkErrors(UErrorCode&); + void checkErrors(UErrorCode&) const; + void clear(); const StaticError& first() const; StaticErrors(const StaticErrors&, UErrorCode&); StaticErrors(StaticErrors&&) noexcept; diff --git a/icu4c/source/i18n/messageformat2_formatter.cpp b/icu4c/source/i18n/messageformat2_formatter.cpp index f6ad5b87ecb5..8d17ae49b99a 100644 --- a/icu4c/source/i18n/messageformat2_formatter.cpp +++ b/icu4c/source/i18n/messageformat2_formatter.cpp @@ -27,12 +27,31 @@ namespace message2 { // ------------------------------------- // Creates a MessageFormat instance based on the pattern. - MessageFormatter::Builder& MessageFormatter::Builder::setPattern(const UnicodeString& pat, UParseError& parseError, UErrorCode& errorCode) { + void MessageFormatter::Builder::clearState() { normalizedInput.remove(); + delete errors; + errors = nullptr; + } + + MessageFormatter::Builder& MessageFormatter::Builder::setPattern(const UnicodeString& pat, + UParseError& parseError, + UErrorCode& errorCode) { + clearState(); + // Create errors + errors = create(StaticErrors(errorCode), errorCode); + THIS_ON_ERROR(errorCode); + // Parse the pattern MFDataModel::Builder tree(errorCode); Parser(pat, tree, *errors, normalizedInput).parse(parseError, errorCode); + // Fail on syntax errors + if (errors->hasSyntaxError()) { + errors->checkErrors(errorCode); + // Check that the checkErrors() method set the error code + U_ASSERT(U_FAILURE(errorCode)); + } + // Build the data model based on what was parsed dataModel = tree.build(errorCode); hasDataModel = true; @@ -55,9 +74,7 @@ namespace message2 { } MessageFormatter::Builder& MessageFormatter::Builder::setDataModel(MFDataModel&& newDataModel) { - normalizedInput.remove(); - delete errors; - errors = nullptr; + clearState(); hasPattern = false; hasDataModel = true; dataModel = std::move(newDataModel); @@ -65,6 +82,13 @@ namespace message2 { return *this; } + MessageFormatter::Builder& + MessageFormatter::Builder::setErrorHandlingBehavior( + MessageFormatter::UMFErrorHandlingBehavior type) { + signalErrors = type == U_MF_STRICT; + return *this; + } + /* This build() method is non-destructive, which entails the risk that its borrowed MFFunctionRegistry and (if the setDataModel() method was called) @@ -86,6 +110,7 @@ namespace message2 { MessageFormatter::Builder::~Builder() { if (errors != nullptr) { delete errors; + errors = nullptr; } } @@ -116,6 +141,7 @@ namespace message2 { standardMFFunctionRegistry.checkStandard(); normalizedInput = builder.normalizedInput; + signalErrors = builder.signalErrors; // Build data model // First, check that there is a data model @@ -162,6 +188,7 @@ namespace message2 { customMFFunctionRegistry = other.customMFFunctionRegistry; dataModel = std::move(other.dataModel); normalizedInput = std::move(other.normalizedInput); + signalErrors = other.signalErrors; errors = other.errors; other.errors = nullptr; return *this; diff --git a/icu4c/source/i18n/messageformat2_parser.cpp b/icu4c/source/i18n/messageformat2_parser.cpp index 0635074f69c3..462ee6cc22eb 100644 --- a/icu4c/source/i18n/messageformat2_parser.cpp +++ b/icu4c/source/i18n/messageformat2_parser.cpp @@ -460,7 +460,7 @@ void Parser::parseToken(const std::u16string_view& token, UErrorCode& errorCode) U_ASSERT(inBounds(source, index)); int32_t tokenPos = 0; - while (tokenPos < (int32_t) token.length()) { + while (tokenPos < static_cast(token.length())) { if (source[index] != token[tokenPos]) { ERROR(parseError, errorCode, index); return; @@ -1674,7 +1674,7 @@ void Parser::parseUnsupportedStatement(UErrorCode& status) { // Terrible hack to get around the ambiguity between unsupported keywords // and supported keywords bool Parser::nextIs(const std::u16string_view &keyword) const { - for(int32_t i = 0; i < (int32_t) keyword.length(); i++) { + for (int32_t i = 0; i < static_cast(keyword.length()); i++) { if (!inBounds(source, index + i) || source[index + i] != keyword[i]) { return false; } diff --git a/icu4c/source/i18n/messageformat2_serializer.cpp b/icu4c/source/i18n/messageformat2_serializer.cpp index 2d007fa4bf5a..82fa65859419 100644 --- a/icu4c/source/i18n/messageformat2_serializer.cpp +++ b/icu4c/source/i18n/messageformat2_serializer.cpp @@ -248,7 +248,7 @@ void Serializer::emit(const Pattern& pat) { void Serializer::serializeDeclarations() { const Binding* bindings = dataModel.getLocalVariablesInternal(); - U_ASSERT(bindings != nullptr); + U_ASSERT(dataModel.bindingsLen == 0 || bindings != nullptr); for (int32_t i = 0; i < dataModel.bindingsLen; i++) { const Binding& b = bindings[i]; @@ -272,7 +272,7 @@ void Serializer::serializeDeclarations() { void Serializer::serializeUnsupported() { const UnsupportedStatement* statements = dataModel.getUnsupportedStatementsInternal(); - U_ASSERT(statements != nullptr); + U_ASSERT(dataModel.unsupportedStatementsLen == 0 || statements != nullptr); for (int32_t i = 0; i < dataModel.unsupportedStatementsLen; i++) { const UnsupportedStatement& s = statements[i]; diff --git a/icu4c/source/i18n/rbt_pars.cpp b/icu4c/source/i18n/rbt_pars.cpp index 6d0d22724324..9dfdbfe1e9d4 100644 --- a/icu4c/source/i18n/rbt_pars.cpp +++ b/icu4c/source/i18n/rbt_pars.cpp @@ -1693,7 +1693,7 @@ utrans_stripRules(const char16_t *source, int32_t sourceLen, char16_t *target, U U16_NEXT_UNSAFE(source, index, c); source+=index; if(c == QUOTE) { - quoted = (UBool)!quoted; + quoted = !quoted; } else if (!quoted) { if (c == RULE_COMMENT_CHAR) { @@ -1739,7 +1739,7 @@ utrans_stripRules(const char16_t *source, int32_t sourceLen, char16_t *target, U } else if (c2 == QUOTE) { /* \' seen. Make sure we don't do anything when we see it again. */ - quoted = (UBool)!quoted; + quoted = !quoted; } } } diff --git a/icu4c/source/i18n/reldatefmt.cpp b/icu4c/source/i18n/reldatefmt.cpp index ced477ac5de5..fa1adfa78726 100644 --- a/icu4c/source/i18n/reldatefmt.cpp +++ b/icu4c/source/i18n/reldatefmt.cpp @@ -1448,8 +1448,8 @@ ureldatefmt_combineDateAndTime( const URelativeDateTimeFormatter* reldatefmt, *status = U_ILLEGAL_ARGUMENT_ERROR; return 0; } - UnicodeString relDateStr((UBool)(relativeDateStringLen == -1), relativeDateString, relativeDateStringLen); - UnicodeString timeStr((UBool)(timeStringLen == -1), timeString, timeStringLen); + UnicodeString relDateStr(relativeDateStringLen == -1, relativeDateString, relativeDateStringLen); + UnicodeString timeStr(timeStringLen == -1, timeString, timeStringLen); UnicodeString res(result, 0, resultCapacity); ((RelativeDateTimeFormatter*)reldatefmt)->combineDateAndTime(relDateStr, timeStr, res, *status); if (U_FAILURE(*status)) { diff --git a/icu4c/source/i18n/tznames_impl.h b/icu4c/source/i18n/tznames_impl.h index eb4748799e2e..c628cd72edab 100644 --- a/icu4c/source/i18n/tznames_impl.h +++ b/icu4c/source/i18n/tznames_impl.h @@ -99,7 +99,7 @@ struct CharacterNode { }; inline UBool CharacterNode::hasValues() const { - return static_cast(fValues != nullptr); + return fValues != nullptr; } inline int32_t CharacterNode::countValues() const { diff --git a/icu4c/source/i18n/ucoleitr.cpp b/icu4c/source/i18n/ucoleitr.cpp index 8930c103cf4d..429fd847c1ab 100644 --- a/icu4c/source/i18n/ucoleitr.cpp +++ b/icu4c/source/i18n/ucoleitr.cpp @@ -289,7 +289,7 @@ ucol_openElements(const UCollator *coll, return nullptr; } - UnicodeString s((UBool)(textLength < 0), text, textLength); + UnicodeString s(textLength < 0, text, textLength); CollationElementIterator *cei = rbc->createCollationElementIterator(s); if (cei == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; @@ -488,7 +488,7 @@ ucol_setText( UCollationElements *elems, *status = U_ILLEGAL_ARGUMENT_ERROR; return; } - UnicodeString s((UBool)(textLength < 0), text, textLength); + UnicodeString s(textLength < 0, text, textLength); return CollationElementIterator::fromUCollationElements(elems)->setText(s, *status); } diff --git a/icu4c/source/i18n/udat.cpp b/icu4c/source/i18n/udat.cpp index b5e3d2113588..d9a3508a4843 100644 --- a/icu4c/source/i18n/udat.cpp +++ b/icu4c/source/i18n/udat.cpp @@ -162,7 +162,7 @@ udat_open(UDateFormatStyle timeStyle, } } else { - UnicodeString pat((UBool)(patternLength == -1), pattern, patternLength); + UnicodeString pat(patternLength == -1, pattern, patternLength); if (locale == nullptr) { fmt = new SimpleDateFormat(pat, *status); @@ -182,7 +182,7 @@ udat_open(UDateFormatStyle timeStyle, } if (tzID != nullptr) { - TimeZone *zone = TimeZone::createTimeZone(UnicodeString((UBool)(tzIDLength == -1), tzID, tzIDLength)); + TimeZone* zone = TimeZone::createTimeZone(UnicodeString(tzIDLength == -1, tzID, tzIDLength)); if (zone == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; delete fmt; @@ -359,7 +359,7 @@ udat_parse( const UDateFormat* format, { if(U_FAILURE(*status)) return (UDate)0; - const UnicodeString src((UBool)(textLength == -1), text, textLength); + const UnicodeString src(textLength == -1, text, textLength); ParsePosition pp; int32_t stackParsePos = 0; UDate res; @@ -392,7 +392,7 @@ udat_parseCalendar(const UDateFormat* format, { if(U_FAILURE(*status)) return; - const UnicodeString src((UBool)(textLength == -1), text, textLength); + const UnicodeString src(textLength == -1, text, textLength); ParsePosition pp; int32_t stackParsePos = 0; @@ -581,7 +581,7 @@ udat_applyPattern( UDateFormat *format, const char16_t *pattern, int32_t patternLength) { - const UnicodeString pat((UBool)(patternLength == -1), pattern, patternLength); + const UnicodeString pat(patternLength == -1, pattern, patternLength); UErrorCode status = U_ZERO_ERROR; verifyIsSimpleDateFormat(format, &status); @@ -1355,8 +1355,8 @@ udat_applyPatternRelative(UDateFormat *format, { verifyIsRelativeDateFormat(format, status); if(U_FAILURE(*status)) return; - const UnicodeString datePat((UBool)(datePatternLength == -1), datePattern, datePatternLength); - const UnicodeString timePat((UBool)(timePatternLength == -1), timePattern, timePatternLength); + const UnicodeString datePat(datePatternLength == -1, datePattern, datePatternLength); + const UnicodeString timePat(timePatternLength == -1, timePattern, timePatternLength); ((RelativeDateFormat*)format)->applyPatterns(datePat, timePat, *status); } diff --git a/icu4c/source/i18n/udateintervalformat.cpp b/icu4c/source/i18n/udateintervalformat.cpp index 1ab381369313..b67ba05e1fe0 100644 --- a/icu4c/source/i18n/udateintervalformat.cpp +++ b/icu4c/source/i18n/udateintervalformat.cpp @@ -51,14 +51,14 @@ udtitvfmt_open(const char* locale, *status = U_ILLEGAL_ARGUMENT_ERROR; return nullptr; } - UnicodeString skel((UBool)(skeletonLength == -1), skeleton, skeletonLength); + UnicodeString skel(skeletonLength == -1, skeleton, skeletonLength); LocalPointer formatter( DateIntervalFormat::createInstance(skel, Locale(locale), *status)); if (U_FAILURE(*status)) { return nullptr; } if (tzID != nullptr) { - TimeZone *zone = TimeZone::createTimeZone(UnicodeString((UBool)(tzIDLength == -1), tzID, tzIDLength)); + TimeZone* zone = TimeZone::createTimeZone(UnicodeString(tzIDLength == -1, tzID, tzIDLength)); if(zone == nullptr) { *status = U_MEMORY_ALLOCATION_ERROR; return nullptr; diff --git a/icu4c/source/i18n/udatpg.cpp b/icu4c/source/i18n/udatpg.cpp index 07aee36882dd..666dfba0aeda 100644 --- a/icu4c/source/i18n/udatpg.cpp +++ b/icu4c/source/i18n/udatpg.cpp @@ -78,7 +78,7 @@ udatpg_getBestPatternWithOptions(UDateTimePatternGenerator *dtpg, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } - UnicodeString skeletonString((UBool)(length<0), skeleton, length); + UnicodeString skeletonString(length < 0, skeleton, length); UnicodeString result=((DateTimePatternGenerator *)dtpg)->getBestPattern(skeletonString, options, *pErrorCode); return result.extract(bestPattern, capacity, *pErrorCode); } @@ -95,7 +95,7 @@ udatpg_getSkeleton(UDateTimePatternGenerator * /* dtpg */, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } - UnicodeString patternString((UBool)(length<0), pattern, length); + UnicodeString patternString(length < 0, pattern, length); UnicodeString result=DateTimePatternGenerator::staticGetSkeleton( patternString, *pErrorCode); return result.extract(skeleton, capacity, *pErrorCode); @@ -113,7 +113,7 @@ udatpg_getBaseSkeleton(UDateTimePatternGenerator * /* dtpg */, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } - UnicodeString patternString((UBool)(length<0), pattern, length); + UnicodeString patternString(length < 0, pattern, length); UnicodeString result=DateTimePatternGenerator::staticGetBaseSkeleton( patternString, *pErrorCode); return result.extract(skeleton, capacity, *pErrorCode); @@ -132,7 +132,7 @@ udatpg_addPattern(UDateTimePatternGenerator *dtpg, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return UDATPG_NO_CONFLICT; } - UnicodeString patternString((UBool)(patternLength<0), pattern, patternLength); + UnicodeString patternString(patternLength < 0, pattern, patternLength); UnicodeString conflictingPatternString; UDateTimePatternConflict result=((DateTimePatternGenerator *)dtpg)-> addPattern(patternString, override, conflictingPatternString, *pErrorCode); @@ -147,7 +147,7 @@ U_CAPI void U_EXPORT2 udatpg_setAppendItemFormat(UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const char16_t *value, int32_t length) { - UnicodeString valueString((UBool)(length<0), value, length); + UnicodeString valueString(length < 0, value, length); ((DateTimePatternGenerator *)dtpg)->setAppendItemFormat(field, valueString); } @@ -166,7 +166,7 @@ U_CAPI void U_EXPORT2 udatpg_setAppendItemName(UDateTimePatternGenerator *dtpg, UDateTimePatternField field, const char16_t *value, int32_t length) { - UnicodeString valueString((UBool)(length<0), value, length); + UnicodeString valueString(length < 0, value, length); ((DateTimePatternGenerator *)dtpg)->setAppendItemName(field, valueString); } @@ -203,7 +203,7 @@ udatpg_getFieldDisplayName(const UDateTimePatternGenerator *dtpg, U_CAPI void U_EXPORT2 udatpg_setDateTimeFormat(const UDateTimePatternGenerator *dtpg, const char16_t *dtFormat, int32_t length) { - UnicodeString dtFormatString((UBool)(length<0), dtFormat, length); + UnicodeString dtFormatString(length < 0, dtFormat, length); ((DateTimePatternGenerator *)dtpg)->setDateTimeFormat(dtFormatString); } @@ -226,7 +226,7 @@ udatpg_setDateTimeFormatForStyle(UDateTimePatternGenerator *udtpg, return; } DateTimePatternGenerator *dtpg = reinterpret_cast(udtpg); - UnicodeString dtFormatString((UBool)(length<0), dateTimeFormat, length); + UnicodeString dtFormatString(length < 0, dateTimeFormat, length); dtpg->setDateTimeFormat(style, dtFormatString, *pErrorCode); } @@ -255,7 +255,7 @@ udatpg_getDateTimeFormatForStyle(const UDateTimePatternGenerator *udtpg, U_CAPI void U_EXPORT2 udatpg_setDecimal(UDateTimePatternGenerator *dtpg, const char16_t *decimal, int32_t length) { - UnicodeString decimalString((UBool)(length<0), decimal, length); + UnicodeString decimalString(length < 0, decimal, length); ((DateTimePatternGenerator *)dtpg)->setDecimal(decimalString); } @@ -294,8 +294,8 @@ udatpg_replaceFieldTypesWithOptions(UDateTimePatternGenerator *dtpg, *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } - UnicodeString patternString((UBool)(patternLength<0), pattern, patternLength); - UnicodeString skeletonString((UBool)(skeletonLength<0), skeleton, skeletonLength); + UnicodeString patternString(patternLength < 0, pattern, patternLength); + UnicodeString skeletonString(skeletonLength < 0, skeleton, skeletonLength); UnicodeString result=((DateTimePatternGenerator *)dtpg)->replaceFieldTypes(patternString, skeletonString, options, *pErrorCode); return result.extract(dest, destCapacity, *pErrorCode); } @@ -318,7 +318,7 @@ U_CAPI const char16_t * U_EXPORT2 udatpg_getPatternForSkeleton(const UDateTimePatternGenerator *dtpg, const char16_t *skeleton, int32_t skeletonLength, int32_t *pLength) { - UnicodeString skeletonString((UBool)(skeletonLength<0), skeleton, skeletonLength); + UnicodeString skeletonString(skeletonLength < 0, skeleton, skeletonLength); const UnicodeString &result=((const DateTimePatternGenerator *)dtpg)->getPatternForSkeleton(skeletonString); if(pLength!=nullptr) { *pLength=result.length(); diff --git a/icu4c/source/i18n/unicode/messageformat2.h b/icu4c/source/i18n/unicode/messageformat2.h index d23ac8409d81..c5459f042f40 100644 --- a/icu4c/source/i18n/unicode/messageformat2.h +++ b/icu4c/source/i18n/unicode/messageformat2.h @@ -139,6 +139,31 @@ namespace message2 { */ const MFDataModel& getDataModel() const; + /** + * Used in conjunction with the + * MessageFormatter::Builder::setErrorHandlingBehavior() method. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + typedef enum UMFErrorHandlingBehavior { + /** + * Suppress errors and return best-effort output. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + U_MF_BEST_EFFORT = 0, + /** + * Signal all MessageFormat errors using the UErrorCode + * argument. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + U_MF_STRICT + } UMFErrorHandlingBehavior; + /** * The mutable Builder class allows each part of the MessageFormatter to be initialized * separately; calling its `build()` method yields an immutable MessageFormatter. @@ -166,7 +191,10 @@ namespace message2 { Locale locale; // Not owned const MFFunctionRegistry* customMFFunctionRegistry; + // Error behavior; see comment in `MessageFormatter` class + bool signalErrors = false; + void clearState(); public: /** * Sets the locale to use for formatting. @@ -218,6 +246,36 @@ namespace message2 { * @deprecated This API is for technology preview only. */ Builder& setDataModel(MFDataModel&& dataModel); + /** + * Set the error handling behavior for this formatter. + * + * "Strict" error behavior means that that formatting methods + * will set their UErrorCode arguments to signal MessageFormat + * data model, resolution, and runtime errors. Syntax errors are + * always signaled. + * + * "Best effort" error behavior means that MessageFormat errors are + * suppressed: formatting methods will _not_ set their + * UErrorCode arguments to signal MessageFormat data model, + * resolution, or runtime errors. Best-effort output + * will be returned. Syntax errors are always signaled. + * This is the default behavior. + * + * @param type An enum with type UMFErrorHandlingBehavior; + * if type == `U_MF_STRICT`, then + * errors are handled strictly. + * If type == `U_MF_BEST_EFFORT`, then + * best-effort output is returned. + * + * The default is to suppress all MessageFormat errors + * and return best-effort output. + * + * @return A reference to the builder. + * + * @internal ICU 76 technology preview + * @deprecated This API is for technology preview only. + */ + Builder& setErrorHandlingBehavior(UMFErrorHandlingBehavior type); /** * Constructs a new immutable MessageFormatter using the pattern or data model * that was previously set, and the locale (if it was previously set) @@ -378,8 +436,15 @@ namespace message2 { // Must be a raw pointer to avoid including the internal header file // defining StaticErrors // Owned by `this` - StaticErrors* errors; - + StaticErrors* errors = nullptr; + + // Error handling behavior. + // If true, then formatting methods set their UErrorCode arguments + // to signal MessageFormat errors, and no useful output is returned. + // If false, then MessageFormat errors are not signaled and the + // formatting methods return best-effort output. + // The default is false. + bool signalErrors = false; }; // class MessageFormatter } // namespace message2 diff --git a/icu4c/source/i18n/unicode/reldatefmt.h b/icu4c/source/i18n/unicode/reldatefmt.h index 5dc4905b12a8..25d5dffa105a 100644 --- a/icu4c/source/i18n/unicode/reldatefmt.h +++ b/icu4c/source/i18n/unicode/reldatefmt.h @@ -384,8 +384,10 @@ class U_I18N_API FormattedRelativeDateTime : public UMemory, public FormattedVal * * *

- * In the future, we may add more forms, such as abbreviated/short forms - * (3 secs ago), and relative day periods ("yesterday afternoon"), etc. + * The UDateRelativeDateTimeFormatterStyle parameter allows selection of + * different length styles: LONG ("3 seconds ago"), SHORT ("3 sec. ago"), + * NARROW ("3s ago"). In the future, we may add more forms, such as + * relative day periods ("yesterday afternoon"), etc. * * The RelativeDateTimeFormatter class is not intended for public subclassing. * diff --git a/icu4c/source/i18n/unicode/tblcoll.h b/icu4c/source/i18n/unicode/tblcoll.h index 3843691ddf5f..0c65e897f501 100644 --- a/icu4c/source/i18n/unicode/tblcoll.h +++ b/icu4c/source/i18n/unicode/tblcoll.h @@ -850,7 +850,7 @@ class U_I18N_API RuleBasedCollator final : public Collator { } UBool attributeHasBeenSetExplicitly(int32_t attribute) const { // assert(0 <= attribute < ATTR_LIMIT); - return static_cast((explicitlySetAttributes & (static_cast(1) << attribute)) != 0); + return (explicitlySetAttributes & (static_cast(1) << attribute)) != 0; } /** diff --git a/icu4c/source/i18n/unum.cpp b/icu4c/source/i18n/unum.cpp index 7e112d4ad732..d6d18abed1fa 100644 --- a/icu4c/source/i18n/unum.cpp +++ b/icu4c/source/i18n/unum.cpp @@ -485,7 +485,7 @@ unum_parseDoubleCurrency(const UNumberFormat* fmt, if (U_FAILURE(*status)) { return doubleVal; } - const UnicodeString src((UBool)(textLength == -1), text, textLength); + const UnicodeString src(textLength == -1, text, textLength); ParsePosition pp; if (parsePos != nullptr) { pp.setIndex(*parsePos); diff --git a/icu4c/source/io/ufile.cpp b/icu4c/source/io/ufile.cpp index 67930fda544a..63954c5fe2eb 100644 --- a/icu4c/source/io/ufile.cpp +++ b/icu4c/source/io/ufile.cpp @@ -255,7 +255,7 @@ u_feof(UFILE *f) if (f == nullptr) { return true; } - endOfBuffer = (UBool)(f->str.fPos >= f->str.fLimit); + endOfBuffer = f->str.fPos >= f->str.fLimit; if (f->fFile != nullptr) { return endOfBuffer && feof(f->fFile); } diff --git a/icu4c/source/io/ufmt_cmn.cpp b/icu4c/source/io/ufmt_cmn.cpp index 0202783f8b5e..7930fe30beb6 100644 --- a/icu4c/source/io/ufmt_cmn.cpp +++ b/icu4c/source/io/ufmt_cmn.cpp @@ -58,7 +58,7 @@ ufmt_isdigit(char16_t c, { int digitVal = ufmt_digitvalue(c); - return static_cast(digitVal < radix && digitVal >= 0); + return digitVal < radix && digitVal >= 0; } #define TO_UC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0037 + a) diff --git a/icu4c/source/test/cintltst/capitst.c b/icu4c/source/test/cintltst/capitst.c index 4797096310b7..2da8cd29adb5 100644 --- a/icu4c/source/test/cintltst/capitst.c +++ b/icu4c/source/test/cintltst/capitst.c @@ -1282,8 +1282,8 @@ void TestSortKey(void) for(i=0;i U_CNV_SAFECLONE_BUFFERSIZE) { log_err("ucnv_safeClone(): max preflighted clone size=%d (%s) is larger than U_CNV_SAFECLONE_BUFFERSIZE=%d\n", - maxBufferSize, maxName, (int)U_CNV_SAFECLONE_BUFFERSIZE); + maxBufferSize, maxName, U_CNV_SAFECLONE_BUFFERSIZE); } } diff --git a/icu4c/source/test/cintltst/chashtst.c b/icu4c/source/test/cintltst/chashtst.c index a4b774d93a1c..729b9b9c3ae0 100644 --- a/icu4c/source/test/cintltst/chashtst.c +++ b/icu4c/source/test/cintltst/chashtst.c @@ -379,9 +379,9 @@ static int32_t U_EXPORT2 U_CALLCONV hashChars(const UHashTok key) { } static UBool U_EXPORT2 U_CALLCONV isEqualChars(const UHashTok key1, const UHashTok key2) { - return (UBool)((key1.pointer != NULL) && - (key2.pointer != NULL) && - (uprv_strcmp((const char*)key1.pointer, (const char*)key2.pointer) == 0)); + return key1.pointer != NULL && + key2.pointer != NULL && + uprv_strcmp((const char*)key1.pointer, (const char*)key2.pointer) == 0; } /********************************************************************** diff --git a/icu4c/source/test/cintltst/cintltst.c b/icu4c/source/test/cintltst/cintltst.c index 4c6d5fc6dec7..ab82fde24750 100644 --- a/icu4c/source/test/cintltst/cintltst.c +++ b/icu4c/source/test/cintltst/cintltst.c @@ -247,10 +247,10 @@ int main(int argc, const char* const argv[]) endTime = uprv_getRawUTCtime(); diffTime = (int32_t)(endTime - startTime); printf("Elapsed Time: %02d:%02d:%02d.%03d\n", - (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR), - (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE), - (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND), - (int)(diffTime%U_MILLIS_PER_SECOND)); + (diffTime % U_MILLIS_PER_DAY) / U_MILLIS_PER_HOUR, + (diffTime % U_MILLIS_PER_HOUR) / U_MILLIS_PER_MINUTE, + (diffTime % U_MILLIS_PER_MINUTE) / U_MILLIS_PER_SECOND, + (diffTime % U_MILLIS_PER_SECOND)); return nerrors ? 1 : 0; } @@ -723,7 +723,7 @@ U_CFUNC UBool assertTrue(const char* msg, int /*not UBool*/ condition) { log_verbose("Ok: %s\n", msg); } #endif - return (UBool)condition; + return condition; } U_CFUNC UBool assertEquals(const char* message, const char* expected, diff --git a/icu4c/source/test/cintltst/crestst.c b/icu4c/source/test/cintltst/crestst.c index 7d0476462e66..f32dce366eac 100644 --- a/icu4c/source/test/cintltst/crestst.c +++ b/icu4c/source/test/cintltst/crestst.c @@ -428,7 +428,7 @@ UBool testTag(const char* frag, ures_close(theBundle); } free(base); - return (UBool)(passNum == pass); + return passNum == pass; } void record_pass(void) diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index 4877d8b49ccf..d5b0bb4febf8 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -2055,7 +2055,7 @@ static UBool testTag(const char* frag, ures_close(tags); ures_close(arrayItem1); free(base); - return (UBool)(failNum == fail); + return failNum == fail; } static void record_pass(void) diff --git a/icu4c/source/test/cintltst/nccbtst.c b/icu4c/source/test/cintltst/nccbtst.c index 825e918192fc..77f84a5ff089 100644 --- a/icu4c/source/test/cintltst/nccbtst.c +++ b/icu4c/source/test/cintltst/nccbtst.c @@ -2713,8 +2713,8 @@ UBool testConvertFromUnicode(const UChar *source, int sourceLen, const uint8_t status = U_ZERO_ERROR; ucnv_fromUnicode (conv, - (char **)&targ, - (const char *)end, + &targ, + end, &src, sourceLimit, checkOffsets ? offs : NULL, @@ -2911,8 +2911,8 @@ UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const UChar *e ucnv_toUnicode (conv, &targ, end, - (const char **)&src, - (const char *)srcLimit, + &src, + srcLimit, checkOffsets ? offs : NULL, (UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of the source data */ &status); @@ -3104,8 +3104,8 @@ UBool testConvertFromUnicodeWithContext(const UChar *source, int sourceLen, con status = U_ZERO_ERROR; ucnv_fromUnicode (conv, - (char **)&targ, - (const char *)end, + &targ, + end, &src, sourceLimit, checkOffsets ? offs : NULL, @@ -3284,8 +3284,8 @@ UBool testConvertToUnicodeWithContext( const uint8_t *source, int sourcelen, con ucnv_toUnicode (conv, &targ, end, - (const char **)&src, - (const char *)srcLimit, + &src, + srcLimit, checkOffsets ? offs : NULL, (UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of the source data */ &status); diff --git a/icu4c/source/test/cintltst/ncnvfbts.c b/icu4c/source/test/cintltst/ncnvfbts.c index 1aded8e4eafb..ac52397395a8 100644 --- a/icu4c/source/test/cintltst/ncnvfbts.c +++ b/icu4c/source/test/cintltst/ncnvfbts.c @@ -209,8 +209,8 @@ static UBool testConvertFromUnicode(const UChar *source, int sourceLen, const u status = U_ZERO_ERROR; ucnv_fromUnicode (conv, - (char **)&targ, - (const char *)end, + &targ, + end, &src, sourceLimit, checkOffsets ? offs : NULL, @@ -374,8 +374,8 @@ static UBool testConvertToUnicode( const uint8_t *source, int sourcelen, const U ucnv_toUnicode (conv, &targ, end, - (const char **)&src, - (const char *)srcLimit, + &src, + srcLimit, checkOffsets ? offs : NULL, (UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of the source data */ &status); diff --git a/icu4c/source/test/cintltst/ncnvtst.c b/icu4c/source/test/cintltst/ncnvtst.c index 77b45db53274..2d695a6e5769 100644 --- a/icu4c/source/test/cintltst/ncnvtst.c +++ b/icu4c/source/test/cintltst/ncnvtst.c @@ -1027,8 +1027,8 @@ static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *e targetLimit=targ+MAX_LENGTH; offs=offsetBuffer; ucnv_fromUnicode (conv, - (char **)&targ, - (const char *)targetLimit, + &targ, + targetLimit, &src, sourceLimit, expectOffsets ? offs : NULL, @@ -1125,7 +1125,7 @@ static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expe ucnv_toUnicode (conv, &targ, targetLimit, - (const char **)&src, + &src, (const char *)sourceLimit, expectOffsets ? offs : NULL, doFlush, @@ -1259,8 +1259,8 @@ static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_ if(gInBufferSize ==999 && gOutBufferSize==999) doFlush = false; ucnv_fromUnicode (conv, - (char **)&targ, - (const char *)end, + &targ, + end, &src, sourceLimit, offs, @@ -1434,8 +1434,8 @@ static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar * ucnv_toUnicode (conv, &targ, end, - (const char **)&src, - (const char *)srcLimit, + &src, + srcLimit, offs, doFlush, /* flush if we're at the end of the source data */ &status); diff --git a/icu4c/source/test/cintltst/nucnvtst.c b/icu4c/source/test/cintltst/nucnvtst.c index 6c97419f4cd8..294b6f43de9f 100644 --- a/icu4c/source/test/cintltst/nucnvtst.c +++ b/icu4c/source/test/cintltst/nucnvtst.c @@ -456,12 +456,12 @@ static ETestConvertResult testConvertFromU( const UChar *source, int sourceLen, junk[0] = 0; offset_str[0] = 0; for(ptr = junkout;ptr0; ){ uSource = (UChar*) source; - uSourceLimit=(const UChar*)sourceLimit; + uSourceLimit = sourceLimit; cTarget = cBuf; uTarget = uBuf; cSource = cBuf; @@ -2993,7 +2993,7 @@ TestGetNextUChar2022(UConverter* cnv, const char* source, const char* limit, }else{ exC = *r; } - if(c!=(uint32_t)(exC)) + if (c != exC) log_err("%s ucnv_getNextUChar() Expected: \\u%04X Got: \\u%04X \n",message,(uint32_t) (*r),c); } r++; @@ -5084,7 +5084,7 @@ TestLMBCS(void) { pUniIn = uniString; ucnv_toUnicode (cnv01us, &pUniIn, pUniIn + 1, - &pLMBCSOut, (const char *)(pLMBCSOut + 3), + &pLMBCSOut, pLMBCSOut + 3, NULL, 1, &errorCode); if (U_FAILURE(errorCode) || pLMBCSOut != (const char *)lmbcsString+3 || pUniIn != uniString+1 || uniString[0] != 0xFF6E) { @@ -5185,14 +5185,14 @@ TestLMBCS(void) { pUIn--; errorCode=U_ZERO_ERROR; - ucnv_toUnicode(cnv, &pUOut,pUOut+1,(const char **)&pLIn,(const char *)(pLIn-1),off,false, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + 1, &pLIn, pLIn - 1, off, false, &errorCode); if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) { log_err("Unexpected Error on negative source request to ucnv_toUnicode: %s\n", u_errorName(errorCode)); } errorCode=U_ZERO_ERROR; - uniChar = ucnv_getNextUChar(cnv, (const char **)&pLIn, (const char *)(pLIn-1), &errorCode); + uniChar = ucnv_getNextUChar(cnv, &pLIn, pLIn - 1, &errorCode); if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) { log_err("Unexpected Error on negative source request to ucnv_getNextUChar: %s\n", u_errorName(errorCode)); @@ -5200,7 +5200,7 @@ TestLMBCS(void) { errorCode=U_ZERO_ERROR; /* 0 byte source request - no error, no pointer movement */ - ucnv_toUnicode(cnv, &pUOut,pUOut+1,(const char **)&pLIn,(const char *)pLIn,off,false, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + 1, &pLIn, pLIn, off, false, &errorCode); ucnv_fromUnicode(cnv, &pLOut,pLOut+1,&pUIn,pUIn,off,false, &errorCode); if(U_FAILURE(errorCode)) { log_err("0 byte source request: unexpected error: %s\n", u_errorName(errorCode)); @@ -5210,7 +5210,7 @@ TestLMBCS(void) { log_err("Unexpected pointer move in 0 byte source request \n"); } /*0 byte source request - GetNextUChar : error & value == fffe or ffff */ - uniChar = ucnv_getNextUChar(cnv, (const char **)&pLIn, (const char *)pLIn, &errorCode); + uniChar = ucnv_getNextUChar(cnv, &pLIn, pLIn, &errorCode); if (errorCode != U_INDEX_OUTOFBOUNDS_ERROR) { log_err("Unexpected Error on 0-byte source request to ucnv_getnextUChar: %s\n", u_errorName(errorCode)); @@ -5252,7 +5252,7 @@ TestLMBCS(void) { pUOut = UOut; ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_STOP, NULL, NULL, NULL, &errorCode); - ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+5),off,true, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + UPRV_LENGTHOF(UOut), &pLIn, pLIn + 5, off, true, &errorCode); if (UOut[0] != 0xD801 || errorCode != U_TRUNCATED_CHAR_FOUND || pUOut != UOut + 1 || pLIn != LIn + 5) { log_err("Unexpected results on chopped low surrogate\n"); @@ -5266,7 +5266,7 @@ TestLMBCS(void) { errorCode = U_ZERO_ERROR; pUOut = UOut; - ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+3),off,true, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + UPRV_LENGTHOF(UOut), &pLIn, pLIn + 3, off, true, &errorCode); if (UOut[0] != 0xD801 || U_FAILURE(errorCode) || pUOut != UOut + 1 || pLIn != LIn + 3) { log_err("Unexpected results on chopped at surrogate boundary \n"); @@ -5283,7 +5283,7 @@ TestLMBCS(void) { errorCode = U_ZERO_ERROR; pUOut = UOut; - ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+6),off,true, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + UPRV_LENGTHOF(UOut), &pLIn, pLIn + 6, off, true, &errorCode); if (UOut[0] != 0xD801 || UOut[1] != 0xC9D0 || U_FAILURE(errorCode) || pUOut != UOut + 2 || pLIn != LIn + 6) { log_err("Unexpected results after unpaired surrogate plus valid Unichar \n"); @@ -5300,7 +5300,7 @@ TestLMBCS(void) { errorCode = U_ZERO_ERROR; pUOut = UOut; - ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+5),off,true, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + UPRV_LENGTHOF(UOut), &pLIn, pLIn + 5, off, true, &errorCode); if (UOut[0] != 0xD801 || errorCode != U_TRUNCATED_CHAR_FOUND || pUOut != UOut + 1 || pLIn != LIn + 5) { log_err("Unexpected results after unpaired surrogate plus chopped Unichar \n"); @@ -5317,7 +5317,7 @@ TestLMBCS(void) { errorCode = U_ZERO_ERROR; pUOut = UOut; - ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+5),off,true, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + UPRV_LENGTHOF(UOut), &pLIn, pLIn + 5, off, true, &errorCode); if (UOut[0] != 0xD801 || UOut[1] != 0x1B || U_FAILURE(errorCode) || pUOut != UOut + 2 || pLIn != LIn + 5) { log_err("Unexpected results after unpaired surrogate plus valid non-Unichar\n"); @@ -5333,7 +5333,7 @@ TestLMBCS(void) { errorCode = U_ZERO_ERROR; pUOut = UOut; - ucnv_toUnicode(cnv, &pUOut,pUOut+UPRV_LENGTHOF(UOut),(const char **)&pLIn,(const char *)(pLIn+4),off,true, &errorCode); + ucnv_toUnicode(cnv, &pUOut, pUOut + UPRV_LENGTHOF(UOut), &pLIn, pLIn + 4, off, true, &errorCode); if (UOut[0] != 0xD801 || errorCode != U_TRUNCATED_CHAR_FOUND || pUOut != UOut + 1 || pLIn != LIn + 4) { @@ -5390,7 +5390,7 @@ static void TestEBCDICUS4XML(void) log_data_err("Failed to open the converter for EBCDIC-XML-US.\n"); return; } - ucnv_toUnicode(cnv, &unicodes, unicodes+3, (const char**)&newLines, newLines+3, NULL, true, &status); + ucnv_toUnicode(cnv, &unicodes, unicodes + 3, &newLines, newLines + 3, NULL, true, &status); if (U_FAILURE(status) || memcmp(unicodes_x, toUnicodeMaps, sizeof(UChar)*3) != 0) { log_err("To Unicode conversion failed in EBCDICUS4XML test. %s\n", u_errorName(status)); @@ -5398,7 +5398,7 @@ static void TestEBCDICUS4XML(void) printUSeqErr(toUnicodeMaps, 3); } status = U_ZERO_ERROR; - ucnv_fromUnicode(cnv, &target, target+3, (const UChar**)&toUnicodeMaps, toUnicodeMaps+3, NULL, true, &status); + ucnv_fromUnicode(cnv, &target, target + 3, &toUnicodeMaps, toUnicodeMaps + 3, NULL, true, &status); if (U_FAILURE(status) || memcmp(target_x, fromUnicodeMaps, sizeof(char)*3) != 0) { log_err("From Unicode conversion failed in EBCDICUS4XML test. %s\n", u_errorName(status)); diff --git a/icu4c/source/test/cintltst/trie2test.c b/icu4c/source/test/cintltst/trie2test.c index d3c50a125ad1..a1459773607b 100644 --- a/icu4c/source/test/cintltst/trie2test.c +++ b/icu4c/source/test/cintltst/trie2test.c @@ -477,7 +477,7 @@ testTrieUTF8(const char *testName, } if(i8!=(p-s)) { log_err("error: wrong end index from UTRIE2_U8_NEXT(%s)(from %d %lx->U+%04lx): %ld != %ld\n", - testName, (int)prev8, (unsigned long)bytes, (long)c, (long)(p-s), (long)i8); + testName, (int)prev8, (unsigned long)bytes, (long)c, p - s, (long)i8); continue; } ++i; @@ -510,7 +510,7 @@ testTrieUTF8(const char *testName, } if(i8!=(p-s)) { log_err("error: wrong end index from UTRIE2_U8_PREV(%s)(from %d %lx->U+%04lx): %ld != %ld\n", - testName, (int)prev8, (unsigned long)bytes, (long)c, (long)(p-s), (long)i8); + testName, (int)prev8, (unsigned long)bytes, (long)c, p - s, (long)i8); continue; } } diff --git a/icu4c/source/test/cintltst/ucptrietest.c b/icu4c/source/test/cintltst/ucptrietest.c index 1a75a3a2f0dc..df32389bceec 100644 --- a/icu4c/source/test/cintltst/ucptrietest.c +++ b/icu4c/source/test/cintltst/ucptrietest.c @@ -636,7 +636,7 @@ testTrieUTF8(const char *testName, log_err("error: wrong end index from UCPTRIE_FAST_U8_NEXT(%s)(from %d %lx->U+%04lx): " "%ld != %ld (bytes %lx)\n", testName, (int)prev8, (unsigned long)actualBytes, (long)c, - (long)(p-s), (long)i8, (unsigned long)expectedBytes); + p - s, (long)i8, (unsigned long)expectedBytes); break; } ++i; @@ -682,7 +682,7 @@ testTrieUTF8(const char *testName, log_err("error: wrong end index from UCPTRIE_FAST_U8_PREV(%s)(from %d %lx->U+%04lx): " "%ld != %ld (bytes %lx)\n", testName, (int)prev8, (unsigned long)actualBytes, (long)c, - (long)(p-s), (long)i8, (unsigned long)expectedBytes); + p - s, (long)i8, (unsigned long)expectedBytes); break; } } diff --git a/icu4c/source/test/cintltst/udatatst.c b/icu4c/source/test/cintltst/udatatst.c index 548971b17df0..fc1ab786ad34 100644 --- a/icu4c/source/test/cintltst/udatatst.c +++ b/icu4c/source/test/cintltst/udatatst.c @@ -1148,7 +1148,7 @@ static void TestICUDataName(void) typeChar = 'l'; break; default: - log_err("Expected 1 or 0 for U_IS_BIG_ENDIAN, got %d!\n", (int)U_IS_BIG_ENDIAN); + log_err("Expected 1 or 0 for U_IS_BIG_ENDIAN, got %d!\n", U_IS_BIG_ENDIAN); /* return; */ } break; diff --git a/icu4c/source/test/intltest/idnaref.cpp b/icu4c/source/test/intltest/idnaref.cpp index 92091efeda41..d08c5582493e 100644 --- a/icu4c/source/test/intltest/idnaref.cpp +++ b/icu4c/source/test/intltest/idnaref.cpp @@ -276,8 +276,8 @@ idnaref_toASCII(const char16_t* src, int32_t srcLength, reqLength=0; //get the options - UBool allowUnassigned = (UBool)((options & IDNAREF_ALLOW_UNASSIGNED) != 0); - UBool useSTD3ASCIIRules = (UBool)((options & IDNAREF_USE_STD3_RULES) != 0); + UBool allowUnassigned = (options & IDNAREF_ALLOW_UNASSIGNED) != 0; + UBool useSTD3ASCIIRules = (options & IDNAREF_USE_STD3_RULES) != 0; UBool* caseFlags = nullptr; @@ -455,8 +455,8 @@ idnaref_toUnicode(const char16_t* src, int32_t srcLength, UBool* caseFlags = nullptr; //get the options - UBool allowUnassigned = (UBool)((options & IDNAREF_ALLOW_UNASSIGNED) != 0); - UBool useSTD3ASCIIRules = (UBool)((options & IDNAREF_USE_STD3_RULES) != 0); + UBool allowUnassigned = (options & IDNAREF_ALLOW_UNASSIGNED) != 0; + UBool useSTD3ASCIIRules = (options & IDNAREF_USE_STD3_RULES) != 0; UBool srcIsASCII = true; UBool srcIsLDH = true; diff --git a/icu4c/source/test/intltest/messageformat2test.cpp b/icu4c/source/test/intltest/messageformat2test.cpp index 524ee4ab79d9..353082ef5c91 100644 --- a/icu4c/source/test/intltest/messageformat2test.cpp +++ b/icu4c/source/test/intltest/messageformat2test.cpp @@ -30,6 +30,9 @@ TestMessageFormat2::runIndexedTest(int32_t index, UBool exec, TESTCASE_AUTO(testAPI); TESTCASE_AUTO(testAPISimple); TESTCASE_AUTO(testDataModelAPI); + TESTCASE_AUTO(testFormatterAPI); + TESTCASE_AUTO(testHighLoneSurrogate); + TESTCASE_AUTO(testLowLoneSurrogate); TESTCASE_AUTO(dataDrivenTests); TESTCASE_AUTO_END; } @@ -64,6 +67,77 @@ void TestMessageFormat2::testDataModelAPI() { assertEquals("testDataModelAPI", i, 3); } +// Needs more tests +void TestMessageFormat2::testFormatterAPI() { + IcuTestErrorCode errorCode(*this, "testFormatterAPI"); + UnicodeString result; + UParseError parseError; + + // Check that constructing the formatter fails + // if there's a syntax error + UnicodeString pattern = "{{}"; + MessageFormatter::Builder mfBuilder(errorCode); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); // This shouldn't matter, since there's a syntax error + mfBuilder.setPattern(pattern, parseError, errorCode); + MessageFormatter mf = mfBuilder.build(errorCode); + errorCode.expectErrorAndReset(U_MF_SYNTAX_ERROR, + "testFormatterAPI: expected syntax error, best-effort error handling"); + + // Parsing is done when setPattern() is called, + // so setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT) or setSuppressErrors must be called + // _before_ setPattern() to get the right behavior, + // and if either method is called after setting a pattern, + // setPattern() has to be called again. + + // Should get the same behavior with strict errors + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); + // Force re-parsing, as above comment + mfBuilder.setPattern(pattern, parseError, errorCode); + mf = mfBuilder.build(errorCode); + errorCode.expectErrorAndReset(U_MF_SYNTAX_ERROR, + "testFormatterAPI: expected syntax error, strict error handling"); + + // Try the same thing for a pattern with a resolution error + pattern = "{{{$x}}}"; + // Check that a pattern with a resolution error gives fallback output + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); + mfBuilder.setPattern(pattern, parseError, errorCode); + mf = mfBuilder.build(errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: expected success from builder, best-effort error handling"); + result = mf.formatToString(MessageArguments(), errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: expected success from formatter, best-effort error handling"); + assertEquals("testFormatterAPI: fallback for message with unresolved variable", + result, "{$x}"); + + // Check that we do get an error with strict errors + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); + mf = mfBuilder.build(errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: builder should succeed with resolution error"); + result = mf.formatToString(MessageArguments(), errorCode); + errorCode.expectErrorAndReset(U_MF_UNRESOLVED_VARIABLE_ERROR, + "testFormatterAPI: formatting should fail with resolution error and strict error handling"); + + // Finally, check a valid pattern + pattern = "hello"; + mfBuilder.setPattern(pattern, parseError, errorCode); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); + mf = mfBuilder.build(errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: expected success from builder with valid pattern, best-effort error handling"); + result = mf.formatToString(MessageArguments(), errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: expected success from formatter with valid pattern, best-effort error handling"); + assertEquals("testFormatterAPI: wrong output with valid pattern, best-effort error handling", + result, "hello"); + + // Check that behavior is the same with strict errors + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); + mf = mfBuilder.build(errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: expected success from builder with valid pattern, strict error handling"); + result = mf.formatToString(MessageArguments(), errorCode); + errorCode.errIfFailureAndReset("testFormatterAPI: expected success from formatter with valid pattern, strict error handling"); + assertEquals("testFormatterAPI: wrong output with valid pattern, strict error handling", + result, "hello"); +} + // Example for design doc -- version without null and error checks void TestMessageFormat2::testAPISimple() { IcuTestErrorCode errorCode1(*this, "testAPI"); @@ -216,9 +290,11 @@ void TestMessageFormat2::testAPICustomFunctions() { MessageFormatter::Builder mfBuilder(errorCode); UnicodeString result; // This fails, because we did not provide a function registry: - MessageFormatter mf = mfBuilder.setPattern("Hello {$name :person formality=informal}", parseError, errorCode) - .setLocale(locale) - .build(errorCode); + MessageFormatter mf = mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT) + .setPattern("Hello {$name :person formality=informal}", + parseError, errorCode) + .setLocale(locale) + .build(errorCode); result = mf.formatToString(arguments, errorCode); assertEquals("testAPICustomFunctions", U_MF_UNKNOWN_FUNCTION_ERROR, errorCode); @@ -263,6 +339,34 @@ void TestMessageFormat2::testAPICustomFunctions() { delete person; } +// ICU-22890 lone surrogate cause infinity loop +void TestMessageFormat2::testHighLoneSurrogate() { + IcuTestErrorCode errorCode(*this, "testHighLoneSurrogate"); + UParseError pe = { 0, 0, {0}, {0} }; + // Lone surrogate with only high surrogate + UnicodeString loneSurrogate({0xda02, 0}); + icu::message2::MessageFormatter msgfmt1 = + icu::message2::MessageFormatter::Builder(errorCode) + .setPattern(loneSurrogate, pe, errorCode) + .build(errorCode); + UnicodeString result = msgfmt1.formatToString({}, errorCode); + errorCode.expectErrorAndReset(U_MF_SYNTAX_ERROR, "testHighLoneSurrogate"); +} + +// ICU-22890 lone surrogate cause infinity loop +void TestMessageFormat2::testLowLoneSurrogate() { + IcuTestErrorCode errorCode(*this, "testLowLoneSurrogate"); + UParseError pe = { 0, 0, {0}, {0} }; + // Lone surrogate with only low surrogate + UnicodeString loneSurrogate({0xdc02, 0}); + icu::message2::MessageFormatter msgfmt2 = + icu::message2::MessageFormatter::Builder(errorCode) + .setPattern(loneSurrogate, pe, errorCode) + .build(errorCode); + UnicodeString result = msgfmt2.formatToString({}, errorCode); + errorCode.expectErrorAndReset(U_MF_SYNTAX_ERROR, "testLowLoneSurrogate"); +} + void TestMessageFormat2::dataDrivenTests() { IcuTestErrorCode errorCode(*this, "jsonTests"); diff --git a/icu4c/source/test/intltest/messageformat2test.h b/icu4c/source/test/intltest/messageformat2test.h index 7c7c2612f50d..71dfb3916c9b 100644 --- a/icu4c/source/test/intltest/messageformat2test.h +++ b/icu4c/source/test/intltest/messageformat2test.h @@ -45,6 +45,8 @@ class TestMessageFormat2: public IntlTest { void testCustomFunctions(void); // Test the data model API void testDataModelAPI(void); + // Test the formatting API + void testFormatterAPI(void); void testAPI(void); void testAPISimple(void); @@ -87,6 +89,8 @@ class TestMessageFormat2: public IntlTest { void testMessageFormatDateTimeSkeleton(message2::TestCase::Builder&, IcuTestErrorCode&); void testMf1Behavior(message2::TestCase::Builder&, IcuTestErrorCode&); + void testHighLoneSurrogate(void); + void testLowLoneSurrogate(void); }; // class TestMessageFormat2 U_NAMESPACE_BEGIN diff --git a/icu4c/source/test/intltest/messageformat2test_utils.h b/icu4c/source/test/intltest/messageformat2test_utils.h index 08cdd57bfa72..c4ad251c7f48 100644 --- a/icu4c/source/test/intltest/messageformat2test_utils.h +++ b/icu4c/source/test/intltest/messageformat2test_utils.h @@ -228,22 +228,32 @@ class TestUtils { if (testCase.hasCustomRegistry()) { mfBuilder.setFunctionRegistry(*testCase.getCustomRegistry()); } + // Initially, set error behavior to strict. + // We'll re-run to check for errors. + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_STRICT); MessageFormatter mf = mfBuilder.build(errorCode); UnicodeString result; + // Builder should fail if a syntax error was expected + if (!testCase.expectSuccess() && testCase.expectedErrorCode() == U_MF_SYNTAX_ERROR) { + if (errorCode != testCase.expectedErrorCode()) { + failExpectedFailure(tmsg, testCase, errorCode); + } + errorCode.reset(); + return; + } + if (U_SUCCESS(errorCode)) { result = mf.formatToString(MessageArguments(testCase.getArguments(), errorCode), errorCode); } - if (testCase.expectSuccess() || (testCase.expectedErrorCode() != U_MF_SYNTAX_ERROR - // For now, don't round-trip messages with these errors, - // since duplicate options are dropped - && testCase.expectedErrorCode() != U_MF_DUPLICATE_OPTION_NAME_ERROR)) { - const UnicodeString& in = mf.getNormalizedPattern(); - UnicodeString out; - if (!roundTrip(in, mf.getDataModel(), out)) { - failRoundTrip(tmsg, testCase, in, out); - } + const UnicodeString& in = mf.getNormalizedPattern(); + UnicodeString out; + if (!roundTrip(in, mf.getDataModel(), out) + // For now, don't round-trip messages with these errors, + // since duplicate options are dropped + && testCase.expectedErrorCode() != U_MF_DUPLICATE_OPTION_NAME_ERROR) { + failRoundTrip(tmsg, testCase, in, out); } if (testCase.expectNoSyntaxError()) { @@ -264,9 +274,27 @@ class TestUtils { if (!testCase.lineNumberAndOffsetMatch(parseError.line, parseError.offset)) { failWrongOffset(tmsg, testCase, parseError.line, parseError.offset); } - if (!testCase.outputMatches(result)) { - failWrongOutput(tmsg, testCase, result); - return; + if (U_FAILURE(errorCode) && !testCase.expectSuccess() + && testCase.expectedErrorCode() != U_MF_SYNTAX_ERROR) { + // Re-run the formatter if there was an error, + // in order to get best-effort output + errorCode.reset(); + mfBuilder.setErrorHandlingBehavior(MessageFormatter::U_MF_BEST_EFFORT); + mf = mfBuilder.build(errorCode); + if (U_SUCCESS(errorCode)) { + result = mf.formatToString(MessageArguments(testCase.getArguments(), errorCode), errorCode); + } + if (U_FAILURE(errorCode)) { + // Must be a non-MF2 error code + U_ASSERT(!(errorCode >= U_MF_UNRESOLVED_VARIABLE_ERROR + && errorCode <= U_FMT_PARSE_ERROR_LIMIT)); + } + // Re-run the formatter + result = mf.formatToString(MessageArguments(testCase.getArguments(), errorCode), errorCode); + if (!testCase.outputMatches(result)) { + failWrongOutput(tmsg, testCase, result); + return; + } } errorCode.reset(); } @@ -278,7 +306,7 @@ class TestUtils { static void failSyntaxError(IntlTest& tmsg, const TestCase& testCase) { tmsg.dataerrln(testCase.getTestName()); - tmsg.logln(testCase.getTestName() + " failed test with pattern: " + testCase.getPattern() + " and error code U_MF_SYNTAX_WARNING; expected no syntax error"); + tmsg.logln(testCase.getTestName() + " failed test with pattern: " + testCase.getPattern() + " and error code U_MF_SYNTAX_ERROR; expected no syntax error"); } static void failExpectedSuccess(IntlTest& tmsg, const TestCase& testCase, IcuTestErrorCode& errorCode, int32_t line, int32_t offset) { diff --git a/icu4c/source/test/intltest/nptrans.cpp b/icu4c/source/test/intltest/nptrans.cpp index aebf18104924..879fdfa16af3 100644 --- a/icu4c/source/test/intltest/nptrans.cpp +++ b/icu4c/source/test/intltest/nptrans.cpp @@ -122,7 +122,7 @@ NamePrepTransform::NamePrepTransform(UParseError& parseError, UErrorCode& status UBool NamePrepTransform::isProhibited(UChar32 ch){ - return static_cast(ch != ASCII_SPACE); + return ch != ASCII_SPACE; } NamePrepTransform::~NamePrepTransform(){ diff --git a/icu4c/source/test/intltest/restest.cpp b/icu4c/source/test/intltest/restest.cpp index 381dfa25627a..661312ad5316 100644 --- a/icu4c/source/test/intltest/restest.cpp +++ b/icu4c/source/test/intltest/restest.cpp @@ -499,12 +499,12 @@ ResourceBundleTest::testTag(const char* frag, else if (status != expected_resource_status) { record_fail("Error getting " + UnicodeString(tag)); - return static_cast(failOrig != fail); + return failOrig != fail; } } - return static_cast(failOrig != fail); + return failOrig != fail; } void diff --git a/icu4c/source/test/intltest/restsnew.cpp b/icu4c/source/test/intltest/restsnew.cpp index 1bdfa2140781..a7bbf7717d9b 100644 --- a/icu4c/source/test/intltest/restsnew.cpp +++ b/icu4c/source/test/intltest/restsnew.cpp @@ -1051,7 +1051,7 @@ NewResourceBundleTest::testTag(const char* frag, CONFIRM_EQ(count, tag_count); } - return static_cast(failOrig == fail); + return failOrig == fail; } void diff --git a/icu4c/source/test/intltest/usettest.cpp b/icu4c/source/test/intltest/usettest.cpp index 18320f928fd7..a53e813ad2f7 100644 --- a/icu4c/source/test/intltest/usettest.cpp +++ b/icu4c/source/test/intltest/usettest.cpp @@ -2135,13 +2135,13 @@ UBool UnicodeSetTest::checkEqual( UnicodeString source; s.toPattern(source, true); UnicodeString result; t.toPattern(result, true); if (s != t) { - intlTest.errln((UnicodeString)"FAIL: " + message + intlTest.errln(UnicodeString("FAIL: ") + message + "\nsource = " + source + "\nresult = " + result ); return false; } else { - intlTest.logln((UnicodeString)"Ok: " + message + intlTest.logln(UnicodeString("Ok: ") + message + "\nsource = " + source + "\nresult = " + result ); @@ -2530,7 +2530,7 @@ class UnicodeSetWithStrings { } UBool hasStrings() const { - return static_cast(stringsLength > 0); + return stringsLength > 0; } UBool hasStringsWithSurrogates() const { diff --git a/icu4c/source/test/intltest/ustrtest.cpp b/icu4c/source/test/intltest/ustrtest.cpp index ae371f68acc4..5df9d8e1fd44 100644 --- a/icu4c/source/test/intltest/ustrtest.cpp +++ b/icu4c/source/test/intltest/ustrtest.cpp @@ -2439,11 +2439,11 @@ void UnicodeStringTest::TestU16StringView() { UnicodeString aliasFromSV = UnicodeString::readOnlyAlias(sv16); assertTrue("aliasFromSV pointer alias", aliasFromSV.getBuffer() == sv16.data()); - assertEquals("aliasFromSV length", (int32_t)sv16.length(), aliasFromSV.length()); + assertEquals("aliasFromSV length", static_cast(sv16.length()), aliasFromSV.length()); UnicodeString aliasFromStr = UnicodeString::readOnlyAlias(str16); assertTrue("aliasFromStr pointer alias", aliasFromStr.getBuffer() == str16.data()); - assertEquals("aliasFromStr length", (int32_t)str16.length(), aliasFromStr.length()); + assertEquals("aliasFromStr length", static_cast(str16.length()), aliasFromStr.length()); UnicodeString aliasFromUStr = UnicodeString::readOnlyAlias(ustr); assertTrue("aliasFromUStr pointer alias", aliasFromUStr.getBuffer() == ustr.getBuffer()); @@ -2494,7 +2494,7 @@ void UnicodeStringTest::TestU16StringView() { // Convert UnicodeString to string view. std::u16string_view sv16FromUniStr(any); assertTrue("sv16FromUniStr buffer alias", sv16FromUniStr.data() == any.getBuffer()); - assertEquals("sv16FromUniStr length", any.length(), (int32_t)sv16FromUniStr.length()); + assertEquals("sv16FromUniStr length", any.length(), static_cast(sv16FromUniStr.length())); // Just to show convenience: Convert UnicodeString to string view, then to std string. std::u16string str16FromUniStr(any); diff --git a/icu4c/source/test/intltest/utxttest.cpp b/icu4c/source/test/intltest/utxttest.cpp index 66eb4eedb975..0293a6ca7170 100644 --- a/icu4c/source/test/intltest/utxttest.cpp +++ b/icu4c/source/test/intltest/utxttest.cpp @@ -1516,7 +1516,7 @@ void UTextTest::Ticket10983() { void UTextTest::Ticket12130() { UErrorCode status = U_ZERO_ERROR; - + const char *text8 = "Fundamentally, computers just deal with numbers. They store letters and other characters " "by assigning a number for each one. Before Unicode was invented, there were hundreds " @@ -1549,7 +1549,7 @@ void UTextTest::Ticket12130() { if (expectedni != ni) { errln("%s:%d utext_getNativeIndex() expected %d, got %d", __FILE__, __LINE__, expectedni, ni); } - if (0 != str.tempSubString(startIdx, 20).compare(extractBuffer)) { + if (0 != str.tempSubString(startIdx, 20).compare(extractBuffer)) { errln("%s:%d utext_extract() failed. expected \"%s\", got \"%s\"", __FILE__, __LINE__, CStr(str.tempSubString(startIdx, 20))(), CStr(UnicodeString(extractBuffer))()); } @@ -1558,7 +1558,7 @@ void UTextTest::Ticket12130() { // Similar utext extract, this time with the string length provided to the UText in advance, // and a buffer of larger than required capacity. - + utext_openUChars(&ut, ustr, str.length(), &status); for (int32_t startIdx = 0; startIdxstart<=index<=chunk->limit. * @return Chunk-relative UTF-16 offset corresponding to the specified native * index. @@ -1938,7 +1938,6 @@ utext_openUChar32s(UText *ut, const UChar32 *s, int64_t length, const char16_t * } - void UTextTest::AccessChangesChunkSize() { UErrorCode status = U_ZERO_ERROR; UText ut = UTEXT_INITIALIZER; @@ -1960,43 +1959,43 @@ void UTextTest::AccessChangesChunkSize() { ut.pFuncs = &textFuncs; // do test - const OffsetAndChar *testEntryPtr = testAccessEntries; - int32_t testCount = UPRV_LENGTHOF(testAccessEntries); - for (; testCount-- > 0; testEntryPtr++) { - utext_setNativeIndex(&ut, testEntryPtr->nativeOffset); - int64_t beforeOffset = utext_getNativeIndex(&ut); - UChar32 uchar = utext_current32(&ut); - int64_t afterOffset = utext_getNativeIndex(&ut); - if (uchar != testEntryPtr->expectChar || afterOffset != beforeOffset) { - errln("utext_current32 unexpected behavior for u16, test case %lld: expected char %04X at offset %lld, got %04X at %lld;\n" - "chunkNativeStart %lld chunkNativeLimit %lld nativeIndexingLimit %d chunkLength %d chunkOffset %d", - static_cast(testEntryPtr - testAccessEntries), testEntryPtr->expectChar, beforeOffset, uchar, afterOffset, - ut.chunkNativeStart, ut.chunkNativeLimit, ut.nativeIndexingLimit, ut.chunkLength, ut.chunkOffset); - } - } - utext_close(&ut); - - ut = UTEXT_INITIALIZER; - utext_openUChar32s(&ut, testAccess32Text, UPRV_LENGTHOF(testAccess32Text), testAccessText, &status); + const OffsetAndChar *testEntryPtr = testAccessEntries; + int32_t testCount = UPRV_LENGTHOF(testAccessEntries); + for (; testCount-- > 0; testEntryPtr++) { + utext_setNativeIndex(&ut, testEntryPtr->nativeOffset); + int64_t beforeOffset = utext_getNativeIndex(&ut); + UChar32 uchar = utext_current32(&ut); + int64_t afterOffset = utext_getNativeIndex(&ut); + if (uchar != testEntryPtr->expectChar || afterOffset != beforeOffset) { + errln("utext_current32 unexpected behavior for u16, test case %lld: expected char %04X at offset %lld, got %04X at %lld;\n" + "chunkNativeStart %lld chunkNativeLimit %lld nativeIndexingLimit %d chunkLength %d chunkOffset %d", + static_cast(testEntryPtr - testAccessEntries), testEntryPtr->expectChar, beforeOffset, uchar, afterOffset, + ut.chunkNativeStart, ut.chunkNativeLimit, ut.nativeIndexingLimit, ut.chunkLength, ut.chunkOffset); + } + } + utext_close(&ut); + + ut = UTEXT_INITIALIZER; + utext_openUChar32s(&ut, testAccess32Text, UPRV_LENGTHOF(testAccess32Text), testAccessText, &status); if (U_FAILURE(status)) { errln("utext_openUChar32s failed: %s", u_errorName(status)); return; } // do test - testEntryPtr = testAccess32Entries; - testCount = UPRV_LENGTHOF(testAccess32Entries); - for (; testCount-- > 0; testEntryPtr++) { - utext_setNativeIndex(&ut, testEntryPtr->nativeOffset); - int64_t beforeOffset = utext_getNativeIndex(&ut); - UChar32 uchar = utext_current32(&ut); - int64_t afterOffset = utext_getNativeIndex(&ut); - if (uchar != testEntryPtr->expectChar || afterOffset != beforeOffset) { - errln("utext_current32 unexpected behavior for u32, test case %lld: expected char %04X at offset %lld, got %04X at %lld;\n" - "chunkNativeStart %lld chunkNativeLimit %lld nativeIndexingLimit %d chunkLength %d chunkOffset %d", - static_cast(testEntryPtr - testAccess32Entries), testEntryPtr->expectChar, beforeOffset, uchar, afterOffset, - ut.chunkNativeStart, ut.chunkNativeLimit, ut.nativeIndexingLimit, ut.chunkLength, ut.chunkOffset); - } - } - utext_close(&ut); + testEntryPtr = testAccess32Entries; + testCount = UPRV_LENGTHOF(testAccess32Entries); + for (; testCount-- > 0; testEntryPtr++) { + utext_setNativeIndex(&ut, testEntryPtr->nativeOffset); + int64_t beforeOffset = utext_getNativeIndex(&ut); + UChar32 uchar = utext_current32(&ut); + int64_t afterOffset = utext_getNativeIndex(&ut); + if (uchar != testEntryPtr->expectChar || afterOffset != beforeOffset) { + errln("utext_current32 unexpected behavior for u32, test case %lld: expected char %04X at offset %lld, got %04X at %lld;\n" + "chunkNativeStart %lld chunkNativeLimit %lld nativeIndexingLimit %d chunkLength %d chunkOffset %d", + static_cast(testEntryPtr - testAccess32Entries), testEntryPtr->expectChar, beforeOffset, uchar, afterOffset, + ut.chunkNativeStart, ut.chunkNativeLimit, ut.nativeIndexingLimit, ut.chunkLength, ut.chunkOffset); + } + } + utext_close(&ut); } diff --git a/icu4c/source/test/perf/unisetperf/draft/bitset.cpp b/icu4c/source/test/perf/unisetperf/draft/bitset.cpp index dc72cf4df237..d720b3827e4b 100644 --- a/icu4c/source/test/perf/unisetperf/draft/bitset.cpp +++ b/icu4c/source/test/perf/unisetperf/draft/bitset.cpp @@ -190,9 +190,9 @@ class BitSet : public UObject, public UnicodeContainable { UBool contains(UChar32 c) const override { if (static_cast(c) <= 0xff) { - return static_cast((latin1Set[c >> 5] & (static_cast(1) << (c & 0x1f))) != 0); + return (latin1Set[c >> 5] & (static_cast(1) << (c & 0x1f))) != 0; } else if (static_cast(c) < 0xffff) { - return static_cast((bits[c >> 6] & (INT64_C(1) << (c & 0x3f))) != 0); + return (bits[c >> 6] & (INT64_C(1) << (c & 0x3f))) != 0; } else { return restSet->contains(c); } diff --git a/icu4c/source/test/perf/unisetperf/draft/trieset.cpp b/icu4c/source/test/perf/unisetperf/draft/trieset.cpp index 9c15179216c1..d5406601fcef 100644 --- a/icu4c/source/test/perf/unisetperf/draft/trieset.cpp +++ b/icu4c/source/test/perf/unisetperf/draft/trieset.cpp @@ -108,9 +108,9 @@ class TrieSet : public UObject, public UnicodeContainable { UBool contains(UChar32 c) const override { if (static_cast(c) <= 0xff) { - return static_cast(latin1[c]); + return latin1[c]; } else if (static_cast(c) < 0xffff) { - return static_cast(UTRIE_GET8_FROM_LEAD(&trie, c)); + return UTRIE_GET8_FROM_LEAD(&trie, c); } else { return restSet->contains(c); } diff --git a/icu4c/source/tools/genrb/parse.cpp b/icu4c/source/tools/genrb/parse.cpp index f0bf9e79a0b4..f487241cc189 100644 --- a/icu4c/source/tools/genrb/parse.cpp +++ b/icu4c/source/tools/genrb/parse.cpp @@ -2137,7 +2137,7 @@ void initParser() } static inline UBool isTable(enum EResourceType type) { - return static_cast(type == RESTYPE_TABLE || type == RESTYPE_TABLE_NO_FALLBACK); + return type == RESTYPE_TABLE || type == RESTYPE_TABLE_NO_FALLBACK; } static enum EResourceType diff --git a/icu4c/source/tools/genrb/rle.c b/icu4c/source/tools/genrb/rle.c index 0025be207e94..68427764aca3 100644 --- a/icu4c/source/tools/genrb/rle.c +++ b/icu4c/source/tools/genrb/rle.c @@ -162,12 +162,12 @@ usArrayToRLEString(const uint16_t* src,int32_t srcLen,uint16_t* buffer, int32_t if (s == runValue && runLength < 0xFFFF){ ++runLength; }else { - buffer = encodeRunShort(buffer,bufLimit, (uint16_t)runValue, runLength,status); + buffer = encodeRunShort(buffer, bufLimit, runValue, runLength, status); runValue = s; runLength = 1; } } - buffer= encodeRunShort(buffer,bufLimit,(uint16_t)runValue, runLength,status); + buffer = encodeRunShort(buffer, bufLimit, runValue, runLength, status); }else{ *status = U_BUFFER_OVERFLOW_ERROR; } diff --git a/icu4c/source/tools/gensprep/store.c b/icu4c/source/tools/gensprep/store.c index f0f4d7844be8..b2cf44d186b3 100644 --- a/icu4c/source/tools/gensprep/store.c +++ b/icu4c/source/tools/gensprep/store.c @@ -233,7 +233,7 @@ static int32_t U_CALLCONV hashEntry(const UHashTok parm) { /* Callback for comparing two entries */ static UBool U_CALLCONV compareEntries(const UHashTok p1, const UHashTok p2) { - return (UBool)(p1.integer != p2.integer); + return p1.integer != p2.integer; } diff --git a/icu4c/source/tools/icupkg/icupkg.cpp b/icu4c/source/tools/icupkg/icupkg.cpp index 45663d413ac4..3da4af745786 100644 --- a/icu4c/source/tools/icupkg/icupkg.cpp +++ b/icu4c/source/tools/icupkg/icupkg.cpp @@ -253,7 +253,7 @@ isPackageName(const char *filename) { int32_t len; len = static_cast(strlen(filename)) - 4; /* -4: subtract the length of ".dat" */ - return static_cast(len > 0 && 0 == strcmp(filename + len, ".dat")); + return len > 0 && 0 == strcmp(filename + len, ".dat"); } /* This line is required by MinGW because it incorrectly globs the arguments. diff --git a/icu4c/source/tools/makeconv/genmbcs.cpp b/icu4c/source/tools/makeconv/genmbcs.cpp index 774cdc6045d1..788fd9f75fb0 100644 --- a/icu4c/source/tools/makeconv/genmbcs.cpp +++ b/icu4c/source/tools/makeconv/genmbcs.cpp @@ -559,7 +559,7 @@ MBCSIsValid(NewConverter *cnvData, const uint8_t *bytes, int32_t length) { MBCSData *mbcsData=(MBCSData *)cnvData; - return (UBool)(1==ucm_countChars(&mbcsData->ucm->states, bytes, length)); + return 1==ucm_countChars(&mbcsData->ucm->states, bytes, length); } U_CDECL_END static UBool @@ -970,7 +970,7 @@ MBCSAddTable(NewConverter *cnvData, UCMTable *table, UConverterStaticData *stati * a sorted table, which makeconv generates when explicit precision * indicators are used. */ - mbcsData->utf8Friendly=utf8Friendly=(UBool)((table->flagsType&UCM_FLAGS_EXPLICIT)!=0); + mbcsData->utf8Friendly = utf8Friendly = (table->flagsType & UCM_FLAGS_EXPLICIT) != 0; if(utf8Friendly) { mbcsData->utf8Max=MBCS_UTF8_MAX; if(SMALL && maxCharLength>1) { diff --git a/icu4c/source/tools/toolutil/package.cpp b/icu4c/source/tools/toolutil/package.cpp index dd4814927833..e58c6648b647 100644 --- a/icu4c/source/tools/toolutil/package.cpp +++ b/icu4c/source/tools/toolutil/package.cpp @@ -1233,7 +1233,7 @@ UBool Package::checkDependencies() { isMissingItems=false; enumDependencies(this, checkDependency); - return static_cast(!isMissingItems); + return !isMissingItems; } void diff --git a/icu4c/source/tools/toolutil/ucm.cpp b/icu4c/source/tools/toolutil/ucm.cpp index 14d73ba5a152..923041a53f60 100644 --- a/icu4c/source/tools/toolutil/ucm.cpp +++ b/icu4c/source/tools/toolutil/ucm.cpp @@ -575,8 +575,8 @@ ucm_checkBaseExt(UCMStates *baseStates, /* check */ result= - checkBaseExtUnicode(baseStates, base, ext, (UBool)(moveTarget!=nullptr), intersectBase)| - checkBaseExtBytes(baseStates, base, ext, (UBool)(moveTarget!=nullptr), intersectBase); + checkBaseExtUnicode(baseStates, base, ext, moveTarget != nullptr, intersectBase) | + checkBaseExtBytes(baseStates, base, ext, moveTarget != nullptr, intersectBase); if(result&HAS_ERRORS) { return false; diff --git a/icu4c/source/tools/tzcode/localtime.c b/icu4c/source/tools/tzcode/localtime.c index 8d84a92ddd2b..d6dd5bef2417 100644 --- a/icu4c/source/tools/tzcode/localtime.c +++ b/icu4c/source/tools/tzcode/localtime.c @@ -1535,7 +1535,7 @@ timesub(const time_t *const timep, const int_fast32_t offset, ip = mon_lengths[isleap(y)]; for (tmp->tm_mon = 0; idays >= ip[tmp->tm_mon]; ++(tmp->tm_mon)) idays -= ip[tmp->tm_mon]; - tmp->tm_mday = (int) (idays + 1); + tmp->tm_mday = idays + 1; tmp->tm_isdst = 0; #ifdef TM_GMTOFF tmp->TM_GMTOFF = offset; diff --git a/icu4j/APIChangeReport.html b/icu4j/APIChangeReport.html index b136de45e90c..67bc10b619f6 100644 --- a/icu4j/APIChangeReport.html +++ b/icu4j/APIChangeReport.html @@ -4,286 +4,224 @@ -ICU4J API Comparison: ICU4J 74 with ICU4J 75 +ICU4J API Comparison: ICU4J 75 with ICU4J 76 -

ICU4J API Comparison: ICU4J 74 with ICU4J 75

+

ICU4J API Comparison: ICU4J 75 with ICU4J 76


-

Removed from ICU4J 74

+

Removed from ICU4J 75

(no API removed)


-

Deprecated or Obsoleted in ICU4J 75

+

Deprecated or Obsoleted in ICU4J 76

(no API obsoleted)


-

Changed in ICU4J 75 (old, new)

+

Changed in ICU4J 76 (old, new)

(no API changed)


-

Promoted to stable in ICU4J 75

+

Promoted to stable in ICU4J 76

-

Package com.ibm.icu.text

-
    -
  • (stable) public interface PersonName
  • -
  • (stable) public class PersonNameFormatter
  • -
  • (stable) public static class PersonNameFormatter.Builder
  • -
  • (stable) public class SimplePersonName
  • -
  • (stable) public static class SimplePersonName.Builder
  • -
  • (stable) public static enum PersonName.FieldModifier
  • -
  • (stable) public static enum PersonName.NameField
  • -
  • (stable) public static enum PersonName.PreferredOrder
  • -
  • (stable) public static enum PersonNameFormatter.DisplayOrder
  • -
  • (stable) public static enum PersonNameFormatter.Formality
  • -
  • (stable) public static enum PersonNameFormatter.Length
  • -
  • (stable) public static enum PersonNameFormatter.Usage
  • -PersonName.FieldModifier +

    Package com.ibm.icu.lang

      -
    • (stable) public static PersonName.FieldModifier forString(java.lang.String)
    • -
    • (stable) public java.lang.String toString()
    • -
    • (stable) public static final PersonName.FieldModifier ALL_CAPS
    • -
    • (stable) public static final PersonName.FieldModifier CORE
    • -
    • (stable) public static final PersonName.FieldModifier INFORMAL
    • -
    • (stable) public static final PersonName.FieldModifier INITIAL
    • -
    • (stable) public static final PersonName.FieldModifier INITIAL_CAP
    • -
    • (stable) public static final PersonName.FieldModifier MONOGRAM
    • -
    • (stable) public static final PersonName.FieldModifier PREFIX
    • -
    -PersonName.NameField -
      -
    • (stable) public java.lang.String toString()
    • -
    • (stable) public static final PersonName.NameField CREDENTIALS
    • -
    • (stable) public static final PersonName.NameField GENERATION
    • -
    • (stable) public static final PersonName.NameField GIVEN
    • -
    • (stable) public static final PersonName.NameField GIVEN2
    • -
    • (stable) public static final PersonName.NameField SURNAME
    • -
    • (stable) public static final PersonName.NameField SURNAME2
    • -
    • (stable) public static final PersonName.NameField TITLE
    • -
    -PersonName.PreferredOrder -
      -
    • (stable) public static final PersonName.PreferredOrder DEFAULT
    • -
    • (stable) public static final PersonName.PreferredOrder GIVEN_FIRST
    • -
    • (stable) public static final PersonName.PreferredOrder SURNAME_FIRST
    • -
    -PersonNameFormatter.DisplayOrder +UProperty
      -
    • (stable) public static final PersonNameFormatter.DisplayOrder DEFAULT
    • -
    • (stable) public static final PersonNameFormatter.DisplayOrder SORTING
    • +
    • (stable) public static final int IDS_UNARY_OPERATOR
    • +
    • (stable) public static final int ID_COMPAT_MATH_CONTINUE
    • +
    • (stable) public static final int ID_COMPAT_MATH_START
    -PersonNameFormatter.Formality -
      -
    • (stable) public static final PersonNameFormatter.Formality FORMAL
    • -
    • (stable) public static final PersonNameFormatter.Formality INFORMAL
    -PersonNameFormatter.Length + +

    Package com.ibm.icu.number

      -
    • (stable) public static final PersonNameFormatter.Length LONG
    • -
    • (stable) public static final PersonNameFormatter.Length MEDIUM
    • -
    • (stable) public static final PersonNameFormatter.Length SHORT
    • -
    -PersonNameFormatter.Usage +LocalizedNumberFormatter
      -
    • (stable) public static final PersonNameFormatter.Usage ADDRESSING
    • -
    • (stable) public static final PersonNameFormatter.Usage MONOGRAM
    • -
    • (stable) public static final PersonNameFormatter.Usage REFERRING
    • +
    • (stable) public UnlocalizedNumberFormatter withoutLocale()
    -UnicodeSet +LocalizedNumberRangeFormatter
      -
    • (stable) public static final int SIMPLE_CASE_INSENSITIVE
    • +
    • (stable) public UnlocalizedNumberRangeFormatter withoutLocale()
-

Package com.ibm.icu.util

+

Package com.ibm.icu.text

    -MeasureUnit +Normalizer2
      -
    • (stable) public static final MeasureUnit BEAUFORT
    • -
    +
  • (stable) public static Normalizer2 getNFKCSimpleCasefoldInstance()
- - -
-

Added in ICU4J 75

- -

Package com.ibm.icu.lang

-
    -
  • (draft) public static enum UCharacter.IdentifierStatus
  • -
  • (draft) public static enum UCharacter.IdentifierType
  • -UCharacter +PersonName.FieldModifier
      -
    • (draft) public static final int getIdentifierTypes(int, java.util.EnumSet<UCharacter.IdentifierType>)
    • -
    • (draft) public static final boolean hasIdentifierType(int, UCharacter.IdentifierType)
    • +
    • (stable) public static final PersonName.FieldModifier GENITIVE
    • +
    • (stable) public static final PersonName.FieldModifier VOCATIVE
    -UCharacter.IdentifierStatus +PersonNameFormatter.DisplayOrder
      -
    • (draft) public static final UCharacter.IdentifierStatus ALLOWED
    • -
    • (draft) public static final UCharacter.IdentifierStatus RESTRICTED
    • +
    • (stable) public static final PersonNameFormatter.DisplayOrder FORCE_GIVEN_FIRST
    • +
    • (stable) public static final PersonNameFormatter.DisplayOrder FORCE_SURNAME_FIRST
    -UCharacter.IdentifierType +PersonNameFormatter.Formality
      -
    • (draft) public static final UCharacter.IdentifierType DEFAULT_IGNORABLE
    • -
    • (draft) public static final UCharacter.IdentifierType DEPRECATED
    • -
    • (draft) public static final UCharacter.IdentifierType EXCLUSION
    • -
    • (draft) public static final UCharacter.IdentifierType INCLUSION
    • -
    • (draft) public static final UCharacter.IdentifierType LIMITED_USE
    • -
    • (draft) public static final UCharacter.IdentifierType NOT_CHARACTER
    • -
    • (draft) public static final UCharacter.IdentifierType NOT_NFKC
    • -
    • (draft) public static final UCharacter.IdentifierType NOT_XID
    • -
    • (draft) public static final UCharacter.IdentifierType OBSOLETE
    • -
    • (draft) public static final UCharacter.IdentifierType RECOMMENDED
    • -
    • (draft) public static final UCharacter.IdentifierType TECHNICAL
    • -
    • (draft) public static final UCharacter.IdentifierType UNCOMMON_USE
    • +
    • (stable) public static final PersonNameFormatter.Formality DEFAULT
    -UProperty +PersonNameFormatter.Length
      -
    • (draft) public static final int IDENTIFIER_STATUS
    • -
    • (draft) public static final int IDENTIFIER_TYPE
    • +
    • (stable) public static final PersonNameFormatter.Length DEFAULT
    -UScript +SpoofChecker
      -
    • (stable) public static final int ARABIC_NASTALIQ
    • +
    • (stable) public int areConfusable(int, java.lang.CharSequence, java.lang.CharSequence)
    • +
    • (stable) public java.lang.String getBidiSkeleton(int, java.lang.CharSequence)
-

Package com.ibm.icu.message2

-
    -MFDataModel.Attribute -
      -
    • (draft) public final java.lang.String name
    • -
    • (draft) public final MFDataModel.LiteralOrVariableRef value
    • -
    -MFDataModel.CatchallKey -
      -
    • (draft) public MFDataModel.CatchallKey()
    • -
    -MFDataModel.FunctionAnnotation -
      -
    • (draft) public final java.lang.String name
    • -
    • (draft) public final java.util.Map<java.lang.String, MFDataModel.Option> options
    • -
    -MFDataModel.FunctionExpression -
      -
    • (draft) public final MFDataModel.FunctionAnnotation annotation
    • -
    • (draft) public final java.util.List<MFDataModel.Attribute> attributes
    • -
    -MFDataModel.InputDeclaration -
      -
    • (draft) public final java.lang.String name
    • -
    • (draft) public final MFDataModel.VariableExpression value
    • -
    -MFDataModel.Literal +

    Package com.ibm.icu.util

      -
    • (draft) public final java.lang.String value
    • -
    -MFDataModel.LiteralExpression +Calendar
      -
    • (draft) public final MFDataModel.Annotation annotation
    • -
    • (draft) public final MFDataModel.Literal arg
    • -
    • (draft) public final java.util.List<MFDataModel.Attribute> attributes
    • +
    • (stable) public static final int ORDINAL_MONTH
    • +
    • (stable) public java.lang.String getTemporalMonthCode()
    • +
    • (stable) public boolean inTemporalLeapYear()
    • +
    • (stable) public void setTemporalMonthCode(java.lang.String)
    -MFDataModel.LocalDeclaration +ChineseCalendar
      -
    • (draft) public final java.lang.String name
    • -
    • (draft) public final MFDataModel.Expression value
    • +
    • (stable) public java.lang.String getTemporalMonthCode()
    • +
    • (stable) public boolean inTemporalLeapYear()
    • +
    • (stable) public void setTemporalMonthCode(java.lang.String)
    -MFDataModel.Markup +HebrewCalendar
      -
    • (draft) public final java.util.List<MFDataModel.Attribute> attributes
    • -
    • (draft) public final MFDataModel.Markup.Kind kind
    • -
    • (draft) public final java.lang.String name
    • -
    • (draft) public final java.util.Map<java.lang.String, MFDataModel.Option> options
    • +
    • (stable) public java.lang.String getTemporalMonthCode()
    • +
    • (stable) public boolean inTemporalLeapYear()
    • +
    • (stable) public void setTemporalMonthCode(java.lang.String)
    -MFDataModel.Option +IslamicCalendar
      -
    • (draft) public final java.lang.String name
    • -
    • (draft) public final MFDataModel.LiteralOrVariableRef value
    • +
    • (stable) public boolean inTemporalLeapYear()
    -MFDataModel.Pattern +MeasureUnit
      -
    • (draft) public final java.util.List<MFDataModel.PatternPart> parts
    • +
    • (stable) public static final MeasureUnit GASOLINE_ENERGY_DENSITY
    -MFDataModel.PatternMessage +TimeZone
      -
    • (draft) public final java.util.List<MFDataModel.Declaration> declarations
    • -
    • (draft) public final MFDataModel.Pattern pattern
    • +
    • (stable) public static java.lang.String getIanaID(java.lang.String)
    -MFDataModel.SelectMessage -
      -
    • (draft) public final java.util.List<MFDataModel.Declaration> declarations
    • -
    • (draft) public final java.util.List<MFDataModel.Expression> selectors
    • -
    • (draft) public final java.util.List<MFDataModel.Variant> variants
    -MFDataModel.StringPart + + +
    +

    Added in ICU4J 76

    + +

    Package com.ibm.icu.lang

      -
    • (draft) public final java.lang.String value
    • +
    • (draft) public static enum UCharacter.IndicConjunctBreak
    • +UCharacter.IndicConjunctBreak +
        +
      • (draft) public static final UCharacter.IndicConjunctBreak CONSONANT
      • +
      • (draft) public static final UCharacter.IndicConjunctBreak EXTEND
      • +
      • (draft) public static final UCharacter.IndicConjunctBreak LINKER
      • +
      • (draft) public static final UCharacter.IndicConjunctBreak NONE
      • +
      +UCharacter.IndicSyllabicCategory +
        +
      • (stable) public static final int REORDERING_KILLER
      • +
      +UCharacter.JoiningGroup +
        +
      • (stable) public static final int KASHMIRI_YEH
      • +
      +UCharacter.UnicodeBlock +
        +
      • (stable) public static final UCharacter.UnicodeBlock EGYPTIAN_HIEROGLYPHS_EXTENDED_A
      • +
      • (stable) public static final int EGYPTIAN_HIEROGLYPHS_EXTENDED_A_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock GARAY
      • +
      • (stable) public static final int GARAY_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock GURUNG_KHEMA
      • +
      • (stable) public static final int GURUNG_KHEMA_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock KIRAT_RAI
      • +
      • (stable) public static final int KIRAT_RAI_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock MYANMAR_EXTENDED_C
      • +
      • (stable) public static final int MYANMAR_EXTENDED_C_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock OL_ONAL
      • +
      • (stable) public static final int OL_ONAL_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock SUNUWAR
      • +
      • (stable) public static final int SUNUWAR_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock SYMBOLS_FOR_LEGACY_COMPUTING_SUPPLEMENT
      • +
      • (stable) public static final int SYMBOLS_FOR_LEGACY_COMPUTING_SUPPLEMENT_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock TODHRI
      • +
      • (stable) public static final int TODHRI_ID
      • +
      • (stable) public static final UCharacter.UnicodeBlock TULU_TIGALARI
      • +
      • (stable) public static final int TULU_TIGALARI_ID
      -MFDataModel.UnsupportedAnnotation +UProperty
        -
      • (draft) public final java.lang.String source
      • +
      • (draft) public static final int INDIC_CONJUNCT_BREAK
      • +
      • (draft) public static final int MODIFIER_COMBINING_MARK
      -MFDataModel.UnsupportedExpression +UScript
        -
      • (draft) public final MFDataModel.UnsupportedAnnotation annotation
      • -
      • (draft) public final java.util.List<MFDataModel.Attribute> attributes
      • +
      • (stable) public static final int GARAY
      • +
      • (stable) public static final int GURUNG_KHEMA
      • +
      • (stable) public static final int KIRAT_RAI
      • +
      • (stable) public static final int OL_ONAL
      • +
      • (stable) public static final int SUNUWAR
      • +
      • (stable) public static final int TODHRI
      • +
      • (stable) public static final int TULU_TIGALARI
      -MFDataModel.UnsupportedStatement -
        -
      • (draft) public final java.lang.String body
      • -
      • (draft) public final java.util.List<MFDataModel.Expression> expressions
      • -
      • (draft) public final java.lang.String keyword
      -MFDataModel.VariableExpression + +

      Package com.ibm.icu.text

        -
      • (draft) public final MFDataModel.Annotation annotation
      • -
      • (draft) public final MFDataModel.VariableRef arg
      • -
      • (draft) public final java.util.List<MFDataModel.Attribute> attributes
      • -
      -MFDataModel.VariableRef +DateFormat
        -
      • (draft) public final java.lang.String name
      • +
      • (draft) public final java.lang.String format(java.time.temporal.Temporal)
      • +
      • (draft) public java.lang.StringBuffer format(java.time.temporal.Temporal, java.lang.StringBuffer, java.text.FieldPosition)
      -MFDataModel.Variant +DateIntervalFormat
        -
      • (draft) public final java.util.List<MFDataModel.LiteralOrCatchallKey> keys
      • -
      • (draft) public final MFDataModel.Pattern value
      • +
      • (draft) public final java.lang.StringBuffer format(java.time.temporal.Temporal, java.time.temporal.Temporal, java.lang.StringBuffer, java.text.FieldPosition)
      • +
      • (draft) public DateIntervalFormat.FormattedDateInterval formatToValue(java.time.temporal.Temporal, java.time.temporal.Temporal)
      -MFParseException +RelativeDateTimeFormatter.RelativeUnit
        -
      • (draft) public MFParseException(java.lang.String, int)
      • -
      • (draft) public java.lang.String getMessage()
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit FRIDAYS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit MONDAYS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit QUARTERS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit SATURDAYS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit SUNDAYS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit THURSDAYS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit TUESDAYS
      • +
      • (draft) public static final RelativeDateTimeFormatter.RelativeUnit WEDNESDAYS
      -MFSerializer +UnicodeSet
        -
      • (draft) public MFSerializer()
      • +
      • (draft) public java.util.stream.IntStream codePointStream()
      • +
      • (draft) public java.lang.Iterable<java.lang.Integer> codePoints()
      • +
      • (draft) public java.util.stream.Stream<UnicodeSet.EntryRange> rangeStream()
      • +
      • (draft) public java.util.stream.Stream<java.lang.String> stream()
      • +
      • (draft) public java.util.stream.Stream<java.lang.String> stringStream()
    -

    Package com.ibm.icu.number

    -
      -LocalizedNumberFormatter +

      Package com.ibm.icu.util

        -
      • (draft) public UnlocalizedNumberFormatter withoutLocale()
      • -
      -LocalizedNumberRangeFormatter +MeasureUnit
        -
      • (draft) public UnlocalizedNumberRangeFormatter withoutLocale()
      • +
      • (draft) public static final MeasureUnit LIGHT_SPEED
      • +
      • (draft) public static final MeasureUnit NIGHT
      • +
      • (draft) public static final MeasureUnit PORTION_PER_1E9
      -
    - -

    Package com.ibm.icu.util

    -
      -MeasureUnit.MeasurePrefix +VersionInfo
        -
      • (draft) public static final MeasureUnit.MeasurePrefix QUECTO
      • -
      • (draft) public static final MeasureUnit.MeasurePrefix QUETTA
      • -
      • (draft) public static final MeasureUnit.MeasurePrefix RONNA
      • -
      • (draft) public static final MeasureUnit.MeasurePrefix RONTO
      • +
      • (stable) public static final VersionInfo UNICODE_16_0

    -

    Contents generated by ReportAPI tool on Mon Mar 25 13:11:50 EDT 2024
    © 2024 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html

    +

    Contents generated by ReportAPI tool on Wed Sep 18 16:18:21 PDT 2024
    © 2024 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html

    diff --git a/icu4j/demos/pom.xml b/icu4j/demos/pom.xml index 2baf924b834a..2990cca0a024 100644 --- a/icu4j/demos/pom.xml +++ b/icu4j/demos/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT demos diff --git a/icu4j/main/charset/pom.xml b/icu4j/main/charset/pom.xml index 517f8b54e5de..7b705d9a1fbc 100644 --- a/icu4j/main/charset/pom.xml +++ b/icu4j/main/charset/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/collate/pom.xml b/icu4j/main/collate/pom.xml index 9b0bcdd2b926..0cdfd25e6d06 100644 --- a/icu4j/main/collate/pom.xml +++ b/icu4j/main/collate/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/common_tests/pom.xml b/icu4j/main/common_tests/pom.xml index 381b36f331db..e5b051c14c5e 100644 --- a/icu4j/main/common_tests/pom.xml +++ b/icu4j/main/common_tests/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/core/pom.xml b/icu4j/main/core/pom.xml index 09a223de01ea..5385b791fdd1 100644 --- a/icu4j/main/core/pom.xml +++ b/icu4j/main/core/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/impl/JavaTimeConverters.java b/icu4j/main/core/src/main/java/com/ibm/icu/impl/JavaTimeConverters.java index eaa6b01af0a9..95ef822bfbbb 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/impl/JavaTimeConverters.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/impl/JavaTimeConverters.java @@ -5,7 +5,6 @@ import static java.time.temporal.ChronoField.MILLI_OF_SECOND; -import java.time.Clock; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; @@ -34,7 +33,7 @@ * *

    * The class includes methods for converting various temporal types, such as - * {@link Instant}, {@link ZonedDateTime}, {@link OffsetTime}, {@link OffsetDateTime}, {@link LocalTime}, + * {@link ZonedDateTime}, {@link OffsetTime}, {@link OffsetDateTime}, {@link LocalTime}, * {@link ChronoLocalDate}, and {@link ChronoLocalDateTime}, to {@link Calendar} instances. * *

    @@ -52,47 +51,6 @@ private JavaTimeConverters() { // Prevent instantiation, making this an utility class } - /** - * Converts the current instant from a {@link Clock} to a {@link Calendar}. - * - *

    - * This method creates a {@link Calendar} instance that represents the current - * instant as provided by the specified {@link Clock}. - * - * @param clock The {@link Clock} providing the current instant. - * @return A {@link Calendar} instance representing the current instant as - * provided by the specified {@link Clock}. - * - * @deprecated This API is ICU internal only. - */ - @Deprecated - public static Calendar temporalToCalendar(Clock clock) { - long epochMillis = clock.millis(); - String timeZone = clock.getZone().getId(); - TimeZone icuTimeZone = TimeZone.getTimeZone(timeZone); - return millisToCalendar(epochMillis, icuTimeZone); - } - - /** - * Converts an {@link Instant} to a {@link Calendar}. - * - *

    - * This method creates a {@link Calendar} instance that represents the same - * point in time as the specified {@link Instant}. The resulting - * {@link Calendar} will be in the default time zone of the JVM. - * - * @param instant The {@link Instant} to convert. - * @return A {@link Calendar} instance representing the same point in time as - * the specified {@link Instant}. - * - * @deprecated This API is ICU internal only. - */ - @Deprecated - public static Calendar temporalToCalendar(Instant instant) { - long epochMillis = instant.toEpochMilli(); - return millisToCalendar(epochMillis, TimeZone.GMT_ZONE); - } - /** * Converts a {@link ZonedDateTime} to a {@link Calendar}. * @@ -232,10 +190,9 @@ public static Calendar temporalToCalendar(LocalDateTime dateTime) { */ @Deprecated public static Calendar temporalToCalendar(Temporal temp) { - if (temp instanceof Clock) { - return temporalToCalendar((Clock) temp); - } else if (temp instanceof Instant) { - return temporalToCalendar((Instant) temp); + if (temp instanceof Instant) { + throw new IllegalArgumentException("java.time.Instant cannot be formatted," + + " it does not have enough information"); } else if (temp instanceof ZonedDateTime) { return temporalToCalendar((ZonedDateTime) temp); } else if (temp instanceof OffsetDateTime) { @@ -253,8 +210,8 @@ public static Calendar temporalToCalendar(Temporal temp) { } else if (temp instanceof ChronoLocalDateTime) { return temporalToCalendar((ChronoLocalDateTime) temp); } else { - System.out.println("WTF is " + temp.getClass()); - return null; + throw new IllegalArgumentException("This type cannot be formatted: " + + temp.getClass().getName()); } } diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/DateTimeFormatterFactory.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/DateTimeFormatterFactory.java index 38e5863fde4c..573c4ba3b5bd 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/DateTimeFormatterFactory.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/DateTimeFormatterFactory.java @@ -3,7 +3,6 @@ package com.ibm.icu.message2; -import java.time.Clock; import java.time.temporal.Temporal; import java.util.Calendar; import java.util.Locale; @@ -352,12 +351,10 @@ public FormattedPlaceholder format(Object toFormat, Map variable return new FormattedPlaceholder( toFormat, new PlainStringFormattedValue("{|" + toFormat + "|}")); } - } else if (toFormat instanceof Clock) { - toFormat = JavaTimeConverters.temporalToCalendar((Clock) toFormat); } else if (toFormat instanceof Temporal) { toFormat = JavaTimeConverters.temporalToCalendar((Temporal) toFormat); } - // Not an else-if here, because the `Clock` & `Temporal` conditions before make `toFormat` a `Calendar` + // Not an else-if here, because the `Temporal` conditions before make `toFormat` a `Calendar` if (toFormat instanceof Calendar) { TimeZone tz = ((Calendar) toFormat).getTimeZone(); long milis = ((Calendar) toFormat).getTimeInMillis(); diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java index ac4f4796d55f..4146a08478a3 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFDataModelFormatter.java @@ -3,7 +3,6 @@ package com.ibm.icu.message2; -import java.time.Clock; import java.time.temporal.Temporal; import java.util.ArrayList; import java.util.Date; @@ -69,7 +68,6 @@ class MFDataModelFormatter { .setDefaultFormatterNameForType(Date.class, "datetime") .setDefaultFormatterNameForType(Calendar.class, "datetime") .setDefaultFormatterNameForType(java.util.Calendar.class, "datetime") - .setDefaultFormatterNameForType(Clock.class, "datetime") .setDefaultFormatterNameForType(Temporal.class, "datetime") // Number formatting diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/DateFormat.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/DateFormat.java index 0bb72bf2ad68..07a90e656487 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/DateFormat.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/DateFormat.java @@ -14,7 +14,6 @@ import java.text.Format; import java.text.ParseException; import java.text.ParsePosition; -import java.time.Clock; import java.time.temporal.Temporal; import java.util.Arrays; import java.util.Date; @@ -633,9 +632,6 @@ public final StringBuffer format(Object obj, StringBuffer toAppendTo, } else if (obj instanceof Number) { return format( new Date(((Number)obj).longValue()), toAppendTo, fieldPosition ); - } else if (obj instanceof Clock) { - return format(JavaTimeConverters.temporalToCalendar((Clock) obj), - toAppendTo, fieldPosition); } else if (obj instanceof Temporal) { return format( (Temporal)obj, toAppendTo, fieldPosition ); } else { diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/MessageFormat.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/MessageFormat.java index 0319294bcf44..6a9a6cc37b82 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/MessageFormat.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/MessageFormat.java @@ -24,7 +24,6 @@ import java.text.Format; import java.text.ParseException; import java.text.ParsePosition; -import java.time.Clock; import java.time.temporal.Temporal; import java.util.ArrayList; import java.util.Date; @@ -1754,9 +1753,6 @@ private void format(int msgStart, PluralSelectorContext pluralNumber, } else if (arg instanceof Calendar) { // format a Calendar if can dest.formatAndAppend(getStockDateFormatter(), arg); - } else if (arg instanceof Clock) { - // format a Clock if can - dest.formatAndAppend(getStockDateFormatter(), arg); } else if (arg instanceof Temporal) { // format a Temporal if can dest.formatAndAppend(getStockDateFormatter(), arg); diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/RelativeDateTimeFormatter.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/RelativeDateTimeFormatter.java index 5183e4a6fe59..d65952424728 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/RelativeDateTimeFormatter.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/RelativeDateTimeFormatter.java @@ -73,8 +73,10 @@ * * *

    - * In the future, we may add more forms, such as abbreviated/short forms - * (3 secs ago), and relative day periods ("yesterday afternoon"), etc. + * The Style parameter allows selection of different length styles: + * LONG ("3 seconds ago"), SHORT ("3 sec. ago"), NARROW ("3s ago"). + * In the future, we may add more forms, such as relative day periods + * ("yesterday afternoon"), etc. * * @stable ICU 53 */ diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/SimpleDateFormat.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/SimpleDateFormat.java index 06bcbf44c9e5..1a6acb8d102f 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/SimpleDateFormat.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/SimpleDateFormat.java @@ -17,7 +17,6 @@ import java.text.FieldPosition; import java.text.Format; import java.text.ParsePosition; -import java.time.Clock; import java.time.temporal.Temporal; import java.util.ArrayList; import java.util.Date; @@ -3920,8 +3919,6 @@ public AttributedCharacterIterator formatToCharacterIterator(Object obj) { calendar.setTime((Date)obj); } else if (obj instanceof Number) { calendar.setTimeInMillis(((Number)obj).longValue()); - } else if (obj instanceof Clock) { - cal = JavaTimeConverters.temporalToCalendar((Clock) obj); } else if (obj instanceof Temporal) { cal = JavaTimeConverters.temporalToCalendar((Temporal) obj); } else { diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/util/TimeZone.java b/icu4j/main/core/src/main/java/com/ibm/icu/util/TimeZone.java index aec4610f4b68..5e6c3be758e0 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/util/TimeZone.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/util/TimeZone.java @@ -1191,7 +1191,7 @@ public static String getCanonicalID(String id, boolean[] isSystemID) { */ public static String getIanaID(String id) { String ianaId = TimeZone.UNKNOWN_ZONE_ID; - if (id == null || id.length() == 0 || id.equals(TimeZone.UNKNOWN_ZONE)) { + if (id == null || id.length() == 0 || id.equals(TimeZone.UNKNOWN_ZONE_ID)) { return ianaId; } String tmpIanaId = ZoneMeta.getIanaID(id); diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/util/ULocale.java b/icu4j/main/core/src/main/java/com/ibm/icu/util/ULocale.java index bb6b32cdd54d..eb570f78c28c 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/util/ULocale.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/util/ULocale.java @@ -4266,9 +4266,17 @@ public static void setDefault(Category category, Locale newLocale) { */ @Deprecated public static class RegionValidateMap { + /** + * @internal Visible For Testing + * @deprecated This API is ICU internal only. + */ public RegionValidateMap() { this.map = Arrays.copyOf(gValidRegionMap, gValidRegionMap.length); } + /** + * @internal Visible For Testing + * @deprecated This API is ICU internal only. + */ public boolean isSet(String region) { int index = value(region); if (index < 0) { @@ -4276,9 +4284,17 @@ public boolean isSet(String region) { } return 0 != (map[index / 32] & (1 << (index % 32))); } + /** + * @internal Visible For Testing + * @deprecated This API is ICU internal only. + */ public boolean equals(RegionValidateMap that) { return Arrays.equals(map, that.map); } + /** + * @internal Visible For Testing + * @deprecated This API is ICU internal only. + */ protected int value(String region) { if (region.matches("[a-zA-Z][a-zA-Z]")) { region = region.toLowerCase(); @@ -4287,6 +4303,10 @@ protected int value(String region) { } return -1; } + /** + * @internal Visible For Testing + * @deprecated This API is ICU internal only. + */ protected int[] map; static private int[] gValidRegionMap = { 0xeedf597c, 0xdeddbdef, 0x15943f3f, 0x0e00d580, @@ -4297,6 +4317,10 @@ protected int value(String region) { 0x00400408, 0x00000001, }; + /** + * @internal Visible For Testing + * @deprecated This API is ICU internal only. + */ public static RegionValidateMap BUILTIN = new RegionValidateMap(); } } diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/util/VersionInfo.java b/icu4j/main/core/src/main/java/com/ibm/icu/util/VersionInfo.java index 912a625ed49a..9abf94ba1554 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/util/VersionInfo.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/util/VersionInfo.java @@ -584,7 +584,7 @@ public int compareTo(VersionInfo other) UNICODE_15_1 = getInstance(15, 1, 0, 0); UNICODE_16_0 = getInstance(16, 0, 0, 0); - ICU_VERSION = getInstance(76, 0, 1, 0); + ICU_VERSION = getInstance(76, 1, 0, 0); ICU_DATA_VERSION = ICU_VERSION; UNICODE_VERSION = UNICODE_16_0; diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeConvertersTest.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeConvertersTest.java index acc278fd7f32..a56699e40e12 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeConvertersTest.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeConvertersTest.java @@ -3,7 +3,6 @@ package com.ibm.icu.dev.test.format; -import java.time.Clock; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; @@ -125,25 +124,10 @@ public void testDateAndTimes() { } - @Test - public void testInstantAndClock() { - // Instant has no time zone, assumes GMT. - EXPECTED_CALENDAR.setTimeZone(TimeZone.GMT_ZONE); + @Test(expected = IllegalArgumentException.class) + public void testInstantFails() { Instant instant = Instant.ofEpochMilli(EXPECTED_CALENDAR.getTimeInMillis()); - Calendar calendar = JavaTimeConverters.temporalToCalendar(instant); - assertCalendarsEquals(EXPECTED_CALENDAR, calendar, DATE_ONLY_FIELDS); - assertCalendarsEquals(EXPECTED_CALENDAR, calendar, TIME_ONLY_FIELDS); - assertEquals("", EXPECTED_CALENDAR.getTimeZone().getID(), calendar.getTimeZone().getID()); - assertEquals("", EXPECTED_CALENDAR.getTimeZone().getRawOffset(), calendar.getTimeZone().getRawOffset()); - // Restore the time zone on the expected calendar - EXPECTED_CALENDAR.setTimeZone(TimeZone.getTimeZone(TIME_ZONE_ID)); - - Clock clock = Clock.fixed(instant, ZoneId.of(TIME_ZONE_ID)); - calendar = JavaTimeConverters.temporalToCalendar(clock); - assertCalendarsEquals(EXPECTED_CALENDAR, calendar, DATE_ONLY_FIELDS); - assertCalendarsEquals(EXPECTED_CALENDAR, calendar, TIME_ONLY_FIELDS); - assertEquals("", EXPECTED_CALENDAR.getTimeZone().getID(), calendar.getTimeZone().getID()); - assertEquals("", EXPECTED_CALENDAR.getTimeZone().getRawOffset(), calendar.getTimeZone().getRawOffset()); + JavaTimeConverters.temporalToCalendar(instant); } // Compare the expected / actual calendar, but using an allowlist diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeFormatTest.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeFormatTest.java index 7f5d8b9a3777..80e4116cb0e6 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeFormatTest.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/format/JavaTimeFormatTest.java @@ -142,15 +142,11 @@ public void testNonGregorianDateFormatting() { } } - @Test - public void testInstantAndClockFormatting() { + @Test(expected = IllegalArgumentException.class) + public void testInstantFormattingFails() { DateFormat formatFromSkeleton = DateFormat.getInstanceForSkeleton("yMMMMd jmsSSSvvvv", Locale.US); - Instant instant = LDT.toInstant(ZoneOffset.UTC); - assertEquals("", "September 27, 2013 at 7:43:56.123 PM Greenwich Mean Time", formatFromSkeleton.format(instant)); - - Clock clock = Clock.fixed(instant, ZoneId.of("America/Los_Angeles")); - assertEquals("", "September 27, 2013 at 12:43:56.123 PM Pacific Time", formatFromSkeleton.format(clock)); + formatFromSkeleton.format(instant); } @Test @@ -208,15 +204,6 @@ public void testMessageFormat() { arguments.put("expDate", LDT.atOffset(ZoneOffset.ofHours(2))); assertEquals("", expectedMf1Result, mf.format(arguments)); assertEquals("", expectedMf2Result, mf2.formatToString(arguments)); - // Instant - Instant instant = LDT.toInstant(ZoneOffset.UTC); - arguments.put("expDate", instant); - assertEquals("", expectedMf1Result, mf.format(arguments)); - assertEquals("", expectedMf2Result, mf2.formatToString(arguments)); - // Clock - arguments.put("expDate", Clock.fixed(instant, ZoneId.of("Europe/Paris"))); - assertEquals("", expectedMf1Result, mf.format(arguments)); - assertEquals("", expectedMf2Result, mf2.formatToString(arguments)); // Test that both JDK and ICU Calendar are recognized as types. arguments.put("expDate", new java.util.GregorianCalendar(2013, 8, 27)); @@ -225,6 +212,31 @@ public void testMessageFormat() { // I filed https://unicode-org.atlassian.net/browse/ICU-22852 // MF2 converts the JDK Calendar to an ICU Calendar, so it works. assertEquals("", expectedMf2Result, mf2.formatToString(arguments)); + + // Make sure that Instant and Clock are not formatted + + // Instant + Instant instant = LDT.toInstant(ZoneOffset.UTC); + arguments.put("expDate", instant); + try { + mf.format(arguments); + fail("Should not be able to format java.time.Instant"); + } catch (IllegalArgumentException ex) { /* expected to throw */ } + try { + mf2.formatToString(arguments); + fail("Should not be able to format java.time.Instant"); + } catch (IllegalArgumentException ex) { /* expected to throw */ } + + // Clock + arguments.put("expDate", Clock.fixed(instant, ZoneId.of("Europe/Paris"))); + try { + mf.format(arguments); + fail("Should not be able to format java.time.Clock"); + } catch (IllegalArgumentException ex) { /* expected to throw */ } + try { + mf2.formatToString(arguments); + fail("Should not be able to format java.time.Clock"); + } catch (IllegalArgumentException ex) { /* expected to throw */ } } @Test diff --git a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java index 4040046903e4..94976a5c9185 100644 --- a/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java +++ b/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java @@ -10,7 +10,7 @@ package com.ibm.icu.dev.test.util; public class DebugUtilitiesData extends Object { - public static final String ICU4C_VERSION="76.0.1"; + public static final String ICU4C_VERSION="76.1"; public static final int UDebugEnumType = 0; public static final int UCalendarDateFields = 1; public static final int UCalendarMonths = 2; diff --git a/icu4j/main/currdata/pom.xml b/icu4j/main/currdata/pom.xml index 7eadaeeb2feb..53a41960b9a9 100644 --- a/icu4j/main/currdata/pom.xml +++ b/icu4j/main/currdata/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/framework/pom.xml b/icu4j/main/framework/pom.xml index 8873acd95b97..832c518e4bfd 100644 --- a/icu4j/main/framework/pom.xml +++ b/icu4j/main/framework/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/icu4j/pom.xml b/icu4j/main/icu4j/pom.xml index be93ead0e7c2..182026251df0 100644 --- a/icu4j/main/icu4j/pom.xml +++ b/icu4j/main/icu4j/pom.xml @@ -9,7 +9,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/langdata/pom.xml b/icu4j/main/langdata/pom.xml index f90a598c44d8..ade5a882f708 100644 --- a/icu4j/main/langdata/pom.xml +++ b/icu4j/main/langdata/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/localespi/pom.xml b/icu4j/main/localespi/pom.xml index 3ec57d041e41..1526e98516c0 100644 --- a/icu4j/main/localespi/pom.xml +++ b/icu4j/main/localespi/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/regiondata/pom.xml b/icu4j/main/regiondata/pom.xml index b1d689827e95..858200ed5988 100644 --- a/icu4j/main/regiondata/pom.xml +++ b/icu4j/main/regiondata/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/main/translit/pom.xml b/icu4j/main/translit/pom.xml index b8f90ee778a8..7219f4bf3835 100644 --- a/icu4j/main/translit/pom.xml +++ b/icu4j/main/translit/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/perf-tests/pom.xml b/icu4j/perf-tests/pom.xml index cdb7fd4c50af..31ab0491de91 100644 --- a/icu4j/perf-tests/pom.xml +++ b/icu4j/perf-tests/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT perf-tests diff --git a/icu4j/pom.xml b/icu4j/pom.xml index c04f14611bbf..844b8d866768 100644 --- a/icu4j/pom.xml +++ b/icu4j/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT pom ${proj-title} (${project.artifactId}) diff --git a/icu4j/releases_tools/shared.sh b/icu4j/releases_tools/shared.sh index 6845762b600b..1b9b39272b2a 100755 --- a/icu4j/releases_tools/shared.sh +++ b/icu4j/releases_tools/shared.sh @@ -5,8 +5,8 @@ export MAVEN_ARGS='--no-transfer-progress' # Version update! -export artifact_version='76.0.1-SNAPSHOT' -export github_rel_version='76_0_1' +export artifact_version='76.1-SNAPSHOT' +export github_rel_version='76rc' export api_report_version='76' export api_report_prev_version='75' export out_dir=target diff --git a/icu4j/samples/pom.xml b/icu4j/samples/pom.xml index 6de776d04d04..910be88c6acf 100644 --- a/icu4j/samples/pom.xml +++ b/icu4j/samples/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT samples diff --git a/icu4j/tools/build/pom.xml b/icu4j/tools/build/pom.xml index c1975788ec82..6113e7e452f7 100644 --- a/icu4j/tools/build/pom.xml +++ b/icu4j/tools/build/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/icu4j/tools/misc/pom.xml b/icu4j/tools/misc/pom.xml index 0e4ffae4ae88..61cd0a9a8416 100644 --- a/icu4j/tools/misc/pom.xml +++ b/icu4j/tools/misc/pom.xml @@ -8,7 +8,7 @@ com.ibm.icu icu4j-root - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT ../../pom.xml diff --git a/tools/cldr/cldr-to-icu/build-icu-data.xml b/tools/cldr/cldr-to-icu/build-icu-data.xml index f9bd00343d06..69bf7f577cb0 100644 --- a/tools/cldr/cldr-to-icu/build-icu-data.xml +++ b/tools/cldr/cldr-to-icu/build-icu-data.xml @@ -61,10 +61,10 @@ - + - + diff --git a/tools/cldr/cldr-to-icu/pom.xml b/tools/cldr/cldr-to-icu/pom.xml index e6feaec84601..0d8f6634dcb5 100644 --- a/tools/cldr/cldr-to-icu/pom.xml +++ b/tools/cldr/cldr-to-icu/pom.xml @@ -83,7 +83,7 @@ com.ibm.icu icu4j - 76.0.1-SNAPSHOT + 76.1-SNAPSHOT