Skip to content

Commit

Permalink
Merge pull request #470 from chewing/issue465
Browse files Browse the repository at this point in the history
Pre-release 0.7.0-rc.1
  • Loading branch information
kanru committed Mar 26, 2024
2 parents d34a0a2 + e5632c4 commit b02ed5b
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 33 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21.0)
project(libchewing C)
project(libchewing LANGUAGES C)

set(CMAKE_PROJECT_VERSION 0.6.0)
set(CMAKE_PROJECT_VERSION 0.7.0-rc.1)
set(LIBCHEWING_VERSION ${CMAKE_PROJECT_VERSION})
set(PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
set(LIBCHEWING_BINARY_VERSION 1.0.0)
Expand Down Expand Up @@ -288,7 +288,7 @@ endif()

if(WITH_RUST)
corrosion_set_env_vars(chewing
CHEWING_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}/libchewing"
CHEWING_DATADIR=${CMAKE_INSTALL_FULL_DATADIR}/libchewing
)
target_link_libraries(libchewing PRIVATE chewing)
target_link_libraries(chewing INTERFACE ${SQLite3_LIBRARIES})
Expand Down
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Expand Up @@ -3,7 +3,7 @@ name = "chewing"
description = "The Chewing (酷音) intelligent Zhuyin input method."
license = "LGPL-2.1-or-later"
documentation = "https://docs.rs/chewing"
version = "0.6.0-alpha.2"
version = "0.7.0-beta.1"
rust-version = "1.70"
edition = "2021"

Expand All @@ -15,10 +15,10 @@ directories = "5.0.0"
env_logger = { version = "0.10.2", default-features = false, optional = true }
log = "0.4.21"
riff = "2.0.0"
rusqlite = { version = "0.30.0", optional = true }
rusqlite = { version = "0.31.0", optional = true }

[target.'cfg(windows)'.dependencies]
rusqlite = { version = "0.30.0", features = ["bundled"], optional = true }
rusqlite = { version = "0.31.0", features = ["bundled"], optional = true }

[lib]
crate-type = ["rlib", "staticlib"]
Expand Down
46 changes: 42 additions & 4 deletions NEWS
@@ -1,12 +1,50 @@
What's New in libchewing next (UNRELEASED)
What's New in libchewing 0.7.0-rc.1 (Mar 25, 2024)
---------------------------------------------------------

This is the first beta release of the Rust rewrite. The library has been tested
with the AFL++ fuzzer and most of the obvious bugs have been fixed so it should
not crash for normal use. Now we invite power users to daily drive the beta
release in order to find more subtle bugs.

The Rust rewrite is ABI compatiable with previous releases. The most notable
difference with the C version includes a new portable system dictionary format
and two new user dictionary format. Users with existing user phrase dictionary
will be automatically migrated to either a new sqlite3 schema or CDB based
format depending on compile time configuration. Old files will be backed up
automatically. With these change we will be able to support dictionary sharing
and loading multiple dictionaries in future releases.

* Future roadmap
- 0.8.x after bug bashing this version will be the first public release with
rust implementation as the default.
- 0.9.x will focus on the stablization of the Rust crate API.
- 1.0.0 will be the first public release of the Rust API. C implementation
will be removed from the repository.

* Added
- Added Colemak-DH ANSI/Orth layout support
- Supporting migrating user dictionary file to new format. (rust)
- Allow creating in memory user dictionary (rust)
- New `chewing-cli` tool can be used to create or inspect dictionary files. (rust)
- New `chewing-cli` tool can dump dictionary as or import from CSV file. (rust)

* Changed
* Dictionary
* Removed
- New trie dictionary format now has built-in checksum. (rust)

* Bug fixed
* Platform-specific
- Some unsigned underflow issue found by afl++ (rust)
- Skip symbol selection if preedit buffer is empty (rust)
- Allow numlock in selection mode (rust)
- Avoid infinite recursion (rust)

* Documentation
- Added document for fuzzers (rust)
- Describe how to compile dictionary files
- Update build instruction and Rust MSRV info

* Testing
- Added a fuzzer harness with afl++ (rust)


