fix copy_partial_string bug (#572)

This commit is contained in:
Mark Thom
2020-06-16 18:47:39 -06:00
parent 0f017339b7
commit 53f99ca434
2 changed files with 5 additions and 5 deletions

View File

@@ -66,7 +66,7 @@
% p_trie_arity_univ(+Term,-FunctorData,-ArgumentsList).
p_trie_arity_univ(Term,functor_data(Name,Arity),Arguments) :-
( var(Term) ->
Name = var,
Name = Term,
Arity = 0,
Arguments = []
; Term =.. [Name|Arguments],

View File

@@ -104,7 +104,7 @@ impl<T: CopierTarget> CopyTermState<T> {
fn copy_partial_string(&mut self, addr: usize, n: usize) {
if let &HeapCellValue::Addr(Addr::PStrLocation(h, _)) = &self.target[addr] {
if h >= self.old_h {
*self.value_at_scan() = HeapCellValue::Addr(Addr::PStrLocation(h, 0));
*self.value_at_scan() = HeapCellValue::Addr(Addr::PStrLocation(h, n));
self.scan += 1;
return;
@@ -114,14 +114,14 @@ impl<T: CopierTarget> CopyTermState<T> {
let threshold = self.target.threshold();
*self.value_at_scan() =
HeapCellValue::Addr(Addr::PStrLocation(threshold, 0));
HeapCellValue::Addr(Addr::PStrLocation(threshold, n));
self.scan += 1;
let (pstr, has_tail) =
match &self.target[addr] {
&HeapCellValue::PartialString(ref pstr, has_tail) => {
(pstr.clone_from_offset(n), has_tail)
(pstr.clone_from_offset(0), has_tail)
}
_ => {
unreachable!()
@@ -130,7 +130,7 @@ impl<T: CopierTarget> CopyTermState<T> {
self.target.push(HeapCellValue::PartialString(pstr, has_tail));
let replacement = HeapCellValue::Addr(Addr::PStrLocation(threshold, 0));
let replacement = HeapCellValue::Addr(Addr::PStrLocation(threshold, n));
let trail_item = mem::replace(
&mut self.target[addr],