Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions crates/common/src/binascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,73 +618,6 @@ pub fn b2a_qp(buf: &[u8], quotetabs: bool, istext: bool, header: bool) -> Vec<u8
out_data
}

/// `rlecode_hqx`.
#[must_use]
pub fn rlecode_hqx(buffer: &[u8]) -> Vec<u8> {
const RUN_CHAR: u8 = 0x90; // b'\x90'
let len = buffer.len();
let mut out_data = Vec::<u8>::with_capacity((len * 2) + 2);

let mut idx = 0;
while idx < len {
let ch = buffer[idx];

if ch == RUN_CHAR {
out_data.push(RUN_CHAR);
out_data.push(0);
return out_data;
}

let mut in_end = idx + 1;
while in_end < len && buffer[in_end] == ch && in_end < idx + 255 {
in_end += 1;
}

if in_end - idx > 3 {
out_data.push(ch);
out_data.push(RUN_CHAR);
out_data.push(((in_end - idx) % 256) as u8);
idx = in_end - 1;
} else {
out_data.push(ch);
}

idx += 1;
}
out_data
}

/// `rledecode_hqx`.
#[must_use]
pub fn rledecode_hqx(buffer: &[u8]) -> Vec<u8> {
const RUN_CHAR: u8 = 0x90; //b'\x90'
let len = buffer.len();
let mut out_data = Vec::<u8>::with_capacity(len);
let mut idx = 0;

out_data.push(buffer[idx]);
idx += 1;

while idx < len {
if buffer[idx] == RUN_CHAR {
if buffer[idx + 1] == 0 {
out_data.push(RUN_CHAR);
} else {
let ch = buffer[idx - 1];
let range = buffer[idx + 1];
idx += 1;
for _ in 1..range {
out_data.push(ch);
}
}
} else {
out_data.push(buffer[idx]);
}
idx += 1;
}
out_data
}

/// `a2b_uu`.
pub fn a2b_uu(b: &[u8]) -> Result<Vec<u8>, Error> {
// First byte: binary data length (in bytes)
Expand Down
7 changes: 5 additions & 2 deletions crates/common/src/encodings/cjk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,13 @@ mod tests {
Codec::Hz,
];
for codec in codecs {
let initial_state = initial_state(codec, true);
for first in 0..=u8::MAX {
let _ = decode_one(codec, &[first], &mut [0; 8]);
let mut state = initial_state;
let _ = decode_one(codec, &[first], &mut state);
for second in 0..=u8::MAX {
let _ = decode_one(codec, &[first, second], &mut [0; 8]);
let mut state = initial_state;
let _ = decode_one(codec, &[first, second], &mut state);
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions crates/stdlib/src/binascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,6 @@ mod decl {
data.with_ref(|buf| binascii::b2a_qp(buf, quotetabs, istext, header))
}

#[pyfunction]
fn rlecode_hqx(s: ArgAsciiBuffer) -> Vec<u8> {
s.with_ref(binascii::rlecode_hqx)
}

#[pyfunction]
fn rledecode_hqx(s: ArgAsciiBuffer) -> Vec<u8> {
s.with_ref(binascii::rledecode_hqx)
}

#[pyfunction]
fn a2b_uu(s: ArgAsciiBuffer, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
s.with_ref(binascii::a2b_uu)
Expand Down
Loading