chaeacters mostly
This commit is contained in:
parent
af38546a0d
commit
7dab812d64
10
C/adtdefs.c
10
C/adtdefs.c
@ -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;
|
||||
|
32
C/errors.c
32
C/errors.c
@ -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 */
|
||||
@ -406,10 +406,10 @@ yamop *Yap_Error__(const char *file, const char *function, int lineno,
|
||||
#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));
|
||||
|
8
C/text.c
8
C/text.c
@ -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)) {
|
||||
@ -339,7 +339,7 @@ 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;
|
||||
}
|
||||
@ -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];
|
||||
|
@ -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}")
|
||||
|
||||
|
@ -114,3 +114,4 @@ typedef unsigned long int YAP_ULONG_LONG;
|
||||
|
||||
#define Unsigned(V) ((CELL)(V))
|
||||
#define Signed(V) ((Int)(V))
|
||||
|
||||
|
35
H/YapText.h
35
H/YapText.h
@ -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;
|
||||
|
@ -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)
|
||||
|
||||
|
@ -5,7 +5,6 @@ package:
|
||||
requirements:
|
||||
build:
|
||||
- cmake
|
||||
- clang
|
||||
- swig
|
||||
- readline
|
||||
- gmp
|
||||
|
16
os/charsio.c
16
os/charsio.c
@ -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)
|
||||
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)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user