]> Repositorios git - scryer-prolog.git/commitdiff
Fix to_upper/to_lower when string is instantiated
authorAdrián Arroyo Calle <[email protected]>
Sat, 22 Apr 2023 08:54:35 +0000 (10:54 +0200)
committerAdrián Arroyo Calle <[email protected]>
Sun, 23 Apr 2023 21:01:29 +0000 (23:01 +0200)
src/machine/system_calls.rs

index cc5bc53683920389c9fd8e9739cd5c0f38f79d52..674fc54fda54991375312863933a5922ffb320cd 100644 (file)
@@ -2794,15 +2794,17 @@ impl Machine {
                
                match (name, arity) {
                    (atom!("to_upper"), 1) => {
-                       let reg = self.machine_st.heap[s+1];
-                       let upper_str = self.machine_st.atom_tbl.build_with(&c.to_uppercase().to_string());
-                       self.machine_st.unify_complete_string(upper_str, reg);
+                       let reg = self.machine_st.deref(self.machine_st.heap[s+1]);
+                       let atom = self.machine_st.atom_tbl.build_with(&c.to_uppercase().to_string());
+                       let upper_str = string_as_cstr_cell!(atom);
+                       unify!(self.machine_st, reg, upper_str);
                        self.machine_st.fail = false;
                    }
                    (atom!("to_lower"), 1) => {
-                       let reg = self.machine_st.heap[s+1];
-                       let lower_str = self.machine_st.atom_tbl.build_with(&c.to_lowercase().to_string());
-                       self.machine_st.unify_complete_string(lower_str, reg);
+                       let reg = self.machine_st.deref(self.machine_st.heap[s+1]);
+                       let atom = self.machine_st.atom_tbl.build_with(&c.to_lowercase().to_string());
+                       let lower_str = string_as_cstr_cell!(atom);
+                       unify!(self.machine_st, reg, lower_str);
                        self.machine_st.fail = false;
                    }               
                    _ => {