diff --git a/core/src/ldml/ldml_transforms.cpp b/core/src/ldml/ldml_transforms.cpp index 270048ac211..973117f36b9 100644 --- a/core/src/ldml/ldml_transforms.cpp +++ b/core/src/ldml/ldml_transforms.cpp @@ -45,16 +45,16 @@ element::is_uset() const { return (flags & LDML_ELEM_FLAGS_TYPE) == LDML_ELEM_FLAGS_TYPE_USET; } -signed char +reorder_weight element::get_order() const { unsigned char uorder = ((flags & LDML_ELEM_FLAGS_ORDER_MASK) >> LDML_ELEM_FLAGS_ORDER_BITSHIFT); - return (signed char)uorder; + return (reorder_weight)uorder; // unsigned to signed } -signed char +reorder_weight element::get_tertiary() const { unsigned char uorder = ((flags & LDML_ELEM_FLAGS_TERTIARY_MASK) >> LDML_ELEM_FLAGS_TERTIARY_BITSHIFT); - return (signed char)uorder; + return (reorder_weight)uorder; // unsigned to signed } bool @@ -93,19 +93,19 @@ element::dump() const { int reorder_sort_key::compare(const reorder_sort_key &other) const { - int primaryResult = (int)primary - (int)other.primary; - int secondaryResult = (int)secondary - (int)other.secondary; - int tertiaryResult = (int)tertiary - (int)other.tertiary; - int quaternaryResult = (int)quaternary - (int)other.quaternary; + auto primaryResult = primary - other.primary; + auto secondaryResult = secondary - other.secondary; + auto tertiaryResult = tertiary - other.tertiary; + auto quaternaryResult = quaternary - other.quaternary; if (primaryResult) { - return primaryResult; + return (int)primaryResult; } else if (secondaryResult) { - return secondaryResult; + return (int)secondaryResult; } else if (tertiaryResult) { - return tertiaryResult; + return (int)tertiaryResult; } else if (quaternaryResult) { - return quaternaryResult; + return (int)quaternaryResult; } else { // We don't expect to get here. quaternaryResult is the string index, which // should be unequal. @@ -131,8 +131,8 @@ reorder_sort_key::from(const std::u32string &str) { // construct a 'baseline' sort key, that is, in the absence of // any match rules. std::deque keylist; - auto s = str.begin(); // str iterator - size_t c = 0; // str index + auto s = str.begin(); // str iterator + reorder_weight c = 0; // str index for (auto e = str.begin(); e < str.end(); e++, s++, c++) { // primary weight: 0 // seconary weight: c (the string index) @@ -215,9 +215,9 @@ std::deque & element_list::update_sort_key(size_t offset, std::deque &key) const { /** string index */ size_t c = 0; - bool have_last_base = false; - signed char last_base_primary = -1; - signed char last_base_secondary = -1; + bool have_last_base = false; + reorder_weight last_base_primary = -1; + reorder_weight last_base_secondary = -1; for (auto e = begin(); e < end(); e++, c++) { /** position in the key */ auto n = offset + c; @@ -418,7 +418,7 @@ reorder_group::apply(std::u32string &str) const { // recombine into a string by pulling out the 'ch' value // that's in each sortkey element. std::u32string newSuffix; - size_t q = sort_keys.begin()->quaternary; // start with the first quaternary + signed char q = sort_keys.begin()->quaternary; // start with the first quaternary for (auto e = sort_keys.begin(); e < sort_keys.end(); e++, q++) { if (q != e->quaternary) { // something rearranged in this subrange, because the quaternary values are out of order. diff --git a/core/src/ldml/ldml_transforms.hpp b/core/src/ldml/ldml_transforms.hpp index 582a7ba3a99..dd082895744 100644 --- a/core/src/ldml/ldml_transforms.hpp +++ b/core/src/ldml/ldml_transforms.hpp @@ -47,6 +47,11 @@ inline bool uassert_success(const char *file, int line, const char *function, UE using km::core::kmx::SimpleUSet; +/** a reorder weight, such as primary, secondary, etc. */ +typedef signed char reorder_weight; + + + /** * Type of a group */ @@ -71,9 +76,9 @@ class element { /** @returns true if tertiary base bit set */ bool is_tertiary_base() const; /** @returns the primary order */ - signed char get_order() const; + reorder_weight get_order() const; /** @returns the tertiary order */ - signed char get_tertiary() const; + reorder_weight get_tertiary() const; /** @returns raw elem flags */ KMX_DWORD get_flags() const; /** @returns true if matches this character*/ @@ -157,10 +162,10 @@ class transform_group : public std::deque { /** a single char, categorized according to reorder rules*/ struct reorder_sort_key { km_core_usv ch; // the single char value - signed char primary; // primary order value - size_t secondary; // index position - signed char tertiary; // tertiary value, defaults to 0 - size_t quaternary; // index again + reorder_weight primary; // primary order value + reorder_weight secondary; // index position + reorder_weight tertiary; // tertiary value, defaults to 0 + reorder_weight quaternary; // index again bool is_tertiary_base; // remember that this key was a tertiary base /** @returns -1, 0, 1 depending on ordering */ diff --git a/core/tests/unit/ldml/test_transforms.cpp b/core/tests/unit/ldml/test_transforms.cpp index 29357071ac5..fe47f043950 100644 --- a/core/tests/unit/ldml/test_transforms.cpp +++ b/core/tests/unit/ldml/test_transforms.cpp @@ -251,7 +251,7 @@ test_reorder_standalone() { l.update_sort_key(0, keylist); std::cout << __FILE__ << ":" << __LINE__ << " updated sortkey" << std::endl; assert_equal(keylist.size(), 2); - size_t secondary = 0; + reorder_weight secondary = 0; for (auto i = keylist.begin(); i < keylist.end(); i++) { i->dump(); assert_equal(i->secondary, secondary); diff --git a/resources/build/trigger-builds.inc.sh b/resources/build/trigger-builds.inc.sh index cc01b49914f..d0ca586398a 100644 --- a/resources/build/trigger-builds.inc.sh +++ b/resources/build/trigger-builds.inc.sh @@ -81,12 +81,12 @@ function triggerGitHubActionsBuild() { GIT_BASE_REF="$(git rev-parse "${GIT_BUILD_SHA}^")" GIT_EVENT_TYPE="${GITHUB_ACTION}: release@${VERSION_WITH_TAG}" elif [[ $GIT_BRANCH != stable-* ]] && [[ $GIT_BRANCH =~ [0-9]+ ]]; then - GIT_BUILD_SHA="$(git rev-parse "refs/pull/${GIT_BRANCH}/head")" - GIT_EVENT_TYPE="${GITHUB_ACTION}: PR #${GIT_BRANCH}" JSON=$(curl -s "${GITHUB_SERVER}/pulls/${GIT_BRANCH}") + GIT_BUILD_SHA="$(echo "$JSON" | $JQ -r '.head.sha')" + GIT_EVENT_TYPE="${GITHUB_ACTION}: PR #${GIT_BRANCH}" GIT_USER="$(echo "$JSON" | $JQ -r '.user.login')" GIT_BASE_BRANCH="$(echo "$JSON" | $JQ -r '.base.ref')" - GIT_BASE_REF="$(git rev-parse "${GIT_BASE_BRANCH}")" + GIT_BASE_REF="$(echo "$JSON" | $JQ -r '.base.sha')" GIT_BRANCH="PR-${GIT_BRANCH}" else GIT_BUILD_SHA="$(git rev-parse "refs/heads/${GIT_BRANCH}")"