Avoid complaining from strlen

`
This commit is contained in:
Vítor Santos Costa 2015-09-21 17:05:36 -05:00
parent 880a9989c3
commit 4336b2ba88
469 changed files with 207364 additions and 9193 deletions

View File

@ -42,7 +42,7 @@ BOp(Ystop, l);
\************************************************************************/
#if YAP_JIT
static void *OpAddress[] =
static void *OpAddress_JIT[] =
{
#define OPCODE(OP,TYPE) && _##OP
#include "YapOpcodes.h"

View File

@ -106,13 +106,13 @@ Yap_MkFunctorWithAddress(Atom ap, unsigned int arity, FunctorEntry *p)
}
inline static Atom
SearchInInvisible(const char *atom)
SearchInInvisible(const unsigned char *atom)
{
AtomEntry *chain;
READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, atom)) {
while (!EndOfPAEntr(chain) && strcmp((char *)chain->StrOfAE, (char *)atom)) {
chain = RepAtom(chain->NextOfAE);
}
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
@ -123,13 +123,13 @@ SearchInInvisible(const char *atom)
}
static inline Atom
SearchAtom(const char *p, Atom a) {
SearchAtom(const unsigned char *p, Atom a) {
AtomEntry *ae;
/* search atom in chain */
while (a != NIL) {
ae = RepAtom(a);
if (strcmp(ae->StrOfAE, (const char *)p) == 0) {
if (strcmp((char *)ae->StrOfAE, (const char *)p) == 0) {
return(a);
}
a = ae->NextOfAE;
@ -153,10 +153,10 @@ SearchWideAtom(const wchar_t *p, Atom a) {
}
static Atom
LookupAtom(const char *atom)
LookupAtom(const unsigned char *atom)
{ /* lookup atom in atom table */
UInt hash;
const char *p;
const unsigned char *p;
Atom a, na;
AtomEntry *ae;
@ -188,7 +188,7 @@ LookupAtom(const char *atom)
}
#endif
/* add new atom to start of chain */
ae = (AtomEntry *) Yap_AllocAtomSpace((sizeof *ae) + strlen(atom) + 1);
ae = (AtomEntry *) Yap_AllocAtomSpace((sizeof *ae) + strlen((const char *)atom) + 1);
if (ae == NULL) {
WRITE_UNLOCK(HashChain[hash].AERWLock);
return NIL;
@ -196,8 +196,8 @@ LookupAtom(const char *atom)
NOfAtoms++;
na = AbsAtom(ae);
ae->PropsOfAE = NIL;
if (ae->StrOfAE != atom)
strcpy(ae->StrOfAE, atom);
if (ae->UStrOfAE != atom)
strcpy((char *)ae->StrOfAE, (const char *)atom);
ae->NextOfAE = a;
HashChain[hash].Entry = na;
INIT_RWLOCK(ae->ARWLock);
@ -282,7 +282,7 @@ Yap_LookupMaybeWideAtom(const wchar_t *atom)
{ /* lookup atom in atom table */
wchar_t *p = (wchar_t *)atom, c;
size_t len = 0;
char *ptr, *ptr0;
unsigned char *ptr, *ptr0;
Atom at;
while ((c = *p++)) {
@ -332,9 +332,9 @@ Yap_LookupMaybeWideAtomWithLength(const wchar_t *atom, size_t len0)
Yap_FreeCodeSpace((char *)ptr0);
return at;
} else {
char *ptr0;
unsigned char *ptr0;
ptr0 = (char *)Yap_AllocCodeSpace((len0+1));
ptr0 = Yap_AllocCodeSpace((len0+1));
if (!ptr0)
return NIL;
for (i=0;i<len0;i++)
@ -347,10 +347,10 @@ Yap_LookupMaybeWideAtomWithLength(const wchar_t *atom, size_t len0)
}
Atom
Yap_LookupAtomWithLength(const char *atom, size_t len0)
Yap_LookupAtomWithLength(const char *atom, size_t len0)
{ /* lookup atom in atom table */
Atom at;
char *ptr;
unsigned char *ptr;
/* not really a wide atom */
ptr = Yap_AllocCodeSpace(len0+1);
@ -364,7 +364,13 @@ Yap_LookupAtomWithLength(const char *atom, size_t len0)
}
Atom
Yap_LookupAtom(const char *atom)
Yap_LookupAtom(const char *atom)
{ /* lookup atom in atom table */
return LookupAtom((const unsigned char *)atom);
}
Atom
Yap_ULookupAtom(const unsigned char *atom)
{ /* lookup atom in atom table */
return LookupAtom(atom);
}
@ -380,10 +386,10 @@ Yap_FullLookupAtom(const char *atom)
{ /* lookup atom in atom table */
Atom t;
if ((t = SearchInInvisible(atom)) != NIL) {
if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) {
return (t);
}
return(LookupAtom(atom));
return(LookupAtom((const unsigned char *)atom));
}
void
@ -391,11 +397,11 @@ Yap_LookupAtomWithAddress(const char *atom,
AtomEntry *ae)
{ /* lookup atom in atom table */
register CELL hash;
register const char *p;
register const unsigned char *p;
Atom a;
/* compute hash */
p = atom;
p = (const unsigned char *)atom;
hash = HashFunction(p) % AtomHashTableSize;
/* ask for a WRITE lock because it is highly unlikely we shall find anything */
WRITE_LOCK(HashChain[hash].AERWLock);
@ -411,7 +417,7 @@ Yap_LookupAtomWithAddress(const char *atom,
ae->NextOfAE = a;
HashChain[hash].Entry = AbsAtom(ae);
ae->PropsOfAE = NIL;
strcpy(ae->StrOfAE, atom);
strcpy((char *)ae->StrOfAE, (char *)atom);
INIT_RWLOCK(ae->ARWLock);
WRITE_UNLOCK(HashChain[hash].AERWLock);
}
@ -420,10 +426,10 @@ void
Yap_ReleaseAtom(Atom atom)
{ /* Releases an atom from the hash chain */
register Int hash;
register const char *p;
register const unsigned char *p;
AtomEntry *inChain;
AtomEntry *ap = RepAtom(atom);
char *name = ap->StrOfAE;
char unsigned *name = ap->UStrOfAE;
/* compute hash */
p = name;

View File

@ -437,6 +437,7 @@ clean_atom_list(AtomHashEntry *HashPtr)
fprintf(stderr, "Purged %p:%s patm=%p %p\n", at, at->StrOfAE, patm, at->NextOfAE);
#endif
GLOBAL_agc_collected += sizeof(AtomEntry)+strlen(at->StrOfAE);
GLOBAL_agc_collected += sizeof(AtomEntry)+strlen((const char *)at->StrOfAE);
}
*patm = atm = at->NextOfAE;
Yap_FreeCodeSpace((char *)at);

View File

@ -151,7 +151,7 @@ call_malloc(size_t size)
return out;
}
char *
void *
Yap_AllocCodeSpace(size_t size)
{
size = AdjustSize(size);
@ -186,15 +186,15 @@ call_realloc(char *p, size_t size)
return out;
}
char *
Yap_ReallocCodeSpace(char *p, size_t size)
void *
Yap_ReallocCodeSpace(void *p, size_t size)
{
size = AdjustSize(size);
return call_realloc(p, size);
}
void
Yap_FreeCodeSpace(char *p)
Yap_FreeCodeSpace(void *p)
{
CACHE_REGS
#if USE_DL_MALLOC
@ -213,7 +213,7 @@ Yap_FreeCodeSpace(char *p)
#endif
}
char *
void *
Yap_AllocAtomSpace(size_t size)
{
size = AdjustSize(size);
@ -221,7 +221,7 @@ Yap_AllocAtomSpace(size_t size)
}
void
Yap_FreeAtomSpace(char *p)
Yap_FreeAtomSpace(void *p)
{
CACHE_REGS
#if USE_DL_MALLOC

View File

@ -260,7 +260,7 @@ static yamop *a_either(op_numbers, CELL, CELL, yamop *, int, struct intermediat
#endif /* YAPOR */
static yamop *a_gl(op_numbers, yamop *, int, struct PSEUDO *, struct intermediates * CACHE_TYPE);
static
COUNT compile_cmp_flags(char *);
COUNT compile_cmp_flags(unsigned char *);
static yamop *a_igl(CELL, op_numbers, yamop *, int, struct intermediates *);
static yamop *a_xigl(op_numbers, yamop *, int, struct PSEUDO *);
static yamop *a_ucons(int *, compiler_vm_op, yamop *, int, struct intermediates *);
@ -1587,8 +1587,10 @@ a_pl(op_numbers opcode, PredEntry *pred, yamop *code_p, int pass_no)
}
static COUNT
compile_cmp_flags(char *s)
compile_cmp_flags(unsigned char *s0)
{
char *s = (char *)s0;
if (strcmp(s,"=<") == 0)
return EQ_OK_IN_CMP|LT_OK_IN_CMP;
if (strcmp(s,"is") == 0)
@ -1621,7 +1623,7 @@ COUNT
Yap_compile_cmp_flags(PredEntry *pred)
{
return
compile_cmp_flags(RepAtom(NameOfFunctor(pred->FunctorOfPred))->StrOfAE);
compile_cmp_flags(RepAtom(NameOfFunctor(pred->FunctorOfPred))->UStrOfAE);
}
static yamop *
@ -1644,7 +1646,7 @@ a_bfunc(CELL a1, CELL a2, PredEntry *pred, clause_info *clinfo, yamop *code_p, i
code_p->y_u.plyys.f = emit_fail(cip);
code_p->y_u.plyys.y1 = v1;
code_p->y_u.plyys.y2 = emit_yreg(var_offset2);
code_p->y_u.plyys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
code_p->y_u.plyys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->UStrOfAE);
}
GONEXT(plyys);
} else {
@ -1654,7 +1656,7 @@ a_bfunc(CELL a1, CELL a2, PredEntry *pred, clause_info *clinfo, yamop *code_p, i
code_p->y_u.plxys.f = emit_fail(cip);
code_p->y_u.plxys.x = emit_xreg(var_offset2);
code_p->y_u.plxys.y = v1;
code_p->y_u.plxys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
code_p->y_u.plxys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->UStrOfAE);
}
GONEXT(plxys);
}
@ -1671,7 +1673,7 @@ a_bfunc(CELL a1, CELL a2, PredEntry *pred, clause_info *clinfo, yamop *code_p, i
code_p->y_u.plxys.f = emit_fail(cip);
code_p->y_u.plxys.x = x1;
code_p->y_u.plxys.y = emit_yreg(var_offset2);
code_p->y_u.plxys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
code_p->y_u.plxys.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->UStrOfAE);
}
GONEXT(plxys);
} else {
@ -1682,7 +1684,7 @@ a_bfunc(CELL a1, CELL a2, PredEntry *pred, clause_info *clinfo, yamop *code_p, i
code_p->y_u.plxxs.f = emit_fail(cip);
code_p->y_u.plxxs.x1 = x1;
code_p->y_u.plxxs.x2 = emit_xreg(var_offset2);
code_p->y_u.plxxs.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->StrOfAE);
code_p->y_u.plxxs.flags = compile_cmp_flags(RepAtom(NameOfFunctor(RepPredProp(((Prop)pred))->FunctorOfPred))->UStrOfAE);
}
GONEXT(plxxs);
}

View File

@ -18,7 +18,7 @@ matchKey(Atom key, xarg *e0, int n, const param_t *def)
{
int i;
for (i=0; i< n; i++) {
if (!strcmp(def->name, RepAtom(key)->StrOfAE)) {
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
return e0;
}
def++;
@ -31,7 +31,9 @@ xarg *
Yap_ArgListToVector (Term listl, const param_t *def, int n)
{
CACHE_REGS
if (!IsPairTerm(listl) && listl != TermNil) {
if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule)
listl = ArgOfTerm(2,listl);
if (!IsPairTerm(listl) && listl != TermNil) {
listl = MkPairTerm( listl, TermNil );
}
xarg *a = calloc( n , sizeof(xarg) );
@ -86,7 +88,7 @@ matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
{
int i;
for (i=0; i< n; i++) {
if (!strcmp(def->name, RepAtom(key)->StrOfAE)) {
if (!strcmp((char*)def->name, (char*)RepAtom(key)->StrOfAE)) {
return e0;
}
def++;

View File

@ -1106,7 +1106,7 @@ p_create_static_array( USES_REGS1 )
Yap_Error(INSTANTIATION_ERROR,tprops,"create static array");
return (FALSE);
} else if (IsAtomTerm(tprops)) {
char *atname = RepAtom(AtomOfTerm(tprops))->StrOfAE;
char *atname = (char *)RepAtom(AtomOfTerm(tprops))->StrOfAE;
if (!strcmp(atname, "int"))
props = array_of_ints;
else if (!strcmp(atname, "dbref"))

View File

@ -64,7 +64,7 @@ static Int number_chars( USES_REGS1 );
static Int number_codes( USES_REGS1 );
static Int current_atom( USES_REGS1 );
static Int cont_current_atom( USES_REGS1 );
static int AlreadyHidden(char *);
static int AlreadyHidden(unsigned char *);
static Int hide( USES_REGS1 );
static Int hidden( USES_REGS1 );
static Int unhide( USES_REGS1 );
@ -72,14 +72,14 @@ static Int unhide( USES_REGS1 );
static int
AlreadyHidden(char *name)
AlreadyHidden(unsigned char *name)
{
AtomEntry *chain;
READ_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
READ_UNLOCK(INVISIBLECHAIN.AERWLock);
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, name) != 0)
while (!EndOfPAEntr(chain) && strcmp((char *)chain->StrOfAE, (char *)name) != 0)
chain = RepAtom(chain->NextOfAE);
if (EndOfPAEntr(chain))
return (FALSE);
@ -108,7 +108,7 @@ hide( USES_REGS1 )
return(FALSE);
}
atomToInclude = AtomOfTerm(t1);
if (AlreadyHidden(RepAtom(atomToInclude)->StrOfAE)) {
if (AlreadyHidden(RepAtom(atomToInclude)->UStrOfAE)) {
Yap_Error(SYSTEM_ERROR,t1,"an atom of name %s was already hidden",
RepAtom(atomToInclude)->StrOfAE);
return(FALSE);
@ -182,7 +182,7 @@ unhide( USES_REGS1 )
WRITE_LOCK(INVISIBLECHAIN.AERWLock);
chain = RepAtom(INVISIBLECHAIN.Entry);
old = NIL;
while (!EndOfPAEntr(chain) && strcmp(chain->StrOfAE, atom->StrOfAE) != 0) {
while (!EndOfPAEntr(chain) && strcmp((char *)chain->StrOfAE, (char *)atom->StrOfAE) != 0) {
old = chain;
chain = RepAtom(chain->NextOfAE);
}
@ -257,7 +257,7 @@ char_code( USES_REGS1 )
}
tf = MkIntegerTerm(c[0]);
} else {
char *c = RepAtom(at)->StrOfAE;
unsigned char *c = RepAtom(at)->UStrOfAE;
if (c[1] != '\0') {
Yap_Error(TYPE_ERROR_CHARACTER,t0,"char_code/2");
@ -377,11 +377,27 @@ string_to_list( USES_REGS1 )
static Int
atom_string( USES_REGS1 )
{
// swap arguments
Term t1 = ARG2;
ARG2 = ARG1;
ARG1 = t1;
return string_to_atom( PASS_REGS1 );
Term t1 = Deref(ARG1), t2 = Deref(ARG2);
LOCAL_MAX_SIZE = 1024;
restart_aux:
if (Yap_IsGroundTerm(t2)) {
Atom at;
// verify if an atom, int, float or bignnum
at = Yap_StringSWIToAtom( t2 PASS_REGS );
if (at)
return Yap_unify(MkAtomTerm(at), t1);
// else
} else {
Term t0 = Yap_AtomSWIToString( t1 PASS_REGS );
if (t0) return Yap_unify(t0, t2);
}
if (LOCAL_Error_TYPE && Yap_HandleError( "atom_string/2" )) {
t1 = Deref(ARG1);
t2 = Deref(ARG2);
goto restart_aux;
}
return FALSE;
}
static Int
@ -839,15 +855,15 @@ cont_string_code3( USES_REGS1 )
{
Term t2;
Int i, j;
int chr;
char *s;
const char *s0;
utf8proc_int32_t chr;
const unsigned char *s;
const unsigned char *s0;
restart_aux:
t2 = Deref(ARG2);
s0 = StringOfTerm( t2 );
s0 = UStringOfTerm( t2 );
i = IntOfTerm(EXTRA_CBACK_ARG(3,1)); // offset in coded string, increases by 1..6
j = IntOfTerm(EXTRA_CBACK_ARG(3,2)); // offset in UNICODE string, always increases by 1
s = utf8_get_char( s0+i, &chr );
s = (s0+i) + get_utf8( (unsigned char *)s0+i, &chr );
if (s[0]) {
EXTRA_CBACK_ARG(3,1) = MkIntTerm(s-s0);
EXTRA_CBACK_ARG(3,2) = MkIntTerm(j+1);
@ -874,7 +890,7 @@ string_code3( USES_REGS1 )
{
Term t1;
Term t2;
const char *s;
const unsigned char *s;
restart_aux:
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -885,7 +901,7 @@ string_code3( USES_REGS1 )
LOCAL_Error_TYPE = TYPE_ERROR_STRING;
LOCAL_Error_Term = t2;
} else {
s = StringOfTerm( t2 );
s = UStringOfTerm( t2 );
t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
EXTRA_CBACK_ARG(3,1) = MkIntTerm(0);
@ -895,8 +911,8 @@ string_code3( USES_REGS1 )
LOCAL_Error_TYPE = TYPE_ERROR_INTEGER;
LOCAL_Error_Term = t1;
} else {
const char *ns = s;
int chr;
const unsigned char *ns = s;
utf8proc_int32_t chr;
Int indx = IntegerOfTerm( t1 );
if (indx <= 0) {
if (indx < 0) {
@ -905,11 +921,11 @@ string_code3( USES_REGS1 )
}
cut_fail();
}
ns = utf8_skip(s,indx);
ns = skip_utf8((unsigned char *)s, indx);
if (ns == NULL) {
cut_fail(); // silently fail?
}
utf8_get_char( ns, &chr);
get_utf8( (unsigned char *)ns, &chr);
if ( chr == '\0') cut_fail();
if (Yap_unify(ARG3, MkIntegerTerm(chr))) cut_succeed();
cut_fail();
@ -932,7 +948,7 @@ get_string_code3( USES_REGS1 )
{
Term t1;
Term t2;
const char *s;
const unsigned char *s;
restart_aux:
t1 = Deref(ARG1);
t2 = Deref(ARG2);
@ -943,7 +959,7 @@ get_string_code3( USES_REGS1 )
LOCAL_Error_TYPE = TYPE_ERROR_STRING;
LOCAL_Error_Term = t2;
} else {
s = StringOfTerm( t2 );
s = UStringOfTerm( t2 );
t1 = Deref(ARG1);
if (IsVarTerm(t1)) {
LOCAL_Error_TYPE = INSTANTIATION_ERROR;
@ -952,8 +968,8 @@ get_string_code3( USES_REGS1 )
LOCAL_Error_TYPE = TYPE_ERROR_INTEGER;
LOCAL_Error_Term = t1;
} else {
const char *ns = s;
int chr;
unsigned char *ns = (unsigned char *)s;
utf8proc_int32_t chr;
Int indx = IntegerOfTerm( t1 );
if (indx <= 0) {
if (indx < 0) {
@ -964,11 +980,11 @@ get_string_code3( USES_REGS1 )
}
} else {
indx -= 1;
ns = utf8_skip(s,indx);
ns = skip_utf8((unsigned char *)s,indx);
if (ns == NULL) {
return FALSE;
} else {
utf8_get_char( ns, &chr);
get_utf8( ns, &chr);
if ( chr != '\0') return Yap_unify(ARG3, MkIntegerTerm(chr));
}
}
@ -1372,13 +1388,13 @@ atom_split( USES_REGS1 )
at = AtomOfTerm(t1);
if (IsWideAtom(at)) {
wchar_t *ws, *ws1 = (wchar_t *)HR;
char *s1 = (char *)HR;
unsigned char *s1 = (unsigned char *)HR;
size_t wlen;
ws = (wchar_t *)RepAtom(at)->StrOfAE;
wlen = wcslen(ws);
if (len > wlen) return FALSE;
if (s1+len > (char *)LCL0-1024)
if (s1+len > (unsigned char *)LCL0-1024)
Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4");
for (i = 0; i< len; i++) {
if (ws[i] > MAX_ISO_LATIN1) {
@ -1405,27 +1421,27 @@ atom_split( USES_REGS1 )
Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4");
ws += len;
while ((*s2++ = *ws++));
to2 = MkAtomTerm(Yap_LookupAtom((char *)HR));
to2 = MkAtomTerm(Yap_LookupAtom(( char *)HR));
}
} else {
s1[len] = '\0';
to1 = MkAtomTerm(Yap_LookupAtom(s1));
to1 = MkAtomTerm(Yap_ULookupAtom(s1));
/* second atom must be wide, if first wasn't */
to2 = MkAtomTerm(Yap_LookupWideAtom(ws+len));
}
} else {
char *s, *s1 = (char *)HR;
unsigned char *s, *s1 = (unsigned char *)HR;
s = RepAtom(at)->StrOfAE;
if (len > (Int)strlen(s)) return(FALSE);
if (s1+len > (char *)ASP-1024)
s = RepAtom(at)->UStrOfAE;
if (len > (Int)strlen((char *)s)) return(FALSE);
if (s1+len > (unsigned char *)ASP-1024)
Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4");
for (i = 0; i< len; i++) {
s1[i] = s[i];
}
s1[len] = '\0';
to1 = MkAtomTerm(Yap_LookupAtom(s1));
to2 = MkAtomTerm(Yap_LookupAtom(s+len));
to1 = MkAtomTerm(Yap_ULookupAtom(s1));
to2 = MkAtomTerm(Yap_ULookupAtom(s+len));
}
return(Yap_unify_constant(ARG3,to1) && Yap_unify_constant(ARG4,to2));
}
@ -1502,7 +1518,7 @@ alloc_tmp_stack(size_t sz USES_REGS) {
}
static Term
build_new_atomic(int mask, wchar_t *wp, char *p, size_t min, size_t len USES_REGS)
build_new_atomic(int mask, wchar_t *wp, const unsigned char *p, size_t min, size_t len USES_REGS)
{
Atom nat;
if (mask & SUB_ATOM_HAS_WIDE) {
@ -1516,27 +1532,28 @@ build_new_atomic(int mask, wchar_t *wp, char *p, size_t min, size_t len USES_REG
if (nat)
return MkAtomTerm(nat);
} else if (!(mask & SUB_ATOM_HAS_UTF8)) {
char *src = p+min;
char *d = alloc_tmp_stack((len+1)*sizeof(char) PASS_REGS);
const unsigned char *src = p+min;
unsigned char *d = alloc_tmp_stack((len+1)*sizeof(char) PASS_REGS);
if (!d) return NIL;
strncpy(d, src, len);
strncpy((char *)d, (char *)src, len);
d[len] = '\0';
nat = Yap_LookupAtom(d);
nat = Yap_ULookupAtom(d);
if (nat)
return MkAtomTerm(nat);
} else {
char *src = p;
const unsigned char *src = p;
unsigned char *buf;
Term t = init_tstring( PASS_REGS1 );
src = (char *)utf8_skip(src, min);
char *cp = src, *buf;
src = skip_utf8((unsigned char *)src, min);
const unsigned char *cp = src;
LOCAL_TERM_ERROR( 4*(len+1) );
buf = buf_from_tstring(HR);
while (len) {
int chr;
cp = utf8_get_char(cp, &chr);
buf = utf8_put_char(buf, chr);
utf8proc_int32_t chr;
cp += get_utf8((unsigned char *)cp, &chr);
buf += put_utf8((unsigned char *)buf, chr);
len--;
}
*buf++ = '\0';
@ -1570,17 +1587,17 @@ check_sub_atom_at(int min, Atom at, Atom nat)
} else {
if (IsWideAtom(at)) {
wchar_t *p1;
char *p2;
unsigned char *p2;
wchar_t c1;
p1 = RepAtom(at)->WStrOfAE+min;
p2 = RepAtom(nat)->StrOfAE;
p2 = RepAtom(nat)->UStrOfAE;
while ( (c1 = *p1++) == *p2++ && c1);
return c1 == 0;
} else {
char *p1, *p2;
unsigned char *p1, *p2;
char c1;
p1 = RepAtom(at)->StrOfAE+min;
p2 = RepAtom(nat)->StrOfAE;
p1 = RepAtom(at)->UStrOfAE+min;
p2 = RepAtom(nat)->UStrOfAE;
while ( (c1 = *p1++) == *p2++ && c1);
return c1 == 0;
}
@ -1588,10 +1605,10 @@ check_sub_atom_at(int min, Atom at, Atom nat)
}
static int
check_sub_string_at(int min, const char *p1, const char *p2, size_t len2)
check_sub_string_at(int min, const unsigned char *p1, const unsigned char *p2, size_t len)
{
p1 = utf8_skip(p1, min);
return utf8_strncmp( p1, p2, len2 ) == 0;
p1 = skip_utf8((unsigned char *)p1, min);
return cmpn_utf8( p1, p2, len ) == 0;
}
static int
@ -1610,22 +1627,22 @@ check_sub_atom_bef(int max, Atom at, Atom nat)
while ( (c1 = *p1++) == *p2++ && c1);
return c1 == 0;
} else {
size_t len = strlen(RepAtom(nat)->StrOfAE);
size_t len = strlen((char *)RepAtom(nat)->StrOfAE);
int min = max- len;
if ((Int)(min - len) < 0) return FALSE;
if (IsWideAtom(at)) {
wchar_t *p1;
char *p2;
unsigned char *p2;
wchar_t c1;
p1 = RepAtom(at)->WStrOfAE+min;
p2 = RepAtom(nat)->StrOfAE;
p2 = RepAtom(nat)->UStrOfAE;
while ( (c1 = *p1++) == *p2++ && c1);
return c1 == 0;
} else {
char *p1, *p2;
unsigned char *p1, *p2;
char c1;
p1 = RepAtom(at)->StrOfAE+min;
p2 = RepAtom(nat)->StrOfAE;
p1 = RepAtom(at)->UStrOfAE+min;
p2 = RepAtom(nat)->UStrOfAE;
while ( (c1 = *p1++) == *p2++ && c1);
return c1 == 0;
}
@ -1635,15 +1652,15 @@ check_sub_atom_bef(int max, Atom at, Atom nat)
static int
check_sub_string_bef(int max, Term at, Term nat)
{
size_t len = utf8_strlen1(StringOfTerm(nat));
size_t len = strlen_utf8(UStringOfTerm(nat));
int min = max- len;
const char *p1, *p2;
const unsigned char *p1, *p2;
int c1;
if ((Int)(min - len) < 0) return FALSE;
p1 = utf8_skip(StringOfTerm(at),min);
p2 = StringOfTerm(nat);
p1 = skip_utf8((unsigned char *)UStringOfTerm(at),min);
p2 = UStringOfTerm(nat);
while ( (c1 = *p1++) == *p2++ && c1);
return c1 == 0;
}
@ -1656,7 +1673,7 @@ cont_sub_atomic( USES_REGS1 )
int mask;
size_t min, len, after, sz;
wchar_t *wp = NULL;
char *p = NULL;
const unsigned char *p = NULL;
Term nat;
int sub_atom = TRUE;
@ -1668,13 +1685,13 @@ cont_sub_atomic( USES_REGS1 )
if (mask & SUB_ATOM_HAS_UTF8) {
sub_atom = FALSE;
p = (char *)StringOfTerm(tat1);
p = UStringOfTerm(tat1);
} else if (mask & SUB_ATOM_HAS_WIDE) {
at = AtomOfTerm(tat1);
wp = RepAtom(at)->WStrOfAE;
} else {
at = AtomOfTerm(tat1);
p = RepAtom(at)->StrOfAE;
p = RepAtom(at)->UStrOfAE;
}
/* we can have one of two cases: A5 bound or unbound */
if (mask & SUB_ATOM_HAS_VAL) {
@ -1704,7 +1721,7 @@ cont_sub_atomic( USES_REGS1 )
}
} else {
while (!found) {
if (wcsstrcmp(wp+min, AtomOfTerm(nat)->StrOfAE, len) == 0) {
if (wcsstrcmp(wp+min, (char *)AtomOfTerm(nat)->StrOfAE, len) == 0) {
Yap_unify(ARG2, MkIntegerTerm(min));
Yap_unify(ARG3, MkIntegerTerm(len));
Yap_unify(ARG4, MkIntegerTerm(after));
@ -1713,7 +1730,7 @@ cont_sub_atomic( USES_REGS1 )
while (min <= sz-len) {
after--;
min++;
if (wcsstrcmp(wp+min, AtomOfTerm(nat)->StrOfAE, len) == 0)
if (wcsstrcmp(wp+min, (char *)AtomOfTerm(nat)->StrOfAE, len) == 0)
break;
}
} else {
@ -1724,9 +1741,9 @@ cont_sub_atomic( USES_REGS1 )
}
}
} else if (sub_atom) {
p = RepAtom(at)->StrOfAE;
p = RepAtom(at)->UStrOfAE;
while (!found) {
if (strncmp(p+min, AtomOfTerm(nat)->StrOfAE, len) == 0) {
if (strncmp((char *)p+min, (char *)AtomOfTerm(nat)->StrOfAE, len) == 0) {
Yap_unify(ARG2, MkIntegerTerm(min));
Yap_unify(ARG3, MkIntegerTerm(len));
Yap_unify(ARG4, MkIntegerTerm(after));
@ -1735,7 +1752,7 @@ cont_sub_atomic( USES_REGS1 )
while (min <= sz-len) {
after--;
min++;
if (strncmp(p+min, AtomOfTerm(nat)->StrOfAE, len) == 0)
if (strncmp((char *)p+min, (char *)AtomOfTerm(nat)->StrOfAE, len) == 0)
break;
}
} else {
@ -1745,12 +1762,12 @@ cont_sub_atomic( USES_REGS1 )
}
}
} else {
const char *p = StringOfTerm( Deref(ARG1) ), *p1 = p;
const char *p5 = StringOfTerm( Deref(ARG5) );
const unsigned char *p = UStringOfTerm( Deref(ARG1) ), *p1 = p;
const unsigned char *p5 = UStringOfTerm( Deref(ARG5) );
while (!found) {
p = utf8_skip(p1, min);
if (utf8_strncmp(p, p5, len) == 0) {
p = skip_utf8((unsigned char *)p1, min);
if (cmpn_utf8(p, p5, len) == 0) {
Yap_unify(ARG2, MkIntegerTerm(min));
Yap_unify(ARG3, MkIntegerTerm(len));
Yap_unify(ARG4, MkIntegerTerm(after));
@ -1758,10 +1775,10 @@ cont_sub_atomic( USES_REGS1 )
/* found one, check if there is any left */
while (min <= sz-len) {
int chr;
p = utf8_get_char(p, &chr);
p += get_utf8((unsigned char *)p, &chr);
after--;
min++;
if (utf8_strncmp(p, StringOfTerm(nat), len) == 0)
if (cmpn_utf8(p, UStringOfTerm(nat), len) == 0)
break;
}
} else {
@ -1828,7 +1845,7 @@ sub_atomic( int sub_atom USES_REGS )
int mask = 0;
size_t min, len, after, sz;
wchar_t *wp = NULL;
char *p = NULL;
unsigned char *p = NULL;
int bnds = 0;
Term nat = 0L;
Atom at = NULL;
@ -1900,7 +1917,7 @@ sub_atomic( int sub_atom USES_REGS )
if (IsWideAtom(oat))
len = wcslen(RepAtom(oat)->WStrOfAE);
else
len = strlen(RepAtom(oat)->StrOfAE);
len = strlen((const char *)RepAtom(oat)->StrOfAE);
}
} else {
if (!IsStringTerm(tout)) {
@ -1908,7 +1925,7 @@ sub_atomic( int sub_atom USES_REGS )
return FALSE;
} else {
mask |= SUB_ATOM_HAS_VAL|SUB_ATOM_HAS_SIZE;
len = utf8_strlen1( StringOfTerm(tout) );
len = strlen_utf8( UStringOfTerm(tout) );
}
}
if (!Yap_unify(ARG3, MkIntegerTerm(len)))
@ -1922,13 +1939,13 @@ sub_atomic( int sub_atom USES_REGS )
wp = RepAtom(at)->WStrOfAE;
sz = wcslen(wp);
} else {
p = RepAtom(at)->StrOfAE;
sz = strlen(p);
p = RepAtom(at)->UStrOfAE;
sz = strlen((const char *)p);
}
} else {
mask |= SUB_ATOM_HAS_UTF8;
p = (char *)StringOfTerm(tat1);
sz = utf8_strlen1(p);
p = (unsigned char *)StringOfTerm(tat1);
sz = strlen_utf8(p);
}
/* the problem is deterministic if we have two cases */
if (bnds > 1) {
@ -1963,7 +1980,7 @@ sub_atomic( int sub_atom USES_REGS )
if (sub_atom)
out = check_sub_atom_at(min, at, AtomOfTerm(nat));
else
out = check_sub_string_at(min, p, StringOfTerm( nat ), len);
out = check_sub_string_at(min, p, UStringOfTerm( nat ), len);
} else if ((mask & (SUB_ATOM_HAS_AFTER|SUB_ATOM_HAS_VAL)) ==
(SUB_ATOM_HAS_AFTER|SUB_ATOM_HAS_VAL)) {
if (sub_atom)
@ -1973,7 +1990,7 @@ sub_atomic( int sub_atom USES_REGS )
} else if ((mask & (SUB_ATOM_HAS_SIZE|SUB_ATOM_HAS_VAL)) ==
(SUB_ATOM_HAS_SIZE|SUB_ATOM_HAS_VAL)) {
if (!sub_atom) {
out = (utf8_strlen1(StringOfTerm(tout)) == len);
out = (strlen_utf8(UStringOfTerm(tout)) == len);
if (!out) cut_fail();
} else if (IsWideAtom(AtomOfTerm(tout))) {
if (!(mask & SUB_ATOM_HAS_VAL)) {
@ -1982,7 +1999,7 @@ sub_atomic( int sub_atom USES_REGS )
/* just check length, they may still be several occurrences :( */
out = (wcslen(RepAtom(AtomOfTerm(tout))->WStrOfAE) == len);
} else {
out = (strlen(RepAtom(AtomOfTerm(tout))->StrOfAE) == len);
out = (strlen((const char *)RepAtom(AtomOfTerm(tout))->StrOfAE) == len);
if (!out) cut_fail();
}
if (len == sz) {

View File

@ -26,7 +26,7 @@ static char SccsId[] = "%W% %G%";
#endif
#include "YapHeap.h"
#include "pl-utf8.h"
#include "YapText.h"
#ifdef USE_GMP
@ -363,13 +363,13 @@ Yap_OpaqueTermToString(Term t, char *str, size_t max)
if (li[0] == (CELL)FunctorString) {
str_index += sprintf(& str[str_index], "\"");
do {
int chr;
char *ptr = (char *)StringOfTerm(AbsAppl(li));
ptr = utf8_get_char(ptr, &chr);
utf8proc_int32_t chr;
unsigned char *ptr = (unsigned char *)StringOfTerm(AbsAppl(li));
ptr += get_utf8(ptr, &chr);
if (chr == '\0') break;
str_index += sprintf(& str[str_index], "%C", chr);
str_index += sprintf(str+str_index, "%C", chr);
} while (TRUE);
str_index += sprintf(& str[str_index], "\"");
str_index += sprintf(str+str_index, "\"");
} else {
CELL big_tag = li[1];

View File

@ -46,7 +46,7 @@ char * Yap_blob_to_string(AtomEntry *ref, const char *s0, size_t sz)
fclose(f); // return the final result.
return s;
} else {
size_t sz0 = strlcpy( s, RepAtom( AtomSWIStream )->StrOfAE, sz);
size_t sz0 = strlcpy( s, (char *)RepAtom( AtomSWIStream )->StrOfAE, sz);
s = s+sz0;
sz -= sz0;
#if defined(__linux__) || defined(__APPLE__)
@ -222,7 +222,7 @@ YAP_blob_data(Atom x, size_t *len, blob_type_t **type)
return x->WStrOfAE;
}
if ( len )
*len = strlen(x->StrOfAE);
*len = strlen((char *)x->StrOfAE);
if ( type )
*type = &unregistered_blob_atom;
return x->StrOfAE;

View File

@ -793,7 +793,7 @@ YAP_LookupAtom(const char *c)
Atom a;
while (TRUE) {
a = Yap_LookupAtom((char *)c);
a = Yap_LookupAtom(c);
if (a == NIL || Yap_get_signal(YAP_CDOVF_SIGNAL)) {
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
@ -831,7 +831,7 @@ YAP_FullLookupAtom(const char *c)
Atom at;
while (TRUE) {
at = Yap_FullLookupAtom((char *)c);
at = Yap_FullLookupAtom(c);
if (at == NIL || Yap_get_signal(YAP_CDOVF_SIGNAL)) {
if (!Yap_locked_growheap(FALSE, 0, NULL)) {
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", LOCAL_ErrorMessage);
@ -854,9 +854,9 @@ YAP_AtomNameLength(Atom at)
return wcslen(c);
} else {
char *c = RepAtom(at)->StrOfAE;
unsigned char *c = RepAtom(at)->UStrOfAE;
return strlen(c);
return strlen((char *)c);
}
}

1830
C/cdmgr.c

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ cmp_atoms(Atom a1, Atom a2)
}
return *s1-*s2;
} else {
return strcmp(RepAtom(a1)->StrOfAE,RepAtom(a2)->StrOfAE);
return strcmp((char *)RepAtom(a1)->StrOfAE,(char *)RepAtom(a2)->StrOfAE);
}
}
@ -181,7 +181,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
goto done;
} else if (IsStringTerm(d0)) {
if (IsStringTerm(d1)){
out = strcmp(StringOfTerm(d0) , StringOfTerm(d1));
out = strcmp((char *)StringOfTerm(d0) , (char *)StringOfTerm(d1));
} else if (IsIntTerm(d1))
out = 1;
else if (IsFloatTerm(d1)) {
@ -242,7 +242,7 @@ static int compare_complex(register CELL *pt0, register CELL *pt0_end, register
if (IsExtensionFunctor(f))
out = 1;
else if (!(out = 2-ArityOfFunctor(f)))
out = strcmp(".",RepAtom(NameOfFunctor(f))->StrOfAE);
out = strcmp(".",(char *)RepAtom(NameOfFunctor(f))->StrOfAE);
} else out = 1;
goto done;
}
@ -411,7 +411,7 @@ compare(Term t1, Term t2) /* compare terms t1 and t2 */
else {
int out;
if (!(out = 2-ArityOfFunctor(f)))
out = strcmp(".",RepAtom(NameOfFunctor(f))->StrOfAE);
out = strcmp(".",(char *)RepAtom(NameOfFunctor(f))->StrOfAE);
return(out);
}
}
@ -488,7 +488,7 @@ compare(Term t1, Term t2) /* compare terms t1 and t2 */
case db_ref_e:
return 1;
case string_e:
return strcmp(StringOfTerm(t1), StringOfTerm(t2));
return strcmp((char *)StringOfTerm(t1), (char *)StringOfTerm(t2));
}
return -1;
}
@ -507,7 +507,7 @@ compare(Term t1, Term t2) /* compare terms t1 and t2 */
Functor f = FunctorOfTerm(t1);
if (!(out = ArityOfFunctor(f))-2)
out = strcmp(RepAtom(NameOfFunctor(f))->StrOfAE,".");
out = strcmp((char *)RepAtom(NameOfFunctor(f))->StrOfAE,".");
return out;
}
return 1;

View File

@ -605,7 +605,6 @@ ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc)
case 'a':
case 'n':
case 'S':
Yap_DebugPlWrite ((Term) arg);
break;
case 'b':
@ -674,6 +673,10 @@ ShowOp (compiler_vm_op ic, const char *f, struct PSEUDO *cpc)
Yap_DebugErrorPutc ('A');
Yap_DebugPlWrite (MkIntTerm (rn));
break;
case 'S':
Yap_DebugErrorPutc ('S');
Yap_DebugPlWrite (MkIntTerm (rn));
break;
case 'h':
{
CELL my_arg = *cptr++;

View File

@ -153,7 +153,7 @@ static int can_unify_complex(register CELL *pt0,
if (FloatOfTerm(d0) == FloatOfTerm(d1)) continue;
goto comparison_failed;
case (CELL)FunctorString:
if (strcmp(StringOfTerm(d0), StringOfTerm(d1)) == 0) continue;
if (strcmp((char *)StringOfTerm(d0), (char *)StringOfTerm(d1)) == 0) continue;
goto comparison_failed;
#ifdef USE_GMP
case (CELL)FunctorBigInt:
@ -292,7 +292,7 @@ can_unify(Term t1, Term t2, Term *Vars USES_REGS)
if (RepAppl(t1)[1] == RepAppl(t2)[1]) return(TRUE);
return FALSE;
case (CELL)FunctorString:
if (strcmp(StringOfTerm(t1), StringOfTerm(t2)) == 0) return(TRUE);
if (strcmp((char *)StringOfTerm(t1), (char *)StringOfTerm(t2)) == 0) return(TRUE);
return FALSE;
case (CELL)FunctorDouble:
if (FloatOfTerm(t1) == FloatOfTerm(t2)) return(TRUE);

View File

@ -743,7 +743,7 @@ Yap_Error(yap_error_number type, Term where, const char *format,...)
Yap_signal(YAP_FAIL_SIGNAL);
P = FAILCODE;
} else {
if (IsVarTerm(where)) {
if (IsVarTerm(where)) {
/* we must be careful someone gave us a copy to a local variable */
Term t = MkVarTerm();
Yap_unify(t, where);
@ -754,7 +754,7 @@ Yap_Error(yap_error_number type, Term where, const char *format,...)
LOCAL_CurrentError = type;
LOCAL_PrologMode |= InErrorMode;
if (!(where = Yap_CopyTerm(where))) {
where = TermNil;
where = TermNil;
}
}
va_start (ap, format);
@ -859,13 +859,27 @@ Yap_Error(yap_error_number type, Term where, const char *format,...)
serious = TRUE;
}
break;
case DOMAIN_ERROR_ARRAY_TYPE:
case DOMAIN_ERROR_FILE_ERRORS:
{
int i;
Term ti[2];
i = strlen(tmpbuf);
ti[0] = MkAtomTerm(AtomArrayType);
ti[0] = TermArrayType;
ti[1] = where;
nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti);
psize -= i;
fun = FunctorError;
serious = TRUE;
}
break;
case DOMAIN_ERROR_FILE_TYPE:
{
int i;
Term ti[2];
i = strlen(tmpbuf);
ti[0] = TermFileType;
ti[1] = where;
nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti);
psize -= i;
@ -879,7 +893,7 @@ Yap_Error(yap_error_number type, Term where, const char *format,...)
Term ti[2];
i = strlen(tmpbuf);
ti[0] = MkAtomTerm(AtomIOMode);
ti[0] = TermIOMode;
ti[1] = where;
nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti);
psize -= i;
@ -1041,6 +1055,20 @@ Yap_Error(yap_error_number type, Term where, const char *format,...)
serious = TRUE;
}
break;
case DOMAIN_ERROR_SOLUTIONS:
{
int i;
Term ti[2];
i = strlen(tmpbuf);
ti[0] = TermSolutions;
ti[1] = where;
nt[0] = Yap_MkApplTerm(FunctorDomainError, 2, ti);
psize -= i;
fun = FunctorError;
serious = TRUE;
}
break;
case DOMAIN_ERROR_SOURCE_SINK:
{
int i;
@ -1729,6 +1757,7 @@ Yap_Error(yap_error_number type, Term where, const char *format,...)
i = strlen(tmpbuf);
psize -= i;
fun = FunctorSyntaxError;
serious = false;
}