From: Adrián Arroyo Calle Date: Sat, 22 Apr 2023 08:54:35 +0000 (+0200) Subject: Fix to_upper/to_lower when string is instantiated X-Git-Tag: v0.9.2~143^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=b162c40007540f77f14e2f5cf2bf4aac3e3f428e;p=scryer-prolog.git Fix to_upper/to_lower when string is instantiated --- 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; } _ => {