Skip to content

Commit

Permalink
fix: broken test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Dec 22, 2023
1 parent 1160468 commit 0a62459
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions yara-x/src/re/thompson/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ impl Display for InstrSeq {
Instr::SplitA(id, offset) => {
writeln!(
f,
"{:05x}: SPLIT_A({:?}) {:05x}",
"{:05x}: SPLIT_A({}) {:05x}",
addr,
id,
addr as isize + offset as isize,
Expand All @@ -1507,14 +1507,14 @@ impl Display for InstrSeq {
Instr::SplitB(id, offset) => {
writeln!(
f,
"{:05x}: SPLIT_B({:?}) {:05x}",
"{:05x}: SPLIT_B({}) {:05x}",
addr,
id,
addr as isize + offset as isize,
)?;
}
Instr::SplitN(split) => {
write!(f, "{:05x}: SPLIT_N({:?})", addr, split.id())?;
write!(f, "{:05x}: SPLIT_N({})", addr, split.id())?;
for offset in split.offsets() {
write!(f, " {:05x}", addr as isize + offset as isize)?;
}
Expand Down
7 changes: 7 additions & 0 deletions yara-x/src/re/thompson/instr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ of `0xAA`. Stated differently, the opcode `0xAA` serves as a special case that
solely matches the `0xAA` byte.
*/

use std::fmt::{Display, Formatter};
use std::mem::size_of;
use std::u8;

Expand All @@ -77,6 +78,12 @@ impl From<SplitId> for usize {
}
}

impl Display for SplitId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

impl SplitId {
pub const BITS: usize = 13;

Expand Down

0 comments on commit 0a62459

Please sign in to comment.