From 44dab9ab3313a2e9bc9477400b90724d7c21dc28 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 3 Dec 2016 10:32:13 -0600 Subject: [PATCH] fix atom_term --- os/readline.c | 2 +- os/readterm.c | 20 +++++++------------- os/yapio.h | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/os/readline.c b/os/readline.c index ca300a911..5dc5930a1 100644 --- a/os/readline.c +++ b/os/readline.c @@ -264,7 +264,7 @@ bool Yap_ReadlineOps(StreamDesc *s) { static int prolog_complete(int ignore, int key) { if (rl_point > 0 && rl_line_buffer[rl_point - 1] != ' ') { -#if HAVE_DECL_RL_CATCH_SIGNALS /* actually version >= 1.2, or true readline \ +#if HAVE_DECL_RL_CATCH_SIGNALS /* actually version >= 1.2, or true readline \ */ rl_begin_undo_group(); rl_complete(ignore, key); diff --git a/os/readterm.c b/os/readterm.c index 96cc0604a..f70c73208 100644 --- a/os/readterm.c +++ b/os/readterm.c @@ -1253,26 +1253,20 @@ static Int style_checker(USES_REGS1) { } X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, - int prio, Term *bindings) { + int prio, Term *bindingsp) { CACHE_REGS - Term bvar = MkVarTerm(), ctl; - yhandle_t sl; + Term ctl; int lvl = push_text_stack(); if (len == 0) { Term rval = TermEof; - if (rval && bindings) { - *bindings = TermNil; - } - pop_text_stack(lvl); + pop_text_stack(lvl); return rval; } - if (bindings) { - ctl = Yap_MkApplTerm(Yap_MkFunctor(AtomVariableNames, 1), 1, &bvar); - sl = Yap_PushHandle(bvar); + if (bindingsp) { + ctl = Yap_MkNewApplTerm(Yap_MkFunctor(AtomVariableNames, 1), 1); } else { ctl = TermNil; - sl = 0; } Term rval; @@ -1281,8 +1275,8 @@ X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, rval = Yap_read_term(stream, ctl, 3); Yap_CloseStream(stream); UNLOCK(GLOBAL_Stream[stream].streamlock); - if (rval && bindings) { - *bindings = Yap_PopHandle(sl); + if (rval && bindingsp) { + *bindingsp = ArgOfTerm(1,ctl); } pop_text_stack(lvl); return rval; diff --git a/os/yapio.h b/os/yapio.h index d8bfaabca..a5d2144e1 100644 --- a/os/yapio.h +++ b/os/yapio.h @@ -106,7 +106,7 @@ typedef enum mem_buf_source { extern char *Yap_MemStreamBuf(int sno); extern X_API Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, - int prio, Term *bindings_p); + int prio, Term *bindingsp); extern Term Yap_StringToNumberTerm(const char *s, encoding_t *encp, bool error_on); extern int Yap_FormatFloat(Float f, char **s, size_t sz);