From ac13f2c1b0e90b4db3a78d3d23085ea85d071e45 Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Mon, 5 Feb 2024 20:29:49 +0100 Subject: Upgrade unicode-width to 0.1.11 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/rust/crates/unicode-width For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I47e9bf9a5d020014a6c07007c9388deb8230b982 --- .cargo_vcs_info.json | 2 +- .github/workflows/rust.yml | 28 ++++++++++++++++++++++++++++ .gitignore | 2 ++ Android.bp | 4 ++-- Cargo.toml | 2 +- Cargo.toml.orig | 2 +- METADATA | 25 +++++++++++-------------- scripts/unicode.py | 4 ++-- src/lib.rs | 6 ++---- src/tables.rs | 6 +++--- 10 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/rust.yml diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index df61a6c..be8a499 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "f444a314efeda9c130db6d6a96e925db0ea1ed13" + "sha1": "89424871950f91033de79cd06318d8c06d94df84" }, "path_in_vcs": "" } \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..89c5f57 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,28 @@ +name: Rust + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + regen: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Regen + run: cd scripts && python3 unicode.py + - name: Diff + run: diff src/tables.rs scripts/tables.rs diff --git a/.gitignore b/.gitignore index 5cdcdba..2d7d550 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ target Cargo.lock scripts/tmp +scripts/*.txt +scripts/*.rs diff --git a/Android.bp b/Android.bp index f988879..5d19f64 100644 --- a/Android.bp +++ b/Android.bp @@ -43,7 +43,7 @@ rust_library { host_supported: true, crate_name: "unicode_width", cargo_env_compat: true, - cargo_pkg_version: "0.1.10", + cargo_pkg_version: "0.1.11", srcs: ["src/lib.rs"], edition: "2015", features: ["default"], @@ -60,7 +60,7 @@ rust_test { host_supported: true, crate_name: "unicode_width", cargo_env_compat: true, - cargo_pkg_version: "0.1.10", + cargo_pkg_version: "0.1.11", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, diff --git a/Cargo.toml b/Cargo.toml index 77aded9..6dcfacd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ [package] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" authors = [ "kwantam ", "Manish Goregaokar ", diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 993b35f..a0f16da 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,7 +1,7 @@ [package] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" authors = ["kwantam ", "Manish Goregaokar "] homepage = "https://github.com/unicode-rs/unicode-width" diff --git a/METADATA b/METADATA index 2cd7fa9..7f184b6 100644 --- a/METADATA +++ b/METADATA @@ -1,23 +1,20 @@ # This project was upgraded with external_updater. -# Usage: tools/external_updater/updater.sh update rust/crates/unicode-width -# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md +# Usage: tools/external_updater/updater.sh update external/rust/crates/unicode-width +# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md name: "unicode-width" description: "Determine displayed width of `char` and `str` types according to Unicode Standard Annex #11 rules." third_party { - url { - type: HOMEPAGE - value: "https://crates.io/crates/unicode-width" - } - url { - type: ARCHIVE - value: "https://static.crates.io/crates/unicode-width/unicode-width-0.1.10.crate" - } - version: "0.1.10" license_type: NOTICE last_upgrade_date { - year: 2022 - month: 12 - day: 19 + year: 2024 + month: 2 + day: 5 + } + homepage: "https://crates.io/crates/unicode-width" + identifier { + type: "Archive" + value: "https://static.crates.io/crates/unicode-width/unicode-width-0.1.11.crate" + version: "0.1.11" } } diff --git a/scripts/unicode.py b/scripts/unicode.py index 2efb0b6..a6d58c5 100755 --- a/scripts/unicode.py +++ b/scripts/unicode.py @@ -106,9 +106,9 @@ def load_east_asian_widths() -> "list[EffectiveWidth]": `Ambiguous` chracters are assigned `EffectiveWidth.AMBIGUOUS`.""" with fetch_open("EastAsianWidth.txt") as eaw: # matches a width assignment for a single codepoint, i.e. "1F336;N # ..." - single = re.compile(r"^([0-9A-F]+);(\w+) +# (\w+)") + single = re.compile(r"^([0-9A-F]+)\s+;\s+(\w+) +# (\w+)") # matches a width assignment for a range of codepoints, i.e. "3001..3003;W # ..." - multiple = re.compile(r"^([0-9A-F]+)\.\.([0-9A-F]+);(\w+) +# (\w+)") + multiple = re.compile(r"^([0-9A-F]+)\.\.([0-9A-F]+)\s+;\s+(\w+) +# (\w+)") # map between width category code and condensed width width_codes = { **{c: EffectiveWidth.NARROW for c in ["N", "Na", "H"]}, diff --git a/src/lib.rs b/src/lib.rs index 68e5b7e..f2a50bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -59,8 +59,6 @@ extern crate test; use tables::charwidth as cw; pub use tables::UNICODE_VERSION; -use core::ops::Add; - mod tables; #[cfg(test)] @@ -121,11 +119,11 @@ pub trait UnicodeWidthStr { impl UnicodeWidthStr for str { #[inline] fn width(&self) -> usize { - self.chars().map(|c| cw::width(c, false).unwrap_or(0)).fold(0, Add::add) + self.chars().map(|c| cw::width(c, false).unwrap_or(0)).sum() } #[inline] fn width_cjk(&self) -> usize { - self.chars().map(|c| cw::width(c, true).unwrap_or(0)).fold(0, Add::add) + self.chars().map(|c| cw::width(c, true).unwrap_or(0)).sum() } } diff --git a/src/tables.rs b/src/tables.rs index 439c69c..791d7a8 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -12,7 +12,7 @@ /// The version of [Unicode](http://www.unicode.org/) /// that this version of unicode-width is based on. -pub const UNICODE_VERSION: (u8, u8, u8) = (15, 0, 0); +pub const UNICODE_VERSION: (u8, u8, u8) = (15, 1, 0); pub mod charwidth { use core::option::Option::{self, None, Some}; @@ -395,13 +395,13 @@ pub mod charwidth { 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x9A, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x5A, 0x55, 0x55, 0x55, - 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, + 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x0A, 0xA0, 0xAA, 0xAA, 0xAA, 0x6A, 0xA9, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x6A, 0x81, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0xA9, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xA9, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x6A, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xA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