Skip to content

Commit 823bf35

Browse files
committed
Skip leading space in ARM instruction params
1 parent f6310d5 commit 823bf35

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

objdiff-core/src/arch/arm.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ impl Arch for ArchArm {
320320
let opcode = string_fmt.into_string();
321321
cb(InstructionPart::opcode(opcode, resolved.ins_ref.opcode))?;
322322

323-
let mut args_formatter = ArgsFormatter { options: &options, cb, resolved: &resolved };
323+
let mut args_formatter =
324+
ArgsFormatter { options: &options, cb, resolved: &resolved, skip_leading_space: true };
324325
ins.write_params(&mut args_formatter)?;
325326
Ok(())
326327
}
@@ -473,6 +474,7 @@ pub struct ArgsFormatter<'a> {
473474
options: &'a unarm::Options,
474475
cb: &'a mut dyn FnMut(InstructionPart) -> Result<()>,
475476
resolved: &'a ResolvedInstructionRef<'a>,
477+
skip_leading_space: bool,
476478
}
477479

478480
impl ArgsFormatter<'_> {
@@ -504,6 +506,15 @@ impl unarm::FormatIns for ArgsFormatter<'_> {
504506
ins.write_params(self)
505507
}
506508

509+
fn write_space(&mut self) -> core::fmt::Result {
510+
if self.skip_leading_space {
511+
self.skip_leading_space = false;
512+
Ok(())
513+
} else {
514+
self.write_str(" ")
515+
}
516+
}
517+
507518
fn write_separator(&mut self) -> core::fmt::Result { self.write(InstructionPart::separator()) }
508519

509520
fn write_uimm(&mut self, uimm: u32) -> core::fmt::Result {

0 commit comments

Comments
 (0)