fix off by one bug in system_calls

This commit is contained in:
Mark Thom
2021-12-04 16:24:06 -07:00
parent 4cde8cd501
commit d7bf04d2c0

View File

@@ -354,7 +354,7 @@ impl MachineState {
let cstr = PartialString::from(cstr_atom); let cstr = PartialString::from(cstr_atom);
let pstr_chars = cstr.as_str_from(0).chars().count(); let pstr_chars = cstr.as_str_from(0).chars().count();
if pstr_chars < max_steps { if pstr_chars <= max_steps {
CycleSearchResult::ProperList(pstr_chars) CycleSearchResult::ProperList(pstr_chars)
} else { } else {
CycleSearchResult::UntouchedCStr(cstr_atom, max_steps) CycleSearchResult::UntouchedCStr(cstr_atom, max_steps)
@@ -734,7 +734,7 @@ impl MachineState {
// avoid allocating a String if possible ... // avoid allocating a String if possible ...
Some(AtomOrString::Atom(cstr_atom)) Some(AtomOrString::Atom(cstr_atom))
} }
(HeapCellValueTag::Atom, (atom, arity)) => { (HeapCellValueTag::Atom, (atom, arity)) => { // TODO: Char??
if arity == 0 { if arity == 0 {
// ... likewise. // ... likewise.
Some(AtomOrString::Atom(atom)) Some(AtomOrString::Atom(atom))
@@ -2698,13 +2698,13 @@ impl MachineState {
&SystemClauseType::EnqueueAttributedVar => { &SystemClauseType::EnqueueAttributedVar => {
let addr = self.store(self.deref(self.registers[1])); let addr = self.store(self.deref(self.registers[1]));
read_heap_cell!(addr, read_heap_cell!(addr,
(HeapCellValueTag::AttrVar, h) => { (HeapCellValueTag::AttrVar, h) => {
self.attr_var_init.attr_var_queue.push(h); self.attr_var_init.attr_var_queue.push(h);
} }
_ => { _ => {
} }
); );
} }
&SystemClauseType::GetNextDBRef => { &SystemClauseType::GetNextDBRef => {
let a1 = self.store(self.deref(self.registers[1])); let a1 = self.store(self.deref(self.registers[1]));
@@ -4424,11 +4424,6 @@ impl MachineState {
&SystemClauseType::UnwindStack => { &SystemClauseType::UnwindStack => {
self.unwind_stack(); self.unwind_stack();
} }
/*
&SystemClauseType::Variant => {
self.fail = self.structural_eq_test();
}
*/
&SystemClauseType::WAMInstructions => { &SystemClauseType::WAMInstructions => {
let module_name = cell_as_atom!(self.store(self.deref(self.registers[1]))); let module_name = cell_as_atom!(self.store(self.deref(self.registers[1])));