What's New in libchewing 0.6.0 (Jan 27, 2024)
---------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions fuzzer/Cargo.toml
@@ -1,13 +1,13 @@
[package]
name = "fuzzer"
version = "0.1.0"
version = "0.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
afl = "0.15.4"
chewing = { version = "0.6.0-alpha.2", path = "..", features = ["capi"] }
chewing = { version = "0.7.0-beta.1", path = "..", features = ["capi"] }
log = "0.4.21"
env_logger = "0.10.0"
xflags = "0.3.2"
11 changes: 8 additions & 3 deletions src/capi/io.rs
Expand Up @@ -1738,9 +1738,10 @@ pub unsafe extern "C" fn chewing_cand_CheckDone(ctx: *const ChewingContext) -> c
None => return -1,
};

match ctx.editor.total_page() {
Ok(_) => FALSE,
Err(_) => TRUE,
if ctx.editor.is_selecting() {
TRUE
} else {
FALSE
}
}

Expand Down Expand Up @@ -1826,6 +1827,10 @@ pub unsafe extern "C" fn chewing_cand_hasNext(ctx: *mut ChewingContext) -> c_int
None => return -1,
};

if !ctx.editor.is_selecting() {
return FALSE;
}

ctx.cand_iter
.as_mut()
.and_then(|it| it.peek())
Expand Down
5 changes: 5 additions & 0 deletions src/path.rs
Expand Up @@ -6,6 +6,7 @@ use std::{
};

use directories::{BaseDirs, ProjectDirs};
use log::info;

const DEFAULT_UNIX_SYS_PATH: &str = "/usr/share/libchewing";
const UNIX_SYS_PATH: Option<&str> = option_env!("CHEWING_DATADIR");
Expand All @@ -19,10 +20,12 @@ const SEARCH_PATH_SEP: char = ':';
pub(crate) fn sys_path_from_env_var() -> String {
let chewing_path = env::var("CHEWING_PATH");
if let Ok(chewing_path) = chewing_path {
info!("Using CHEWING_PATH {}", chewing_path);
chewing_path
} else {
let user_datadir = data_dir();
let sys_datadir = UNIX_SYS_PATH.unwrap_or(DEFAULT_UNIX_SYS_PATH);
info!("Using CHEWING_PATH {}", sys_datadir);
if let Some(datadir) = user_datadir.as_ref().and_then(|p| p.to_str()) {
format!("{datadir}:{sys_datadir}")
} else {
Expand All @@ -34,6 +37,7 @@ pub(crate) fn sys_path_from_env_var() -> String {
pub(crate) fn find_path_by_files(search_path: &str, files: &[&str]) -> Option<PathBuf> {
for path in search_path.split(SEARCH_PATH_SEP) {
let prefix = Path::new(path).to_path_buf();
info!("Search files {:?} in {}", files, prefix.display());
if files
.iter()
.map(|it| {
Expand All @@ -43,6 +47,7 @@ pub(crate) fn find_path_by_files(search_path: &str, files: &[&str]) -> Option<Pa
})
.all(|it| it.exists())
{
info!("Load {:?} from {}", files, prefix.display());
return Some(prefix);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testhelper/Cargo.toml
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
chewing = { version = "0.6.0-alpha.2", path = "../..", features = ["capi"] }
chewing = { version = "0.7.0-beta.1", path = "../..", features = ["capi"] }

[features]
sqlite = ["chewing/sqlite"]
4 changes: 2 additions & 2 deletions tools/Cargo.toml
Expand Up @@ -2,10 +2,10 @@
name = "chewing-cli"
description = "Tools of the Chewing (酷音) intelligent Zhuyin input method."
license = "LGPL-2.1-or-later"
version = "0.6.0-alpha.1"
version = "0.7.0-beta.1"
edition = "2021"

[dependencies]
anyhow = "1.0.0"
chewing = { version = "0.6.0-alpha.1", path = "..", features = ["sqlite"] }
chewing = { version = "0.7.0-beta.1", path = "..", features = ["sqlite"] }
xflags = "0.3.2"

0 comments on commit b02ed5b

Please sign in to comment.