From: Mark Thom Date: Sun, 3 May 2020 23:03:59 +0000 (-0600) Subject: restore previous focus upon character match failure in compare_pstr_to_string (#441) X-Git-Tag: v0.8.123~65 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=9e220e8416e02533464ad2756ab6ea407b891fa8;p=scryer-prolog.git restore previous focus upon character match failure in compare_pstr_to_string (#441) --- diff --git a/src/prolog/machine/machine_state.rs b/src/prolog/machine/machine_state.rs index 06fc9417..5f3557fb 100644 --- a/src/prolog/machine/machine_state.rs +++ b/src/prolog/machine/machine_state.rs @@ -45,7 +45,7 @@ impl<'a> HeapPStrIter<'a> { #[inline] pub(crate) - fn focus(&'a self) -> Addr { + fn focus(&self) -> Addr { self.machine_st.store(self.machine_st.deref(self.focus)) } @@ -303,6 +303,10 @@ fn compare_pstr_to_string<'a>( } } } + + if s[s_offset ..].is_empty() { + return Some(s_offset); + } } Some(s_offset) diff --git a/src/prolog/toplevel.pl b/src/prolog/toplevel.pl index 7a0b5bf3..461e7195 100644 --- a/src/prolog/toplevel.pl +++ b/src/prolog/toplevel.pl @@ -323,21 +323,6 @@ gather_goals([Var = Value | Pairs], VarList, QueryVarList, Goals) :- ; gather_goals(Pairs, VarList, QueryVarList, Goals) ). -/* -gather_goals([], VarList, QueryVarList, Goals) :- - gather_query_vars(VarList, Vars), - copy_term(Vars, Vars, Goals). -% filter_goals(Goals0, Goals, Vars). -gather_goals([Var = Value | Pairs], VarList, QueryVarList, Goals) :- - ( ( nonvar(Value) - ; is_a_different_variable(Pairs, Value) - ) -> - Goals = [Var = Value | Goals0], - gather_goals(Pairs, VarList, QueryVarList, Goals0) - ; gather_goals(Pairs, VarList, QueryVarList, Goals) - ). -*/ - print_exception(E) :- ( E == error('$interrupt_thrown', repl) -> nl % print the % exception on a