From 23e8492aa7ecd90c5ef6d554b8dba0ed2a8e694e Mon Sep 17 00:00:00 2001 From: ddidderr Date: Sun, 12 Jul 2026 09:33:23 +0200 Subject: [PATCH] fix(cli): initialize the patch-from fileio preference Set the C file-I/O patch-from flag explicitly when the Rust frontend creates preferences. The parser still rejects the unported option, but this keeps the backend in ordinary dictionary mode instead of reading an unspecified field. Test Plan: - cargo test --manifest-path rust/cli/Cargo.toml --all-features - cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings - git diff --check Refs: rust/src/zstd_cli.rs, programs/fileio.c --- rust/src/zstd_cli.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/src/zstd_cli.rs b/rust/src/zstd_cli.rs index 291a046ec..db33cb801 100644 --- a/rust/src/zstd_cli.rs +++ b/rust/src/zstd_cli.rs @@ -157,6 +157,7 @@ unsafe extern "C" { fn FIO_setContentSize(prefs: *mut FIO_prefs_t, value: c_int); fn FIO_setAsyncIOFlag(prefs: *mut FIO_prefs_t, value: c_int); fn FIO_setPassThroughFlag(prefs: *mut FIO_prefs_t, value: c_int); + fn FIO_setPatchFromMode(prefs: *mut FIO_prefs_t, value: c_int); fn FIO_setMMapDict(prefs: *mut FIO_prefs_t, value: c_int); fn FIO_setNbFilesTotal(ctx: *mut FIO_ctx_t, value: c_int); fn FIO_setHasStdinInput(ctx: *mut FIO_ctx_t, value: c_int); @@ -1240,6 +1241,10 @@ unsafe fn apply_preferences(cli: &Cli, prefs: *mut FIO_prefs_t, ctx: *mut FIO_ct if let Some(value) = cli.pass_through { FIO_setPassThroughFlag(prefs, value); } + /* `FIO_createPreferences()` leaves this field unspecified. The Rust + * frontend does not yet parse --patch-from, so explicitly keep the + * C file-I/O backend in ordinary dictionary mode. */ + FIO_setPatchFromMode(prefs, 0); FIO_setContentSize(prefs, cli.content_size); if let Some(value) = cli.dict_id { FIO_setDictIDFlag(prefs, value);