chaeacters mostly

This commit is contained in:
Vitor Santos Costa 2017-10-18 01:02:52 +01:00
parent af38546a0d
commit 7dab812d64
10 changed files with 1185 additions and 1188 deletions

View File

@ -27,6 +27,7 @@ static char SccsId[] = "%W% %G%";
#include "Yap.h"
#include "Yatom.h"
#include "clause.h"
#include "alloc.h"
#include "yapio.h"
#include <stdio.h>
#include <wchar.h>
@ -183,12 +184,17 @@ LookupAtom(const unsigned char *atom) { /* lookup atom in atom table */
}
#endif
/* add new atom to start of chain */
size_t asz = strlen((const char *)atom);
ae = (AtomEntry *)Yap_AllocAtomSpace((sizeof *ae) + asz+1);
sz = strlen((const char *)atom);
size_t asz = (sizeof *ae) + ( sz+1);
ae = malloc(asz);
if (ae == NULL) {
WRITE_UNLOCK(HashChain[hash].AERWLock);
return NIL;
}
// enable fast hashing by making sure that
// the last cell is fully initialized.
CELL *aec = (CELL*)ae;
aec[asz/(YAP_ALIGN+1)-1] = 0;
NOfAtoms++;
na = AbsAtom(ae);
ae->PropsOfAE = NIL;
@ -219,28 +225,28 @@ Atom Yap_LookupAtomWithLength(const char *atom,
at = LookupAtom(ptr);
Yap_FreeCodeSpace(ptr);
return at;
}
}
Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */
Atom Yap_LookupAtom(const char *atom) { /* lookup atom in atom table */
return LookupAtom((const unsigned char *)atom);
}
}
Atom Yap_ULookupAtom(
Atom Yap_ULookupAtom(
const unsigned char *atom) { /* lookup atom in atom table */
return LookupAtom(atom);
}
}
Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */
Atom Yap_FullLookupAtom(const char *atom) { /* lookup atom in atom table */
Atom t;
if ((t = SearchInInvisible((const unsigned char *)atom)) != NIL) {
return (t);
}
return (LookupAtom((const unsigned char *)atom));
}
}
void Yap_LookupAtomWithAddress(const char *atom,
void Yap_LookupAtomWithAddress(const char *atom,
AtomEntry *ae) { /* lookup atom in atom table */
register CELL hash;
register const unsigned char *p;
@ -268,9 +274,9 @@ void Yap_LookupAtomWithAddress(const char *atom,
strcpy((char *)ae->StrOfAE, (char *)atom);
INIT_RWLOCK(ae->ARWLock);
WRITE_UNLOCK(HashChain[hash].AERWLock);
}
}
void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */
void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */
register Int hash;
register const unsigned char *p;
AtomEntry *inChain;
@ -298,10 +304,10 @@ void Yap_ReleaseAtom(Atom atom) { /* Releases an atom from the hash chain */
WRITE_UNLOCK(inChain->ARWLock);
WRITE_UNLOCK(HashChain[hash].AERWLock);
ap->NextOfAE = NULL;
}
}
static Prop
GetAPropHavingLock(AtomEntry *ae,
static Prop
GetAPropHavingLock(AtomEntry *ae,
PropFlags kind) { /* look property list of atom a for kind */
PropEntry *pp;
@ -309,15 +315,15 @@ GetAPropHavingLock(AtomEntry *ae,
while (!EndOfPAEntr(pp) && pp->KindOfPE != kind)
pp = RepProp(pp->NextOfPE);
return (AbsProp(pp));
}
}
Prop Yap_GetAPropHavingLock(
Prop Yap_GetAPropHavingLock(
AtomEntry *ae, PropFlags kind) { /* look property list of atom a for kind */
return GetAPropHavingLock(ae, kind);
}
}
static Prop
GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */
static Prop
GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a);
Prop out;
@ -325,14 +331,14 @@ GetAProp(Atom a, PropFlags kind) { /* look property list of atom a for kind */
out = GetAPropHavingLock(ae, kind);
READ_UNLOCK(ae->ARWLock);
return (out);
}
}
Prop Yap_GetAProp(Atom a,
Prop Yap_GetAProp(Atom a,
PropFlags kind) { /* look property list of atom a for kind */
return GetAProp(a, kind);
}
}
OpEntry *Yap_GetOpPropForAModuleHavingALock(
OpEntry *Yap_GetOpPropForAModuleHavingALock(
Atom a, Term mod) { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a);
PropEntry *pp;
@ -345,9 +351,9 @@ OpEntry *Yap_GetOpPropForAModuleHavingALock(
return NULL;
}
return (OpEntry *)pp;
}
}
int Yap_HasOp(Atom a) { /* look property list of atom a for kind */
int Yap_HasOp(Atom a) { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a);
PropEntry *pp;
@ -361,10 +367,10 @@ int Yap_HasOp(Atom a) { /* look property list of atom a for kind */
} else {
return TRUE;
}
}
}
OpEntry *
Yap_OpPropForModule(Atom a,
OpEntry *
Yap_OpPropForModule(Atom a,
Term mod) { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a);
PropEntry *pp;
@ -399,10 +405,10 @@ Yap_OpPropForModule(Atom a,
WRITE_UNLOCK(ae->ARWLock);
info->Prefix = info->Infix = info->Posfix = 0;
return info;
}
}
OpEntry *
Yap_GetOpProp(Atom a, op_type type,
OpEntry *
Yap_GetOpProp(Atom a, op_type type,
Term cmod USES_REGS) { /* look property list of atom a for kind */
AtomEntry *ae = RepAtom(a);
PropEntry *pp;
@ -455,11 +461,11 @@ Yap_GetOpProp(Atom a, op_type type,
}
READ_UNLOCK(ae->ARWLock);
return NULL;
}
}
inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
p0 = ae->PropsOfAE;
@ -478,11 +484,11 @@ inline static Prop GetPredPropByAtomHavingLock(AtomEntry *ae, Term cur_mod)
p0 = pe->NextOfPE;
}
return (NIL);
}
}
Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
AtomEntry *ae = RepAtom(at);
@ -490,11 +496,11 @@ Prop Yap_GetPredPropByAtom(Atom at, Term cur_mod)
p0 = GetPredPropByAtomHavingLock(ae, cur_mod);
READ_UNLOCK(ae->ARWLock);
return (p0);
}
}
inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
p0 = ae->PropsOfAE;
@ -512,11 +518,11 @@ inline static Prop GetPredPropByAtomHavingLockInThisModule(AtomEntry *ae, Term c
p0 = pe->NextOfPE;
}
return (NIL);
}
}
Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
AtomEntry *ae = RepAtom(at);
@ -524,12 +530,12 @@ Prop Yap_GetPredPropByAtomInThisModule(Atom at, Term cur_mod)
p0 = GetPredPropByAtomHavingLockInThisModule(ae, cur_mod);
READ_UNLOCK(ae->ARWLock);
return (p0);
}
}
Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod)
/* get predicate entry for ap/arity; */
{
Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod)
/* get predicate entry for ap/arity; */
{
Prop p0;
FUNC_READ_LOCK(f);
@ -537,22 +543,22 @@ Prop Yap_GetPredPropByFunc(Functor f, Term cur_mod)
FUNC_READ_UNLOCK(f);
return (p0);
}
}
Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
/* get predicate entry for ap/arity; */
{
Prop Yap_GetPredPropByFuncInThisModule(Functor f, Term cur_mod)
/* get predicate entry for ap/arity; */
{
Prop p0;
FUNC_READ_LOCK(f);
p0 = GetPredPropByFuncHavingLock(f, cur_mod);
FUNC_READ_UNLOCK(f);
return (p0);
}
}
Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
/* get predicate entry for ap/arity; */
{
Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
/* get predicate entry for ap/arity; */
{
Prop p0;
AtomEntry *ae = RepAtom(ap);
Functor f;
@ -565,10 +571,10 @@ Prop Yap_GetPredPropHavingLock(Atom ap, unsigned int arity, Term mod)
p0 = GetPredPropByFuncHavingLock(f, mod);
FUNC_READ_UNLOCK(f);
return (p0);
}
}
/* get expression entry for at/arity; */
Prop Yap_GetExpProp(Atom at, unsigned int arity) {
/* get expression entry for at/arity; */
Prop Yap_GetExpProp(Atom at, unsigned int arity) {
Prop p0;
AtomEntry *ae = RepAtom(at);
ExpEntry *p;
@ -579,10 +585,10 @@ Prop Yap_GetExpProp(Atom at, unsigned int arity) {
p = RepExpProp(p0 = p->NextOfPE);
READ_UNLOCK(ae->ARWLock);
return (p0);
}
}
/* get expression entry for at/arity, at is already locked; */
Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) {
/* get expression entry for at/arity, at is already locked; */
Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) {
Prop p0;
ExpEntry *p;
@ -591,9 +597,9 @@ Prop Yap_GetExpPropHavingLock(AtomEntry *ae, unsigned int arity) {
p = RepExpProp(p0 = p->NextOfPE);
return (p0);
}
}
static int ExpandPredHash(void) {
static int ExpandPredHash(void) {
UInt new_size = PredHashTableSize + PredHashIncrement;
PredEntry **oldp = PredHash;
PredEntry **np =
@ -621,10 +627,10 @@ static int ExpandPredHash(void) {
PredHash = np;
Yap_FreeAtomSpace((ADDR)oldp);
return TRUE;
}
}
/* fe is supposed to be locked */
Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
/* fe is supposed to be locked */
Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
if (p == NULL) {
@ -713,10 +719,10 @@ Prop Yap_NewPredPropByFunctor(FunctorEntry *fe, Term cur_mod) {
}
}
return AbsPredProp(p);
}
}
#if THREADS
Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
if (p == NULL) {
@ -761,10 +767,10 @@ Prop Yap_NewThreadPred(PredEntry *ap USES_REGS) {
GPROF_NEW_PRED_THREAD);
}
return AbsPredProp(p);
}
}
#endif
Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
Prop p0;
PredEntry *p = (PredEntry *)Yap_AllocAtomSpace(sizeof(*p));
CACHE_REGS
@ -820,11 +826,11 @@ Prop Yap_NewPredPropByAtom(AtomEntry *ae, Term cur_mod) {
}
}
return p0;
}
}
Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
PredEntry *p;
FUNC_WRITE_LOCK(f);
@ -855,11 +861,11 @@ Prop Yap_PredPropByFunctorNonThreadLocal(Functor f, Term cur_mod)
READ_UNLOCK(PredHashRWLock);
}
return Yap_NewPredPropByFunctor(f, cur_mod);
}
}
Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
AtomEntry *ae = RepAtom(at);
@ -879,9 +885,9 @@ Prop Yap_PredPropByAtomNonThreadLocal(Atom at, Term cur_mod)
p0 = pe->NextOfPE;
}
return Yap_NewPredPropByAtom(ae, cur_mod);
}
}
Term Yap_GetValue(Atom a) {
Term Yap_GetValue(Atom a) {
Prop p0 = GetAProp(a, ValProperty);
Term out;
@ -909,9 +915,9 @@ Term Yap_GetValue(Atom a) {
}
READ_UNLOCK(RepValProp(p0)->VRWLock);
return (out);
}
}
void Yap_PutValue(Atom a, Term v) {
void Yap_PutValue(Atom a, Term v) {
AtomEntry *ae = RepAtom(a);
Prop p0;
ValEntry *p;
@ -1027,9 +1033,9 @@ void Yap_PutValue(Atom a, Term v) {
p->ValueOfVE = v;
}
WRITE_UNLOCK(p->VRWLock);
}
}
bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) {
bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) {
AtomEntry *ae = RepAtom(a);
Prop p0;
TranslationEntry *p;
@ -1051,9 +1057,9 @@ bool Yap_PutAtomTranslation(Atom a, arity_t arity, Int i) {
if someone else searches for the property */
WRITE_UNLOCK(ae->ARWLock);
return true;
}
}
bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) {
bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) {
AtomEntry *ae = RepAtom(a);
Prop p0;
TranslationEntry *p;
@ -1075,9 +1081,9 @@ bool Yap_PutFunctorTranslation(Atom a, arity_t arity, Int i) {
if someone else searches for the property */
WRITE_UNLOCK(ae->ARWLock);
return true;
}
}
bool Yap_PutAtomMutex(Atom a, void *i) {
bool Yap_PutAtomMutex(Atom a, void *i) {
AtomEntry *ae = RepAtom(a);
Prop p0;
MutexEntry *p;
@ -1098,9 +1104,9 @@ bool Yap_PutAtomMutex(Atom a, void *i) {
if someone else searches for the property */
WRITE_UNLOCK(ae->ARWLock);
return true;
}
}
Term Yap_ArrayToList(register Term *tp, size_t nof) {
Term Yap_ArrayToList(register Term *tp, size_t nof) {
CACHE_REGS
register Term *pt = tp + nof;
register Term t;
@ -1116,9 +1122,9 @@ Term Yap_ArrayToList(register Term *tp, size_t nof) {
t = MkPairTerm(tm, t);
}
return (t);
}
}
int Yap_GetName(char *s, UInt max, Term t) {
int Yap_GetName(char *s, UInt max, Term t) {
register Term Head;
register Int i;
@ -1139,11 +1145,11 @@ int Yap_GetName(char *s, UInt max, Term t) {
}
*s = '\0';
return TRUE;
}
}
#ifdef SFUNC
Term MkSFTerm(Functor f, int n, Term *a, empty_value) {
Term MkSFTerm(Functor f, int n, Term *a, empty_value) {
Term t, p = AbsAppl(H);
int i;
@ -1159,19 +1165,19 @@ Term MkSFTerm(Functor f, int n, Term *a, empty_value) {
}
*H++ = 0;
return (p);
}
}
CELL *ArgsOfSFTerm(Term t) {
CELL *ArgsOfSFTerm(Term t) {
CELL *p = RepAppl(t) + 1;
while (*p != (CELL)p)
p = CellPtr(*p) + 1;
return (p + 1);
}
}
#endif
static HoldEntry *InitAtomHold(void) {
static HoldEntry *InitAtomHold(void) {
HoldEntry *x = (HoldEntry *)Yap_AllocAtomSpace(sizeof(struct hold_entry));
if (x == NULL) {
return NULL;
@ -1180,9 +1186,9 @@ static HoldEntry *InitAtomHold(void) {
x->NextOfPE = NIL;
x->RefsOfPE = 1;
return x;
}
}
int Yap_AtomIncreaseHold(Atom at) {
int Yap_AtomIncreaseHold(Atom at) {
AtomEntry *ae = RepAtom(at);
HoldEntry *pp;
Prop *opp = &(ae->PropsOfAE);
@ -1205,9 +1211,9 @@ int Yap_AtomIncreaseHold(Atom at) {
}
WRITE_UNLOCK(ae->ARWLock);
return TRUE;
}
}
int Yap_AtomDecreaseHold(Atom at) {
int Yap_AtomDecreaseHold(Atom at) {
AtomEntry *ae = RepAtom(at);
HoldEntry *pp;
Prop *opp = &(ae->PropsOfAE);
@ -1229,9 +1235,9 @@ int Yap_AtomDecreaseHold(Atom at) {
}
WRITE_UNLOCK(ae->ARWLock);
return TRUE;
}
}
const char *IndicatorOfPred(PredEntry *pe) {
const char *IndicatorOfPred(PredEntry *pe) {
const char *mods;
Atom at;
arity_t arity;
@ -1263,4 +1269,4 @@ const char *IndicatorOfPred(PredEntry *pe) {
snprintf(LOCAL_FileNameBuf, YAP_FILENAME_MAX, "%s:%s/" UInt_FORMAT, mods,
RepAtom(at)->StrOfAE, arity);
return LOCAL_FileNameBuf;
}
}

View File

@ -38,7 +38,7 @@ bool Yap_Warning(const char *s, ...) {
PredEntry *pred;
bool rc;
Term ts[2];
const char *format;
const char *fmt;
char tmpbuf[MAXPATHLEN];
LOCAL_DoingUndefp = true;
@ -46,12 +46,12 @@ bool Yap_Warning(const char *s, ...) {
pred = RepPredProp(PredPropByFunc(FunctorPrintMessage,
PROLOG_MODULE)); // PROCEDURE_print_message2
va_start(ap, s);
format = va_arg(ap, char *);
if (format != NULL) {
fmt = va_arg(ap, char *);
if (fmt != NULL) {
#if HAVE_VSNPRINTF
vsnprintf(tmpbuf, MAXPATHLEN - 1, format, ap);
vsnprintf(tmpbuf, MAXPATHLEN - 1, fmt, ap);
#else
(void)vsprintf(tmpbuf, format, ap);
(void)vsprintf(tmpbuf, fmt, ap);
#endif
} else
return false;
@ -321,12 +321,12 @@ void Yap_ThrowError__(const char *file, const char *function, int lineno,
char tmpbuf[MAXPATHLEN];
va_start(ap, where);
char *format = va_arg(ap, char *);
if (format != NULL) {
char *fmt = va_arg(ap, char *);
if (fmt != NULL) {
#if HAVE_VSNPRINTF
(void)vsnprintf(tmpbuf, MAXPATHLEN - 1, format, ap);
(void)vsnprintf(tmpbuf, MAXPATHLEN - 1, fmt, ap);
#else
(void)vsprintf(tnpbuf, format, ap);
(void)vsprintf(tnpbuf, fmt, ap);
#endif
// fprintf(stderr, "warning: ");
Yap_Error__(file, function, lineno, type, where, tmpbuf);
@ -377,7 +377,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
Functor fun;
Term error_t;
Term comment;
char *format;
char *fmt;
char s[MAXPATHLEN];
/* disallow recursive error handling */
@ -399,17 +399,17 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
if (where == 0L) {
where = TermNil;
}
// first, obtain current location
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno,
// function);
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
// first, obtain current location
// sprintf(LOCAL_FileNameBuf, "%s:%d in C-function %s ", file, lineno,
// function);
// tf = MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf));
#if DEBUG_STRICT
if (Yap_heap_regs && !(LOCAL_PrologMode & BootMode))
fprintf(stderr, "***** Processing Error %d (%lx,%x) %s***\n", type,
(unsigned long int)LOCAL_Signals, LOCAL_PrologMode, format);
(unsigned long int)LOCAL_Signals, LOCAL_PrologMode, fmt);
else
fprintf(stderr, "***** Processing Error %d (%x) %s***\n", type,
LOCAL_PrologMode, format);
LOCAL_PrologMode, fmt);
#endif
if (type == INTERRUPT_EVENT) {
fprintf(stderr, "%% YAP exiting: cannot handle signal %d\n",
@ -425,12 +425,12 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
Yap_exit(1);
}
va_start(ap, where);
format = va_arg(ap, char *);
if (format != NULL) {
fmt = va_arg(ap, char *);
if (fmt != NULL) {
#if HAVE_VSNPRINTF
(void)vsnprintf(s, MAXPATHLEN - 1, format, ap);
(void)vsnprintf(s, MAXPATHLEN - 1, fmt, ap);
#else
(void)vsprintf(s, format, ap);
(void)vsprintf(s, fmt, ap);
#endif
// fprintf(stderr, "warning: ");
comment = MkAtomTerm(Yap_LookupAtom(s));
@ -479,7 +479,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
error_exit_yap(1);
}
#ifdef DEBUG
// DumpActiveGoals( USES_REGS1 );
// DumpActiveGoals( USES_REGS1 );
#endif /* DEBUG */
if (!IsVarTerm(where) && IsApplTerm(where) &&
FunctorOfTerm(where) == FunctorError) {
@ -604,7 +604,7 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
LOCAL_Signals = 0;
CalculateStackGap(PASS_REGS1);
#if DEBUG
// DumpActiveGoals( PASS_REGS1 );
// DumpActiveGoals( PASS_REGS1 );
#endif
/* wait if we we are in user code,
it's up to her to decide */

View File

@ -268,7 +268,7 @@ static void *codes2buf(Term t0, void *b0, bool *get_codes USES_REGS) {
}
}
st0 = st = malloc(length + 1);
st0 = st = Malloc(length + 1);
t = t0;
if (codes) {
while (IsPairTerm(t)) {
@ -290,9 +290,9 @@ static void *codes2buf(Term t0, void *b0, bool *get_codes USES_REGS) {
st[0] = '\0';
return st0;
}
}
static unsigned char *latin2utf8(seq_tv_t *inp) {
static unsigned char *latin2utf8(seq_tv_t *inp) {
unsigned char *b0 = inp->val.uc;
size_t sz = strlen(inp->val.c);
sz *= 2;
@ -339,12 +339,12 @@ static void *codes2buf(Term t0, void *b0, bool *get_codes USES_REGS) {
seq_tv_t *inp USES_REGS) {
bool codes;
unsigned char *nbuf = codes2buf(t, buf, &codes PASS_REGS);
if (!codes)
if (codes)
return NULL;
return nbuf;
}
static unsigned char *Yap_ListToBuffer(unsigned char *buf, Term t,
static unsigned char *Yap_ListToBuffer(unsigned char *buf, Term t,
seq_tv_t *inp USES_REGS) {
unsigned char *nbuf = codes2buf(t, buf, NULL PASS_REGS);
return nbuf;
@ -645,7 +645,7 @@ static void *codes2buf(Term t0, void *b0, bool *get_codes USES_REGS) {
out->val.uc = BaseMalloc(leng + 1);
strcpy(out->val.c, (char *)s0);
} else if (out->val.uc != s0) {
out->val.c = Realloc(out->val.c, leng + 1);
out->val.c = BaseMalloc(leng + 1);
strcpy(out->val.c, (char *)s0);
}
} else if (out->enc == ENC_ISO_LATIN1) {
@ -954,7 +954,7 @@ bool write_Text(unsigned char *inp, seq_tv_t *out USES_REGS) {
bufv[j++] = nbuf;
}
if (j == 0) {
buf = malloc(8);
buf = Malloc(8);
memset(buf, 0, 4);
} else if (j == 1) {
buf = bufv[0];
@ -966,8 +966,8 @@ bool write_Text(unsigned char *inp, seq_tv_t *out USES_REGS) {
return rc;
}
//
bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp,
//
bool Yap_Splice_Text(int n, size_t cuts[], seq_tv_t *inp,
seq_tv_t outv[] USES_REGS) {
const unsigned char *buf;
size_t b_l, u_l;

View File

@ -525,7 +525,7 @@ SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${libdir}")

View File

@ -114,3 +114,4 @@ typedef unsigned long int YAP_ULONG_LONG;
#define Unsigned(V) ((CELL)(V))
#define Signed(V) ((Int)(V))

View File

@ -188,11 +188,7 @@ INLINE_ONLY inline EXTERN utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr,
utf8proc_int32_t *valp) {
utf8proc_ssize_t rc = utf8proc_iterate(ptr, n, valp);
if (rc < 0) {
if (rc == UTF8PROC_ERROR_INVALIDUTF8)
Yap_Warning("get_utf8 found bad UTF-8 char %s, skipping...", ptr);
else
Yap_Warning("UTF-8 error %d, skipping...", *ptr);
rc = 1;
LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_IN_CHARACTER_CODE;
}
return rc;
}
@ -203,8 +199,9 @@ INLINE_ONLY inline EXTERN utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr,
INLINE_ONLY inline EXTERN utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr,
utf8proc_int32_t val) {
utf8proc_ssize_t rc = utf8proc_encode_char(val, ptr);
if (rc == 0)
Yap_Warning("UTF-8 error at %s", ptr);
if (rc < 0) {
LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_CHARACTER_CODE;
}
return rc;
}
@ -217,15 +214,11 @@ inline static const utf8proc_uint8_t *skip_utf8(const utf8proc_uint8_t *pt,
if (b == 0)
return pt;
if (l < 0) {
if (l == UTF8PROC_ERROR_INVALIDUTF8)
Yap_Warning("skip_utf8: found bad UTF-8 in char %s[%d], skipping...",
pt, i);
else
Yap_Warning("UTF-8 error %d at %s[%d], skipping...", l, pt, i);
l = 1;
}
LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_CHARACTER_CODE;
} else {
pt += l;
}
}
return pt;
}
@ -240,14 +233,11 @@ inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t *pt) {
utf8proc_ssize_t l = utf8proc_iterate(pt, -1, &b);
if (b == 0)
return rc;
else if (b > 0) {
else if (l > 0) {
pt += l;
rc++;
} else {
if (l == UTF8PROC_ERROR_INVALIDUTF8)
Yap_Warning("found bad UTF-8 char %d, skipping %s...", *pt, pt);
else
Yap_Warning("UTF-8 error %d, skipping...", l);
LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_CHARACTER_CODE;
pt++;
}
}
@ -259,6 +249,9 @@ inline static utf8proc_ssize_t strlen_latin_utf8(const unsigned char *pt) {
utf8proc_uint8_t b;
while (true) {
utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b);
if (l<0) {
pt++;
}
if (b == 0)
return rc;
pt++;
@ -276,6 +269,7 @@ inline static utf8proc_ssize_t strnlen_latin_utf8(const unsigned char *pt,
if (b == 0)
return rc;
pt++;
if (l > 0)
rc += l;
if (--max == 0)
return rc;
@ -290,6 +284,8 @@ inline static utf8proc_ssize_t strlen_ucs2_utf8(const wchar_t *pt) {
utf8proc_ssize_t l = utf8proc_encode_char(*pt, &b);
if (b == 0)
return rc;
if (l < 0)
continue;
pt++;
rc += l;
}
@ -947,7 +943,6 @@ static inline Atom Yap_ListOfAtomsToAtom(Term t0 USES_REGS) {
out.type = YAP_STRING_ATOM;
out.val.uc = NULL;
out.enc = ENC_ISO_UTF8;
out.enc = ENC_ISO_UTF8;
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
return (Atom)NULL;
return out.val.a;

View File

@ -20,8 +20,6 @@ check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( "stdio.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )
configure_file (cmake/cudd_config.h.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cudd_config.h" )
configure_file (cmake/cudd_config.h.cmake
"${CMAKE_BINARY_DIR}/packages/cplint/config,config.h" )
endif (CUDD_FOUND)

View File

@ -5,7 +5,6 @@ package:
requirements:
build:
- cmake
- clang
- swig
- readline
- gmp

View File

@ -97,7 +97,7 @@ Int Yap_peek(int sno) {
CACHE_REGS
Int ocharcount, olinecount, olinepos;
StreamDesc *s;
uint32_t ch;
int32_t ch;
s = GLOBAL_Stream + sno;
#if USE_READLINE
@ -1039,11 +1039,11 @@ code with _C_, while leaving the current stream position unaltered.
*/
static Int peek_byte(USES_REGS1) { /* at_end_of_stream */
/* the next character is a EOF */
int sno = Yap_CheckStream(ARG1, Input_Stream_f, "peek_byte/2");
int sno = Yap_CheckBinaryStream(ARG1, Input_Stream_f, "peek_byte/2");
Int ch;
if (sno < 0)
return (FALSE);
return false;
if (!(GLOBAL_Stream[sno].status & Binary_Stream_f)) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_BINARY_STREAM, ARG1, "peek_byte/2");
@ -1099,22 +1099,20 @@ atom with _C_, while leaving the stream position unaltered.
static Int peek_char(USES_REGS1) {
/* the next character is a EOF */
int sno = Yap_CheckTextStream(ARG1, Input_Stream_f, "peek/2");
unsigned char sinp[10];
unsigned char sinp[16];
Int ch;
if (sno < 0)
if (sno < 0)
return false;
if ((GLOBAL_Stream[sno].status & Binary_Stream_f)) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
Yap_Error(PERMISSION_ERROR_INPUT_TEXT_STREAM, ARG1, "peek_byte/2");
return (FALSE);
}
if ((ch = Yap_peek(sno)) < 0) {
UNLOCK(GLOBAL_Stream[sno].streamlock);
return Yap_unify_constant(ARG2, MkAtomTerm(AtomEof));
}
UNLOCK(GLOBAL_Stream[sno].streamlock);
int off = put_utf8(sinp, ch);
if (off < 0) {
return false;
}
sinp[off] = '\0';
return Yap_unify_constant(ARG2, MkAtomTerm(Yap_ULookupAtom(sinp)));
}