mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-01 08:18:33 +00:00
fix(proof): keep inflate error output out of messages
This commit is contained in:
1 parent
68407a34cd
commit
b729cf0cb4
2 files changed
+3
-3
No files matched your search
@@ -877,8 +877,8 @@ impl AffixDict {
|
||||
|
||||
/// Read data written by [`AffixDict::to_bytes`].
|
||||
pub fn from_bytes(data: &[u8]) -> Result<AffixDict, String> {
|
||||
let raw =
|
||||
miniz_oxide::inflate::decompress_to_vec_with_limit(data, 64 << 20).map_err(|e| format!("affix dictionary: inflate failed: {e:?}"))?;
|
||||
let raw = miniz_oxide::inflate::decompress_to_vec_with_limit(data, 64 << 20)
|
||||
.map_err(|e| format!("affix dictionary: inflate failed: {:?}", e.status))?;
|
||||
let words_at = raw.windows(7).position(|w| w == b"\nWORDS\n").ok_or("affix dictionary: no WORDS section")?;
|
||||
let head = std::str::from_utf8(raw.get(..words_at).unwrap_or_default()).map_err(|_| "affix dictionary: bad utf-8 in the rules")?;
|
||||
let mut lines = head.lines();
|
||||
|
||||
@@ -78,7 +78,7 @@ impl Dictionary {
|
||||
|
||||
/// Deserialize data written by [`Dictionary::to_bytes`].
|
||||
pub fn from_bytes(data: &[u8]) -> Result<Dictionary, String> {
|
||||
let raw = miniz_oxide::inflate::decompress_to_vec(data).map_err(|e| format!("hyphenation dictionary: inflate failed: {e:?}"))?;
|
||||
let raw = miniz_oxide::inflate::decompress_to_vec(data).map_err(|e| format!("hyphenation dictionary: inflate failed: {:?}", e.status))?;
|
||||
let body = raw.strip_prefix(MAGIC).ok_or("hyphenation dictionary: bad header")?;
|
||||
let mut d = Dictionary { words: String::with_capacity(body.len()), offs: vec![0], masks: Vec::new() };
|
||||
let mut cur: Vec<u8> = Vec::new();
|
||||
|
||||
Reference in new issue
Block a user