]> Repositorios git - scryer-prolog.git/commitdiff
offset into complete strings with '$skip_max_list'/4 (#1529)
authorMark Thom <[email protected]>
Sun, 21 Aug 2022 02:28:49 +0000 (20:28 -0600)
committerMark Thom <[email protected]>
Thu, 27 Oct 2022 05:36:07 +0000 (23:36 -0600)
src/machine/system_calls.rs

index 5ce4ff899e366130d21e4a2ca966b8b836ea8f4e..7690c37fb08f2a8da50bfa49b4f00932cd74eaed 100644 (file)
@@ -579,7 +579,19 @@ impl MachineState {
                 self.finalize_skip_max_list(n as i64, list_loc_as_cell!(l));
             }
             CycleSearchResult::UntouchedCStr(cstr_atom, n) => {
-                self.finalize_skip_max_list(n as i64, string_as_cstr_cell!(cstr_atom));
+                let cell = if n > 0 {
+                    let h = self.heap.len();
+
+                    self.heap.push(string_as_cstr_cell!(cstr_atom));
+                    self.heap.push(pstr_offset_as_cell!(h));
+                    self.heap.push(fixnum_as_cell!(Fixnum::build_with(n as i64)));
+
+                    pstr_loc_as_cell!(h+1)
+                } else {
+                    string_as_cstr_cell!(cstr_atom)
+                };
+
+                self.finalize_skip_max_list(n as i64, cell);
             }
             CycleSearchResult::EmptyList => {
                 self.finalize_skip_max_list(0, empty_list_as_cell!());