From 7a6d36ff168c38763acf3ff1849f6714ee7f775e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Mon, 16 Dec 2013 21:46:33 +0000 Subject: [PATCH 1/2] ensure real version to be YAP compatible --- .gitmodules | 2 +- packages/real | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index fde91a8c4..ed2819dd1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -36,7 +36,7 @@ url = git://git.code.sf.net/p/yap/pldoc [submodule "packages/real"] path = packages/real - url = git://www.swi-prolog.org/home/pl/git/packages/real.git + url = git://git.code.sf.net/p/yap/real [submodule "packages/archive"] path = packages/archive url = git://git.code.sf.net/p/yap/archive diff --git a/packages/real b/packages/real index 5a72fe49e..a383bfd51 160000 --- a/packages/real +++ b/packages/real @@ -1 +1 @@ -Subproject commit 5a72fe49e5a5c651a890a388eb967b83da8e2c52 +Subproject commit a383bfd51144172fdea8463bd56e9308742e5de2 From 1aafb30360b3025b6f8d4df186bf2b7e27b8619d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Mon, 16 Dec 2013 21:47:46 +0000 Subject: [PATCH 2/2] instantiation error --- C/text.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/C/text.c b/C/text.c index e8a4eb89a..eb9572899 100644 --- a/C/text.c +++ b/C/text.c @@ -219,8 +219,11 @@ Yap_ListOfAtomsToBuffer(void *buf, Term t, seq_tv_t *inp, int *widep, size_t *le LOCAL_Error_Term = *r; return NULL; } - if (n && !atoms) + if (n && !atoms) { + LOCAL_Error_Term = t; + LOCAL_Error_TYPE = TYPE_ERROR_CHARACTER; return NULL; + } *lenp = n; if (*widep) { wchar_t *s; @@ -351,6 +354,11 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng switch (inp->type & YAP_TYPE_MASK) { case YAP_STRING_STRING: { const char *s; + if (IsVarTerm(inp->val.t)) { + LOCAL_Error_TYPE = INSTANTIATION_ERROR; + LOCAL_Error_Term = inp->val.t; + return 0L; + } if (!IsStringTerm(inp->val.t)) { LOCAL_Error_TYPE = TYPE_ERROR_STRING; LOCAL_Error_Term = inp->val.t; @@ -399,7 +407,11 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng case YAP_STRING_ATOM: // this is a term, extract to a buffer, and representation is wide *minimal = TRUE; - if (!IsAtomTerm(inp->val.t)) { + if (IsVarTerm(inp->val.t)) { + LOCAL_Error_TYPE = INSTANTIATION_ERROR; + LOCAL_Error_Term = inp->val.t; + return 0L; + } else if (!IsAtomTerm(inp->val.t)) { LOCAL_Error_TYPE = TYPE_ERROR_ATOM; LOCAL_Error_Term = inp->val.t; return NULL; @@ -488,7 +500,11 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng return NULL; } else { Term t = inp->val.t; - if (IsStringTerm(t)) { + if (IsVarTerm(t)) { + LOCAL_Error_TYPE = INSTANTIATION_ERROR; + LOCAL_Error_Term = t; + return NULL; + } else if (IsStringTerm(t)) { if (inp->type & (YAP_STRING_STRING)) { inp->type &= (YAP_STRING_STRING); return read_Text( buf, inp, enc, minimal, lengp PASS_REGS); @@ -505,14 +521,14 @@ read_Text( void *buf, seq_tv_t *inp, encoding_t *enc, int *minimal, size_t *leng LOCAL_Error_Term = t; } } else if (IsAtomTerm(t)) { - if (inp->type & (YAP_STRING_ATOM)) { + if (t == TermNil && inp->type & (YAP_STRING_CODES|YAP_STRING_ATOMS)) { + inp->type &= (YAP_STRING_CODES|YAP_STRING_ATOMS); + return read_Text( buf, inp, enc, minimal, lengp PASS_REGS); + } else if (inp->type & (YAP_STRING_ATOM)) { inp->type &= (YAP_STRING_ATOM); inp->val.t = t; return read_Text( buf, inp, enc, minimal, lengp PASS_REGS); // [] is special... - } else if (t == TermNil && inp->type & (YAP_STRING_CODES|YAP_STRING_ATOMS)) { - inp->type &= (YAP_STRING_CODES|YAP_STRING_ATOMS); - return read_Text( buf, inp, enc, minimal, lengp PASS_REGS); } else { LOCAL_Error_TYPE = gen_type_error( inp->type ); LOCAL_Error_Term = t;