]> Repositorios git - scryer-prolog.git/commitdiff
make self.s_offset use bytes in case of HeapPtr::PStr in UnifyVoid (#2897)
authorMark Thom <[email protected]>
Tue, 22 Apr 2025 03:25:50 +0000 (20:25 -0700)
committerMark Thom <[email protected]>
Wed, 23 Apr 2025 06:33:11 +0000 (23:33 -0700)
src/machine/dispatch.rs

index 254f9adcc9ad69b29b1f3490be4046ffd15f3a13..94b26ad324e551c2689ecca6c7b1317ca3576f6d 100644 (file)
@@ -3072,9 +3072,19 @@ impl Machine {
                     }
                     &Instruction::UnifyVoid(n) => {
                         match self.machine_st.mode {
-                            MachineMode::Read => {
-                                self.machine_st.s_offset += n;
-                            }
+                            MachineMode::Read => match &self.machine_st.s {
+                                HeapPtr::HeapCell(_) => self.machine_st.s_offset += n,
+                                &HeapPtr::PStr(pstr_loc) => {
+                                    debug_assert!(n <= 2);
+                                    let mut char_iter = self.machine_st.heap.char_iter(pstr_loc);
+
+                                    // this only matters in the case that n == 1, but the case
+                                    // analysis isn't worth doing since the effect is benign if n ==
+                                    // 2
+                                    self.machine_st.s_offset +=
+                                        char_iter.next().unwrap().len_utf8();
+                                }
+                            },
                             MachineMode::Write => {
                                 let h = self.machine_st.heap.cell_len();