make sure that we don't have tails of lists with local variables.
This commit is contained in:
parent
834e3ed5d0
commit
68a1ab6ce7
@ -1175,6 +1175,7 @@ Yap_StringToDiffList(char *s, Term t)
|
||||
{
|
||||
register unsigned char *cp = (unsigned char *)s + strlen(s);
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
while (cp > (unsigned char *)s) {
|
||||
t = MkPairTerm(MkIntTerm(*--cp), t);
|
||||
}
|
||||
@ -1186,6 +1187,7 @@ Yap_NStringToDiffList(char *s, Term t, size_t len)
|
||||
{
|
||||
register unsigned char *cp = (unsigned char *)s + len;
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
while (cp > (unsigned char *)s) {
|
||||
t = MkPairTerm(MkIntTerm(*--cp), t);
|
||||
}
|
||||
@ -1197,6 +1199,7 @@ Yap_WideStringToDiffList(wchar_t *s, Term t)
|
||||
{
|
||||
wchar_t *cp = s + wcslen(s);
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
while (cp > s) {
|
||||
t = MkPairTerm(MkIntegerTerm(*--cp), t);
|
||||
}
|
||||
@ -1208,6 +1211,7 @@ Yap_NWideStringToDiffList(wchar_t *s, Term t, size_t len)
|
||||
{
|
||||
wchar_t *cp = s + len;
|
||||
|
||||
t = Yap_Globalise(t);
|
||||
while (cp > s) {
|
||||
t = MkPairTerm(MkIntegerTerm(*--cp), t);
|
||||
}
|
||||
@ -1286,7 +1290,7 @@ Yap_NWideStringToDiffListOfAtoms(wchar_t *s, Term t0, size_t len)
|
||||
wchar_t *cp = s + len;
|
||||
|
||||
so[1] = '\0';
|
||||
t = t0;
|
||||
t = Yap_Globalise(t0);
|
||||
while (cp > s) {
|
||||
so[0] = *--cp;
|
||||
t = MkPairTerm(MkAtomTerm(LookupWideAtom(so)), t);
|
||||
|
15
C/other.c
15
C/other.c
@ -100,3 +100,18 @@ Yap_MkNewApplTerm(Functor f, unsigned int n)
|
||||
}
|
||||
|
||||
|
||||
Term
|
||||
Yap_Globalise(Term t)
|
||||
{
|
||||
CELL *vt;
|
||||
Term tn;
|
||||
|
||||
if (!IsVarTerm(t))
|
||||
return t;
|
||||
vt = VarOfTerm(t);
|
||||
if (vt <= H && vt > H0)
|
||||
return t;
|
||||
tn = MkVarTerm();
|
||||
Yap_unify(t, tn);
|
||||
return tn;
|
||||
}
|
||||
|
@ -295,6 +295,7 @@ void STD_PROTO(Yap_InitMPE,(void));
|
||||
Term STD_PROTO(Yap_MkApplTerm,(Functor,unsigned int,Term *));
|
||||
Term STD_PROTO(Yap_MkNewApplTerm,(Functor,unsigned int));
|
||||
Term STD_PROTO(Yap_MkNewPairTerm,(void));
|
||||
Term STD_PROTO(Yap_Globalise,(Term));
|
||||
|
||||
|
||||
/* parser.c */
|
||||
|
Reference in New Issue
Block a user