From b162c40007540f77f14e2f5cf2bf4aac3e3f428e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Adri=C3=A1n=20Arroyo=20Calle?= Date: Sat, 22 Apr 2023 10:54:35 +0200 Subject: [PATCH] Fix to_upper/to_lower when string is instantiated --- src/machine/system_calls.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index cc5bc536..674fc54f 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -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; } _ => { -- 2.54.0