aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--.github/workflows/rust.yml28
-rw-r--r--.gitignore2
-rw-r--r--Android.bp4
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA25
-rwxr-xr-xscripts/unicode.py4
-rw-r--r--src/lib.rs6
-rw-r--r--src/tables.rs6
10 files changed, 53 insertions, 28 deletions
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 <kwantam@gmail.com>",
"Manish Goregaokar <manishsmail@gmail.com>",
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 <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"]
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, 0xA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