Merge branch 'master' of git.dcc.fc.up.pt:yap-6.3

This commit is contained in:
Ricardo Rocha 2012-04-23 18:57:14 +01:00
commit cd5e1211c5
2 changed files with 29 additions and 22 deletions

View File

@ -1530,7 +1530,6 @@ p_atom_concat( USES_REGS1 )
{
Term t1;
int wide_mode = FALSE;
UInt sz;
restart:
t1 = Deref(ARG1);
@ -1543,8 +1542,9 @@ p_atom_concat( USES_REGS1 )
if (wide_mode) {
wchar_t *cptr = (wchar_t *)(((AtomEntry *)Yap_PreAllocCodeSpace())->StrOfAE), *cpt0;
wchar_t *top = (wchar_t *)AuxSp;
char *atom_str;
unsigned char *atom_str;
Atom ahead;
UInt sz;
cpt0 = cptr;
while (IsPairTerm(t1)) {
@ -1560,26 +1560,29 @@ p_atom_concat( USES_REGS1 )
return(FALSE);
}
ahead = AtomOfTerm(thead);
atom_str = RepAtom(ahead)->StrOfAE;
if (IsWideAtom(ahead)) {
/* check for overflows */
sz = wcslen((wchar_t *)atom_str);
sz = wcslen(RepAtom(ahead)->WStrOfAE);
} else {
sz = strlen(atom_str);
atom_str = (unsigned char *)RepAtom(ahead)->StrOfAE;
sz = strlen((char *)atom_str);
}
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, LOCAL_ErrorMessage);
if (cptr+sz > top+1024) {
cptr = (wchar_t *)Yap_ExpandPreAllocCodeSpace(sz+1024,NULL, TRUE);
if (cptr+sz > (wchar_t *)AuxSp+1024) {
/* crash in flames */
Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "allocating temp space in atom_concat/2");
return FALSE;
}
top = (wchar_t *)AuxSp;
goto restart;
}
if (IsWideAtom(ahead)) {
memcpy((void *)cptr, (void *)atom_str, sz*sizeof(wchar_t));
memcpy((void *)cptr, RepAtom(ahead)->WStrOfAE, sz*sizeof(wchar_t));
cptr += sz;
} else {
int i;
UInt i;
for (i=0; i < sz; i++) {
*cptr++ = *atom_str++;
}
@ -1607,7 +1610,8 @@ p_atom_concat( USES_REGS1 )
} else {
char *cptr = ((AtomEntry *)Yap_PreAllocCodeSpace())->StrOfAE, *cpt0;
char *top = (char *)AuxSp;
char *atom_str;
unsigned char *atom_str;
UInt sz;
cpt0 = cptr;
while (IsPairTerm(t1)) {
@ -1627,9 +1631,9 @@ p_atom_concat( USES_REGS1 )
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
goto restart;
}
atom_str = RepAtom(AtomOfTerm(thead))->StrOfAE;
atom_str = (unsigned char *)RepAtom(AtomOfTerm(thead))->StrOfAE;
/* check for overflows */
sz = strlen(atom_str);
sz = strlen((char *)atom_str);
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
@ -1725,9 +1729,9 @@ p_atomic_concat( USES_REGS1 )
memcpy((void *)wcptr, (void *)watom_str, sz*sizeof(wchar_t));
wcptr += sz;
} else {
char *atom_str = RepAtom(AtomOfTerm(thead))->StrOfAE;
unsigned char *atom_str = (unsigned char *)RepAtom(AtomOfTerm(thead))->StrOfAE;
/* check for overflows */
UInt sz = strlen(atom_str);
UInt sz = strlen((char *)atom_str);
if (wcptr+sz >= wtop-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {
@ -1823,7 +1827,7 @@ p_atomic_concat( USES_REGS1 )
return(FALSE);
}
if (IsAtomTerm(thead)) {
char *atom_str;
unsigned char *atom_str;
UInt sz;
if (IsWideAtom(AtomOfTerm(thead))) {
@ -1831,9 +1835,9 @@ p_atomic_concat( USES_REGS1 )
wide_mode = TRUE;
goto restart;
}
atom_str = RepAtom(AtomOfTerm(thead))->StrOfAE;
atom_str = (unsigned char *)RepAtom(AtomOfTerm(thead))->StrOfAE;
/* check for overflows */
sz = strlen(atom_str);
sz = strlen((char *)atom_str);
if (cptr+sz >= top-1024) {
Yap_ReleasePreAllocCodeSpace((ADDR)cpt0);
if (!Yap_growheap(FALSE, sz+1024, NULL)) {

View File

@ -18,11 +18,9 @@
static char SccsId[] = "@(#)utilpreds.c 1.3";
#endif
#include "Yap.h"
#include "clause.h"
#include "absmi.h"
#include "YapHeap.h"
#include "yapio.h"
#include "eval.h"
#include "attvar.h"
#ifdef HAVE_STRING_H
#include "string.h"
@ -4370,6 +4368,10 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end
goto trail_overflow;
}
}
#if defined(TABLING) || defined(YAPOR_SBA)
TrailVal(TR) = (CELL)ptd0;
#endif
TrailTerm(TR++) = (CELL)ptd0;
}
/* Do we still have compound terms to visit */
@ -4387,6 +4389,7 @@ static Int numbervars_in_complex_term(register CELL *pt0, register CELL *pt0_end
goto loop;
}
prune(B);
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0);
return numbv;