text handling/UNICODE
This commit is contained in:
parent
4d1c031051
commit
70f4f7adcf
24
C/atomic.c
24
C/atomic.c
@ -309,42 +309,40 @@ static Int char_code(USES_REGS1) {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
static Int name(USES_REGS1) { /* name(?Atomic,?String) */
|
static Int name(USES_REGS1) { /* name(?Atomic,?String) */
|
||||||
Term t = Deref(ARG2), NewT, AtomNameT = Deref(ARG1);
|
Term t2 = Deref(ARG2), NewT, t1 = Deref(ARG1);
|
||||||
LOCAL_MAX_SIZE = 1024;
|
LOCAL_MAX_SIZE = 1024;
|
||||||
|
|
||||||
int l = push_text_stack();
|
int l = push_text_stack();
|
||||||
restart_aux:
|
restart_aux:
|
||||||
if (Yap_IsGroundTerm(AtomNameT)) {
|
if (Yap_IsGroundTerm(t1)) {
|
||||||
if (!IsVarTerm(t) && !IsPairTerm(t) && t != TermNil) {
|
if (!IsVarTerm(t2) && !IsPairTerm(t2) && t2 != TermNil) {
|
||||||
Yap_Error(TYPE_ERROR_LIST, ARG2, "name/2");
|
Yap_Error(TYPE_ERROR_LIST, ARG2, "name/2");
|
||||||
pop_text_stack(l);
|
|
||||||
ReleaseAndReturn(FALSE);
|
ReleaseAndReturn(FALSE);
|
||||||
}
|
}
|
||||||
// verify if an atom, int, float or bi§gnnum
|
// verify if an atom, int, float or bi§gnnum
|
||||||
NewT = Yap_AtomicToListOfCodes(AtomNameT PASS_REGS);
|
NewT = Yap_AtomicToListOfCodes(t1 PASS_REGS);
|
||||||
if (NewT) {
|
if (NewT) {
|
||||||
pop_text_stack(l);
|
|
||||||
ReleaseAndReturn(Yap_unify(NewT, ARG2));
|
ReleaseAndReturn(Yap_unify(NewT, ARG2));
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
} else if (IsVarTerm(t)) {
|
} else if (IsVarTerm(t2)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR, t, "name/2");
|
Yap_Error(INSTANTIATION_ERROR, t2, "name/2");
|
||||||
pop_text_stack(l);
|
pop_text_stack(l);
|
||||||
return FALSE;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Term at = Yap_ListToAtomic(t PASS_REGS);
|
Term at = Yap_ListToAtomic(t2 PASS_REGS);
|
||||||
if (at) {
|
if (at) {
|
||||||
pop_text_stack(l);
|
pop_text_stack(l);
|
||||||
ReleaseAndReturn(Yap_unify(at, ARG1));
|
ReleaseAndReturn(Yap_unify(at, ARG1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LOCAL_Error_TYPE && Yap_HandleError("atom/2")) {
|
if (LOCAL_Error_TYPE && Yap_HandleError("atom/2")) {
|
||||||
AtomNameT = Deref(ARG1);
|
t1 = Deref(ARG1);
|
||||||
t = Deref(ARG2);
|
t2 = Deref(ARG2);
|
||||||
goto restart_aux;
|
goto restart_aux;
|
||||||
}
|
}
|
||||||
pop_text_stack(l);
|
pop_text_stack(l);
|
||||||
ReleaseAndReturn(FALSE);
|
ReleaseAndReturn(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int string_to_atomic(
|
static Int string_to_atomic(
|
||||||
|
@ -2221,7 +2221,7 @@ X_API char *YAP_WriteBuffer(Term t, char *buf, size_t sze, int flags) {
|
|||||||
|
|
||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
inp.val.t = t;
|
inp.val.t = t;
|
||||||
inp.type = YAP_STRING_TERM;
|
inp.type = YAP_STRING_TERM|YAP_STRING_DATUM;
|
||||||
out.type = YAP_STRING_CHARS;
|
out.type = YAP_STRING_CHARS;
|
||||||
out.val.c = buf;
|
out.val.c = buf;
|
||||||
out.max = sze - 1;
|
out.max = sze - 1;
|
||||||
|
247
C/text.c
247
C/text.c
@ -53,7 +53,8 @@ typedef struct TextBuffer_manager {
|
|||||||
|
|
||||||
int push_text_stack(USES_REGS1) {
|
int push_text_stack(USES_REGS1) {
|
||||||
|
|
||||||
return LOCAL_TextBuffer->lvl++; }
|
return LOCAL_TextBuffer->lvl++;
|
||||||
|
}
|
||||||
|
|
||||||
int pop_text_stack(int i) {
|
int pop_text_stack(int i) {
|
||||||
int lvl = LOCAL_TextBuffer->lvl;
|
int lvl = LOCAL_TextBuffer->lvl;
|
||||||
@ -170,8 +171,8 @@ void *Yap_InitTextAllocator(void) {
|
|||||||
|
|
||||||
static size_t MaxTmp(USES_REGS1) {
|
static size_t MaxTmp(USES_REGS1) {
|
||||||
|
|
||||||
return ((char *)LOCAL_TextBuffer->buf + LOCAL_TextBuffer->sz) -
|
return ((char *) LOCAL_TextBuffer->buf + LOCAL_TextBuffer->sz) -
|
||||||
(char *)LOCAL_TextBuffer->ptr;
|
(char *) LOCAL_TextBuffer->ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term Globalize(Term v USES_REGS) {
|
static Term Globalize(Term v USES_REGS) {
|
||||||
@ -215,9 +216,9 @@ static Int SkipListCodes(unsigned char **bufp, Term *l, Term **tailp,
|
|||||||
// are we looking for atoms/codes?
|
// are we looking for atoms/codes?
|
||||||
// whatever the case, we should be consistent throughout,
|
// whatever the case, we should be consistent throughout,
|
||||||
// so we should be consistent with the first arg.
|
// so we should be consistent with the first arg.
|
||||||
if (st > st0+max_lim) {
|
if (st > st0 + max_lim) {
|
||||||
max_lim += 2048;
|
max_lim += 2048;
|
||||||
*bufp = st0 = Realloc(st0,max_lim);
|
*bufp = st0 = Realloc(st0, max_lim);
|
||||||
}
|
}
|
||||||
if (IsAtomTerm(hd0)) {
|
if (IsAtomTerm(hd0)) {
|
||||||
atomst = true;
|
atomst = true;
|
||||||
@ -226,7 +227,7 @@ static Int SkipListCodes(unsigned char **bufp, Term *l, Term **tailp,
|
|||||||
atomst = false;
|
atomst = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( IsPairTerm(*l)) {
|
while (IsPairTerm(*l)) {
|
||||||
int ch;
|
int ch;
|
||||||
length++;
|
length++;
|
||||||
{
|
{
|
||||||
@ -238,7 +239,7 @@ static Int SkipListCodes(unsigned char **bufp, Term *l, Term **tailp,
|
|||||||
return -REPRESENTATION_ERROR_CHARACTER;
|
return -REPRESENTATION_ERROR_CHARACTER;
|
||||||
} else {
|
} else {
|
||||||
AtomEntry *ae = RepAtom(AtomOfTerm(hd));
|
AtomEntry *ae = RepAtom(AtomOfTerm(hd));
|
||||||
st = (unsigned char *) stpcpy( ( char *)st, ae->StrOfAE);
|
st = (unsigned char *) stpcpy((char *) st, ae->StrOfAE);
|
||||||
}
|
}
|
||||||
} else if (IsIntegerTerm(hd)) {
|
} else if (IsIntegerTerm(hd)) {
|
||||||
ch = IntegerOfTerm(hd);
|
ch = IntegerOfTerm(hd);
|
||||||
@ -248,7 +249,7 @@ static Int SkipListCodes(unsigned char **bufp, Term *l, Term **tailp,
|
|||||||
*tailp = l;
|
*tailp = l;
|
||||||
return -REPRESENTATION_ERROR_CHARACTER_CODE;
|
return -REPRESENTATION_ERROR_CHARACTER_CODE;
|
||||||
} else {
|
} else {
|
||||||
st += put_utf8(st,ch);
|
st += put_utf8(st, ch);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return -TYPE_ERROR_INTEGER;
|
return -TYPE_ERROR_INTEGER;
|
||||||
@ -273,7 +274,7 @@ st += put_utf8(st,ch);
|
|||||||
st[0] = '\0';
|
st[0] = '\0';
|
||||||
*tailp = l;
|
*tailp = l;
|
||||||
*atoms = length;
|
*atoms = length;
|
||||||
length = (st-st0);
|
length = (st - st0);
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
@ -295,9 +296,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
*pt++ = '\0';
|
*pt++ = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *wchar2utf8(seq_tv_t *inp, size_t *lengp) {
|
static unsigned char *wchar2utf8(seq_tv_t *inp, size_t *lengp) {
|
||||||
*lengp = wcslen(inp->val.w);
|
*lengp = wcslen(inp->val.w);
|
||||||
size_t sz = *lengp * 4;
|
size_t sz = *lengp * 4;
|
||||||
wchar_t *b0 = inp->val.w;
|
wchar_t *b0 = inp->val.w;
|
||||||
@ -309,11 +310,11 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
pt += put_utf8(pt, ch);
|
pt += put_utf8(pt, ch);
|
||||||
*pt++ = '\0';
|
*pt++ = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS);
|
static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS);
|
||||||
|
|
||||||
static unsigned char *to_buffer(unsigned char *buf, Term t, seq_tv_t *inp,
|
static unsigned char *to_buffer(unsigned char *buf, Term t, seq_tv_t *inp,
|
||||||
bool *widep, Int *atoms,
|
bool *widep, Int *atoms,
|
||||||
size_t *lenp USES_REGS) {
|
size_t *lenp USES_REGS) {
|
||||||
CELL *r = NULL;
|
CELL *r = NULL;
|
||||||
@ -330,31 +331,31 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
*lenp = n;
|
*lenp = n;
|
||||||
return bufc;
|
return bufc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *Yap_ListOfCodesToBuffer(unsigned char *buf, Term t,
|
static unsigned char *Yap_ListOfCodesToBuffer(unsigned char *buf, Term t,
|
||||||
seq_tv_t *inp, bool *widep,
|
seq_tv_t *inp, bool *widep,
|
||||||
size_t *lenp USES_REGS) {
|
size_t *lenp USES_REGS) {
|
||||||
Int atoms = 1; // we only want lists of atoms
|
Int atoms = 1; // we only want lists of atoms
|
||||||
return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS);
|
return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *Yap_ListOfAtomsToBuffer(unsigned char *buf, Term t,
|
static unsigned char *Yap_ListOfAtomsToBuffer(unsigned char *buf, Term t,
|
||||||
seq_tv_t *inp, bool *widep,
|
seq_tv_t *inp, bool *widep,
|
||||||
size_t *lenp USES_REGS) {
|
size_t *lenp USES_REGS) {
|
||||||
Int atoms = 2; // we only want lists of integer codes
|
Int atoms = 2; // we only want lists of integer codes
|
||||||
return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS);
|
return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char *Yap_ListToBuffer(unsigned char *buf, Term t,
|
static unsigned char *Yap_ListToBuffer(unsigned char *buf, Term t,
|
||||||
seq_tv_t *inp, bool *widep,
|
seq_tv_t *inp, bool *widep,
|
||||||
size_t *lenp USES_REGS) {
|
size_t *lenp USES_REGS) {
|
||||||
Int atoms = 0; // we accept both types of lists.
|
Int atoms = 0; // we accept both types of lists.
|
||||||
return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS);
|
return to_buffer(buf, t, inp, widep, &atoms, lenp PASS_REGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_GEN_TYPE_ERROR
|
#if USE_GEN_TYPE_ERROR
|
||||||
static yap_error_number gen_type_error(int flags) {
|
static yap_error_number gen_type_error(int flags) {
|
||||||
if ((flags & (YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT |
|
if ((flags & (YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT |
|
||||||
YAP_STRING_FLOAT | YAP_STRING_ATOMS_CODES | YAP_STRING_BIG)) ==
|
YAP_STRING_FLOAT | YAP_STRING_ATOMS_CODES | YAP_STRING_BIG)) ==
|
||||||
(YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
|
(YAP_STRING_STRING | YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
|
||||||
@ -375,17 +376,17 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (flags & (YAP_STRING_CODES | YAP_STRING_ATOMS))
|
if (flags & (YAP_STRING_CODES | YAP_STRING_ATOMS))
|
||||||
return TYPE_ERROR_LIST;
|
return TYPE_ERROR_LIST;
|
||||||
return TYPE_ERROR_NUMBER;
|
return TYPE_ERROR_NUMBER;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// static int cnt;
|
// static int cnt;
|
||||||
|
|
||||||
unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
|
unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
|
||||||
unsigned char *s0 = NULL;
|
unsigned char *s0 = NULL;
|
||||||
bool wide;
|
bool wide;
|
||||||
|
|
||||||
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
|
if (LOCAL_Error_TYPE != YAP_NO_ERROR) {
|
||||||
fprintf(stderr, "Sourious error %u\n", LOCAL_Error_TYPE);
|
fprintf(stderr, "Spurious error %u\n", LOCAL_Error_TYPE);
|
||||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||||
}
|
}
|
||||||
/* we know what the term is */
|
/* we know what the term is */
|
||||||
@ -400,10 +401,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
} else if (!IsPairOrNilTerm(inp->val.t) && !IsStringTerm(inp->val.t) &&
|
} else if (!IsPairOrNilTerm(inp->val.t) && !IsStringTerm(inp->val.t) &&
|
||||||
inp->type == (YAP_STRING_ATOMS_CODES | YAP_STRING_STRING)) {
|
inp->type == (YAP_STRING_ATOMS_CODES | YAP_STRING_STRING)) {
|
||||||
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
LOCAL_Error_TYPE = TYPE_ERROR_LIST;
|
||||||
} else if (!IsNumTerm(inp->val.t) &&
|
} else if (!IsPairOrNilTerm(inp->val.t) && !IsStringTerm(inp->val.t)
|
||||||
(inp->type & (YAP_STRING_INT | YAP_STRING_FLOAT |
|
&& !IsAtomTerm(inp->val.t) && !(inp->type & YAP_STRING_DATUM)) {
|
||||||
YAP_STRING_BIG)) == inp->type) {
|
LOCAL_Error_TYPE = TYPE_ERROR_TEXT;
|
||||||
LOCAL_Error_TYPE = TYPE_ERROR_NUMBER;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,23 +420,23 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (inp->type & YAP_STRING_WITH_BUFFER)
|
if (inp->type & YAP_STRING_WITH_BUFFER)
|
||||||
return at->UStrOfAE;
|
return at->UStrOfAE;
|
||||||
inp->type |= YAP_STRING_IN_TMP;
|
inp->type |= YAP_STRING_IN_TMP;
|
||||||
char *o = Malloc(sz+1);
|
char *o = Malloc(sz + 1);
|
||||||
strcpy(o, at->StrOfAE);
|
strcpy(o, at->StrOfAE);
|
||||||
return (unsigned char *)o;
|
return (unsigned char *) o;
|
||||||
}
|
}
|
||||||
if (IsStringTerm(inp->val.t) && inp->type & YAP_STRING_STRING) {
|
if (IsStringTerm(inp->val.t) && inp->type & YAP_STRING_STRING) {
|
||||||
// this is a term, extract to a buffer, and representation is wide
|
// this is a term, extract to a buffer, and representation is wide
|
||||||
// Yap_DebugPlWriteln(inp->val.t);
|
// Yap_DebugPlWriteln(inp->val.t);
|
||||||
const char *s = StringOfTerm(inp->val.t);
|
const char *s = StringOfTerm(inp->val.t);
|
||||||
size_t sz = strlen( s );
|
size_t sz = strlen(s);
|
||||||
if (lengp)
|
if (lengp)
|
||||||
*lengp = sz;
|
*lengp = sz;
|
||||||
if (inp->type & YAP_STRING_WITH_BUFFER)
|
if (inp->type & YAP_STRING_WITH_BUFFER)
|
||||||
return (unsigned char*)UStringOfTerm(inp->val.t);
|
return (unsigned char *) UStringOfTerm(inp->val.t);
|
||||||
inp->type |= YAP_STRING_IN_TMP;
|
inp->type |= YAP_STRING_IN_TMP;
|
||||||
char *o = Malloc(sz+1);
|
char *o = Malloc(sz + 1);
|
||||||
strcpy(o, s);
|
strcpy(o, s);
|
||||||
return (unsigned char *)o;
|
return (unsigned char *) o;
|
||||||
}
|
}
|
||||||
if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) ==
|
if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) ==
|
||||||
(YAP_STRING_CODES | YAP_STRING_ATOMS)) &&
|
(YAP_STRING_CODES | YAP_STRING_ATOMS)) &&
|
||||||
@ -466,7 +466,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
if (lengp)
|
if (lengp)
|
||||||
*lengp = strlen(s);
|
*lengp = strlen(s);
|
||||||
return (unsigned char *)s;
|
return (unsigned char *) s;
|
||||||
}
|
}
|
||||||
if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) {
|
if (inp->type & YAP_STRING_FLOAT && IsFloatTerm(inp->val.t)) {
|
||||||
char *s;
|
char *s;
|
||||||
@ -476,7 +476,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
if (lengp)
|
if (lengp)
|
||||||
*lengp = strlen(s);
|
*lengp = strlen(s);
|
||||||
return (unsigned char *)s;
|
return (unsigned char *) s;
|
||||||
}
|
}
|
||||||
#if USE_GMP
|
#if USE_GMP
|
||||||
if (inp->type & YAP_STRING_BIG && IsBigIntTerm(inp->val.t)) {
|
if (inp->type & YAP_STRING_BIG && IsBigIntTerm(inp->val.t)) {
|
||||||
@ -488,13 +488,13 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
if (lengp)
|
if (lengp)
|
||||||
*lengp = strlen(s);
|
*lengp = strlen(s);
|
||||||
return inp->val.uc = (unsigned char *)s;
|
return inp->val.uc = (unsigned char *) s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (inp->type & YAP_STRING_TERM) {
|
if (inp->type & YAP_STRING_TERM) {
|
||||||
// Yap_DebugPlWriteln(inp->val.t);
|
// Yap_DebugPlWriteln(inp->val.t);
|
||||||
char *s = (char *)Yap_TermToString(inp->val.t, lengp, ENC_ISO_UTF8, 0);
|
char *s = (char *) Yap_TermToString(inp->val.t, lengp, ENC_ISO_UTF8, 0);
|
||||||
return inp->val.uc = (unsigned char *)s;
|
return inp->val.uc = (unsigned char *) s;
|
||||||
}
|
}
|
||||||
if (inp->type & YAP_STRING_CHARS) {
|
if (inp->type & YAP_STRING_CHARS) {
|
||||||
if (inp->enc == ENC_ISO_LATIN1) {
|
if (inp->enc == ENC_ISO_LATIN1) {
|
||||||
@ -503,7 +503,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (lengp)
|
if (lengp)
|
||||||
*lengp = strlen(inp->val.c);
|
*lengp = strlen(inp->val.c);
|
||||||
return inp->val.uc;
|
return inp->val.uc;
|
||||||
}else { //if (inp->enc == ENC_ISO_UTF8) {
|
} else { //if (inp->enc == ENC_ISO_UTF8) {
|
||||||
if (lengp)
|
if (lengp)
|
||||||
*lengp = strlen(inp->val.c);
|
*lengp = strlen(inp->val.c);
|
||||||
return inp->val.uc;
|
return inp->val.uc;
|
||||||
@ -514,9 +514,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
return wchar2utf8(inp, lengp);
|
return wchar2utf8(inp, lengp);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term write_strings(unsigned char *s0, seq_tv_t *out,
|
static Term write_strings(unsigned char *s0, seq_tv_t *out,
|
||||||
size_t leng USES_REGS) {
|
size_t leng USES_REGS) {
|
||||||
size_t min = 0, max = leng;
|
size_t min = 0, max = leng;
|
||||||
|
|
||||||
@ -529,25 +529,25 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *s = (char *)s0;
|
char *s = (char *) s0;
|
||||||
Term t = init_tstring(PASS_REGS1);
|
Term t = init_tstring(PASS_REGS1);
|
||||||
LOCAL_TERM_ERROR(t, 2 * max);
|
LOCAL_TERM_ERROR(t, 2 * max);
|
||||||
unsigned char *buf = buf_from_tstring(HR);
|
unsigned char *buf = buf_from_tstring(HR);
|
||||||
strcpy( (char *)buf, s );
|
strcpy((char *) buf, s);
|
||||||
if (max+1 < min) {
|
if (max + 1 < min) {
|
||||||
LOCAL_TERM_ERROR(t, 2 * min);
|
LOCAL_TERM_ERROR(t, 2 * min);
|
||||||
memset(buf+min, '\0', max);
|
memset(buf + min, '\0', max);
|
||||||
buf += min;
|
buf += min;
|
||||||
} else {
|
} else {
|
||||||
buf += max+1;
|
buf += max + 1;
|
||||||
}
|
}
|
||||||
close_tstring(buf PASS_REGS);
|
close_tstring(buf PASS_REGS);
|
||||||
out->val.t = t;
|
out->val.t = t;
|
||||||
|
|
||||||
return out->val.t;
|
return out->val.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term write_atoms(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
static Term write_atoms(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
||||||
Term t = AbsPair(HR);
|
Term t = AbsPair(HR);
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
size_t max = leng;
|
size_t max = leng;
|
||||||
@ -560,7 +560,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
max = out->max;
|
max = out->max;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *s = s0, *lim = s + strnlen((char *)s, max);
|
unsigned char *s = s0, *lim = s + strnlen((char *) s, max);
|
||||||
unsigned char *cp = s;
|
unsigned char *cp = s;
|
||||||
unsigned char w[10];
|
unsigned char w[10];
|
||||||
int wp = 0;
|
int wp = 0;
|
||||||
@ -596,9 +596,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
out->val.t = t;
|
out->val.t = t;
|
||||||
return (t);
|
return (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term write_codes(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
static Term write_codes(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
||||||
Term t = AbsPair(HR);
|
Term t = AbsPair(HR);
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
size_t max = leng;
|
size_t max = leng;
|
||||||
@ -611,7 +611,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
max = out->max;
|
max = out->max;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *s = s0, *lim = s + strlen((char *)s);
|
unsigned char *s = s0, *lim = s + strlen((char *) s);
|
||||||
unsigned char *cp = s;
|
unsigned char *cp = s;
|
||||||
|
|
||||||
LOCAL_TERM_ERROR(t, 2 * (lim - s));
|
LOCAL_TERM_ERROR(t, 2 * (lim - s));
|
||||||
@ -642,9 +642,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
out->val.t = t;
|
out->val.t = t;
|
||||||
return (t);
|
return (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Atom write_atom(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
static Atom write_atom(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
||||||
unsigned char *s = s0;
|
unsigned char *s = s0;
|
||||||
int32_t ch;
|
int32_t ch;
|
||||||
if (leng == 0) {
|
if (leng == 0) {
|
||||||
@ -653,25 +653,25 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (strlen_utf8(s0) <= leng) {
|
if (strlen_utf8(s0) <= leng) {
|
||||||
return Yap_LookupAtom(s0);
|
return Yap_LookupAtom(s0);
|
||||||
} else {
|
} else {
|
||||||
size_t n = get_utf8(s, 1, &ch);
|
size_t n = get_utf8(s, -1, &ch);
|
||||||
unsigned char *buf = Malloc(n + 1);
|
unsigned char *buf = Malloc(n + 1);
|
||||||
memcpy(buf, s0, n + 1);
|
memcpy(buf, s0, n + 1);
|
||||||
return Yap_ULookupAtom(buf);
|
return Yap_ULookupAtom(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write_buffer(unsigned char *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
size_t write_buffer(unsigned char *s0, seq_tv_t *out, size_t leng USES_REGS) {
|
||||||
size_t min = 0, max = leng, room_end;
|
size_t min = 0, max = leng, room_end;
|
||||||
if (out->enc == ENC_ISO_UTF8) {
|
if (out->enc == ENC_ISO_UTF8) {
|
||||||
room_end = strlen((char *)s0) + 1;
|
room_end = strlen((char *) s0) + 1;
|
||||||
if (out->val.uc == NULL) { // this should always be the case
|
if (out->val.uc == NULL) { // this should always be the case
|
||||||
out->val.uc = malloc(room_end < 16 ? 16 : room_end);
|
out->val.uc = malloc(room_end < 16 ? 16 : room_end);
|
||||||
}
|
}
|
||||||
if (out->val.uc != s0) {
|
if (out->val.uc != s0) {
|
||||||
strcpy(out->val.c, (char *)s0);
|
strcpy(out->val.c, (char *) s0);
|
||||||
}
|
}
|
||||||
} else if (out->enc == ENC_ISO_LATIN1) {
|
} else if (out->enc == ENC_ISO_LATIN1) {
|
||||||
room_end = strlen((char *)s0) + 1;
|
room_end = strlen((char *) s0) + 1;
|
||||||
unsigned char *s = s0;
|
unsigned char *s = s0;
|
||||||
unsigned char *cp = s;
|
unsigned char *cp = s;
|
||||||
unsigned char *buf = out->val.uc;
|
unsigned char *buf = out->val.uc;
|
||||||
@ -698,7 +698,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
room_end = buf - out->val.uc;
|
room_end = buf - out->val.uc;
|
||||||
} else if (out->enc == ENC_WCHAR) {
|
} else if (out->enc == ENC_WCHAR) {
|
||||||
unsigned char *s = s0, *lim = s + (max = strnlen((char *)s0, max));
|
unsigned char *s = s0, *lim = s + (max = strnlen((char *) s0, max));
|
||||||
unsigned char *cp = s;
|
unsigned char *cp = s;
|
||||||
wchar_t *buf0, *buf;
|
wchar_t *buf0, *buf;
|
||||||
|
|
||||||
@ -726,35 +726,40 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
room_end = -1;
|
room_end = -1;
|
||||||
}
|
}
|
||||||
return room_end;
|
return room_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t write_length(const unsigned char *s0, seq_tv_t *out,
|
static size_t write_length(const unsigned char *s0, seq_tv_t *out,
|
||||||
size_t leng USES_REGS) {
|
size_t leng USES_REGS) {
|
||||||
return leng;
|
return leng;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term write_number(unsigned char *s, seq_tv_t *out, int size,
|
static Term write_number(unsigned char *s, seq_tv_t *out, int size,
|
||||||
bool error_on USES_REGS) {
|
bool error_on USES_REGS) {
|
||||||
Term t;
|
Term t;
|
||||||
|
yap_error_number erro = LOCAL_Error_TYPE;
|
||||||
int i = push_text_stack();
|
int i = push_text_stack();
|
||||||
t = Yap_StringToNumberTerm((char *)s, &out->enc, error_on);
|
t = Yap_StringToNumberTerm((char *) s, &out->enc, error_on);
|
||||||
pop_text_stack(i);
|
pop_text_stack(i);
|
||||||
|
LOCAL_Error_TYPE = erro;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term string_to_term(void *s, seq_tv_t *out, size_t leng USES_REGS) {
|
static Term string_to_term(void *s, seq_tv_t *out, size_t leng USES_REGS) {
|
||||||
Term o;
|
Term o;
|
||||||
|
yap_error_number erro = LOCAL_Error_TYPE;
|
||||||
o = out->val.t = Yap_BufferToTerm(s, strlen(s) + 1, TermNil);
|
o = out->val.t = Yap_BufferToTerm(s, strlen(s) + 1, TermNil);
|
||||||
return o;
|
LOCAL_Error_TYPE = erro;
|
||||||
}
|
|
||||||
|
|
||||||
bool write_Text(unsigned char *inp, seq_tv_t *out, size_t leng USES_REGS) {
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool write_Text(unsigned char *inp, seq_tv_t *out, size_t leng USES_REGS) {
|
||||||
/* we know what the term is */
|
/* we know what the term is */
|
||||||
if (out->type == 0) {
|
if (out->type == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out->type & YAP_STRING_TERM) {
|
if (out->type & YAP_STRING_DATUM) {
|
||||||
if ((out->val.t = string_to_term(inp, out, leng PASS_REGS)) != 0L)
|
if ((out->val.t = string_to_term(inp, out, leng PASS_REGS)) != 0L)
|
||||||
return out->val.t != 0;
|
return out->val.t != 0;
|
||||||
}
|
}
|
||||||
@ -783,12 +788,12 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
case YAP_STRING_CHARS: {
|
case YAP_STRING_CHARS: {
|
||||||
size_t room = write_buffer(inp, out, leng PASS_REGS);
|
size_t room = write_buffer(inp, out, leng PASS_REGS);
|
||||||
// printf("%s\n", out->val.c);
|
// printf("%s\n", out->val.c);
|
||||||
return ((Int)room > 0);
|
return ((Int) room > 0);
|
||||||
}
|
}
|
||||||
case YAP_STRING_WCHARS: {
|
case YAP_STRING_WCHARS: {
|
||||||
size_t room = write_buffer(inp, out, leng PASS_REGS);
|
size_t room = write_buffer(inp, out, leng PASS_REGS);
|
||||||
// printf("%S\n", out->val.w);
|
// printf("%S\n", out->val.w);
|
||||||
return ((Int)room > 0);
|
return ((Int) room > 0);
|
||||||
}
|
}
|
||||||
case YAP_STRING_STRING:
|
case YAP_STRING_STRING:
|
||||||
out->val.t = write_strings(inp, out, leng PASS_REGS);
|
out->val.t = write_strings(inp, out, leng PASS_REGS);
|
||||||
@ -805,7 +810,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
case YAP_STRING_LENGTH:
|
case YAP_STRING_LENGTH:
|
||||||
out->val.l = write_length(inp, out, leng PASS_REGS);
|
out->val.l = write_length(inp, out, leng PASS_REGS);
|
||||||
// printf("s\n",out->val.l);
|
// printf("s\n",out->val.l);
|
||||||
return out->val.l != (size_t)(-1);
|
return out->val.l != (size_t) (-1);
|
||||||
case YAP_STRING_ATOM:
|
case YAP_STRING_ATOM:
|
||||||
out->val.a = write_atom(inp, out, leng PASS_REGS);
|
out->val.a = write_atom(inp, out, leng PASS_REGS);
|
||||||
// Yap_DebugPlWriteln(out->val.t);
|
// Yap_DebugPlWriteln(out->val.t);
|
||||||
@ -814,12 +819,14 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
out->val.t = write_number(inp, out, leng, true PASS_REGS);
|
out->val.t = write_number(inp, out, leng, true PASS_REGS);
|
||||||
// Yap_DebugPlWriteln(out->val.t);
|
// Yap_DebugPlWriteln(out->val.t);
|
||||||
return out->val.t != 0;
|
return out->val.t != 0;
|
||||||
default: { return true; }
|
default: {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t upcase(void *s0, seq_tv_t *out USES_REGS) {
|
static size_t upcase(void *s0, seq_tv_t *out USES_REGS) {
|
||||||
|
|
||||||
unsigned char *s = s0;
|
unsigned char *s = s0;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
@ -830,9 +837,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
s += put_utf8(s, chr);
|
s += put_utf8(s, chr);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t downcase(void *s0, seq_tv_t *out USES_REGS) {
|
static size_t downcase(void *s0, seq_tv_t *out USES_REGS) {
|
||||||
|
|
||||||
unsigned char *s = s0;
|
unsigned char *s = s0;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
@ -843,9 +850,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
s += put_utf8(s, chr);
|
s += put_utf8(s, chr);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) {
|
bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) {
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
bool rc;
|
bool rc;
|
||||||
|
|
||||||
@ -861,6 +868,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
*/
|
*/
|
||||||
// cnt++;
|
// cnt++;
|
||||||
buf = Yap_readText(inp, &leng PASS_REGS);
|
buf = Yap_readText(inp, &leng PASS_REGS);
|
||||||
|
if (!buf) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) {
|
if (out->type & (YAP_STRING_NCHARS | YAP_STRING_TRUNC)) {
|
||||||
if (out->max < leng) {
|
if (out->max < leng) {
|
||||||
const unsigned char *ptr = skip_utf8(buf, out->max);
|
const unsigned char *ptr = skip_utf8(buf, out->max);
|
||||||
@ -868,14 +878,11 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
char *nbuf = Malloc(diff + 1);
|
char *nbuf = Malloc(diff + 1);
|
||||||
memcpy(nbuf, buf, diff);
|
memcpy(nbuf, buf, diff);
|
||||||
nbuf[diff] = '\0';
|
nbuf[diff] = '\0';
|
||||||
leng = out->max;
|
leng = diff;
|
||||||
}
|
}
|
||||||
// else if (out->type & YAP_STRING_NCHARS &&
|
// else if (out->type & YAP_STRING_NCHARS &&
|
||||||
// const unsigned char *ptr = skip_utf8(buf, leng)
|
// const unsigned char *ptr = skip_utf8(buf, leng)
|
||||||
}
|
}
|
||||||
if (!buf) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (out->type & (YAP_STRING_UPCASE | YAP_STRING_DOWNCASE)) {
|
if (out->type & (YAP_STRING_UPCASE | YAP_STRING_DOWNCASE)) {
|
||||||
if (out->type & YAP_STRING_UPCASE) {
|
if (out->type & YAP_STRING_UPCASE) {
|
||||||
@ -904,17 +911,17 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
fprintf(stderr, "%s", out->val.c);
|
fprintf(stderr, "%s", out->val.c);
|
||||||
fprintf(stderr, "\n]\n"); */
|
fprintf(stderr, "\n]\n"); */
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static unsigned char *concat(int n, void *sv[] USES_REGS) {
|
static unsigned char *concat(int n, void *sv[] USES_REGS) {
|
||||||
void *buf;
|
void *buf;
|
||||||
unsigned char *buf0;
|
unsigned char *buf0;
|
||||||
size_t room = 0;
|
size_t room = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
room += strlen((char *)sv[i]);
|
room += strlen((char *) sv[i]);
|
||||||
}
|
}
|
||||||
buf = Malloc(room + 1);
|
buf = Malloc(room + 1);
|
||||||
buf0 = buf;
|
buf0 = buf;
|
||||||
@ -927,9 +934,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return buf0;
|
return buf0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS) {
|
static void *slice(size_t min, size_t max, const unsigned char *buf USES_REGS) {
|
||||||
unsigned char *nbuf = Malloc((max - min) * 4 + 1);
|
unsigned char *nbuf = Malloc((max - min) * 4 + 1);
|
||||||
const unsigned char *ptr = skip_utf8(buf, min);
|
const unsigned char *ptr = skip_utf8(buf, min);
|
||||||
unsigned char *nptr = nbuf;
|
unsigned char *nptr = nbuf;
|
||||||
@ -941,11 +948,11 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
nptr[0] = '\0';
|
nptr[0] = '\0';
|
||||||
return nbuf;
|
return nbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Out must be an atom or a string
|
// Out must be an atom or a string
|
||||||
bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
|
||||||
void **bufv;
|
void **bufv;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int i;
|
int i;
|
||||||
@ -969,10 +976,10 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
bool rc = write_Text(buf, out, strlen_utf8(buf) PASS_REGS);
|
bool rc = write_Text(buf, out, strlen_utf8(buf) PASS_REGS);
|
||||||
|
|
||||||
return rc;
|
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) {
|
seq_tv_t outv[] USES_REGS) {
|
||||||
const unsigned char *buf;
|
const unsigned char *buf;
|
||||||
size_t b_l, u_l;
|
size_t b_l, u_l;
|
||||||
@ -1000,7 +1007,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
u_l1 = u_l - u_l0;
|
u_l1 = u_l - u_l0;
|
||||||
|
|
||||||
buf1 = slice(u_l0, u_l, buf PASS_REGS);
|
buf1 = slice(u_l0, u_l, buf PASS_REGS);
|
||||||
b_l1 = strlen((const char *)buf1);
|
b_l1 = strlen((const char *) buf1);
|
||||||
bool rc = write_Text(buf1, outv + 1, b_l1 PASS_REGS);
|
bool rc = write_Text(buf1, outv + 1, b_l1 PASS_REGS);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
return false;
|
return false;
|
||||||
@ -1014,7 +1021,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
u_l1 = strlen_utf8(buf1);
|
u_l1 = strlen_utf8(buf1);
|
||||||
b_l0 = b_l - b_l1;
|
b_l0 = b_l - b_l1;
|
||||||
u_l0 = u_l - u_l1;
|
u_l0 = u_l - u_l1;
|
||||||
if (bcmp(skip_utf8((const unsigned char *)buf, b_l0), buf1, b_l1) !=
|
if (bcmp(skip_utf8((const unsigned char *) buf, b_l0), buf1, b_l1) !=
|
||||||
0) {
|
0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1039,9 +1046,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to convert a generic text term (string, atom, list of codes, list
|
* Function to convert a generic text term (string, atom, list of codes, list
|
||||||
of<
|
of<
|
||||||
atoms) into a buff
|
atoms) into a buff
|
||||||
@ -1055,8 +1062,8 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
*
|
*
|
||||||
* @return the buffer, or NULL in case of failure. If so, Yap_Error may be
|
* @return the buffer, or NULL in case of failure. If so, Yap_Error may be
|
||||||
called.
|
called.
|
||||||
*/
|
*/
|
||||||
const char *Yap_TextTermToText(Term t, char *buf, size_t len, encoding_t enc) {
|
const char *Yap_TextTermToText(Term t, char *buf, size_t len, encoding_t enc) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
inp.val.t = t;
|
inp.val.t = t;
|
||||||
@ -1078,9 +1085,9 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return NULL;
|
return NULL;
|
||||||
return out.val.c;
|
return out.val.c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert from a predicate structure to an UTF-8 string of the form
|
* Convert from a predicate structure to an UTF-8 string of the form
|
||||||
*
|
*
|
||||||
* module:name/arity.
|
* module:name/arity.
|
||||||
@ -1091,7 +1098,7 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
*
|
*
|
||||||
* @return the temporary string
|
* @return the temporary string
|
||||||
*/
|
*/
|
||||||
const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) {
|
const char *Yap_PredIndicatorToUTF8String(PredEntry *ap) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
Atom at;
|
Atom at;
|
||||||
arity_t arity = 0;
|
arity_t arity = 0;
|
||||||
@ -1120,10 +1127,11 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (ap->ModuleOfPred == IDB_MODULE) {
|
if (ap->ModuleOfPred == IDB_MODULE) {
|
||||||
if (ap->PredFlags & NumberDBPredFlag) {
|
if (ap->PredFlags & NumberDBPredFlag) {
|
||||||
Int key = ap->src.IndxId;
|
Int key = ap->src.IndxId;
|
||||||
snprintf(s, smax - s, "%" PRIdPTR, key);
|
snprintf(s, smax - s, "%"
|
||||||
|
PRIdPTR, key);
|
||||||
return LOCAL_FileNameBuf;
|
return LOCAL_FileNameBuf;
|
||||||
} else if (ap->PredFlags & AtomDBPredFlag) {
|
} else if (ap->PredFlags & AtomDBPredFlag) {
|
||||||
at = (Atom)(ap->FunctorOfPred);
|
at = (Atom) (ap->FunctorOfPred);
|
||||||
if (!Yap_AtomToUTF8Text(at, s))
|
if (!Yap_AtomToUTF8Text(at, s))
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -1136,18 +1144,19 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
if (arity) {
|
if (arity) {
|
||||||
at = NameOfFunctor(ap->FunctorOfPred);
|
at = NameOfFunctor(ap->FunctorOfPred);
|
||||||
} else {
|
} else {
|
||||||
at = (Atom)(ap->FunctorOfPred);
|
at = (Atom) (ap->FunctorOfPred);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Yap_AtomToUTF8Text(at, s)) {
|
if (!Yap_AtomToUTF8Text(at, s)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
s += strlen(s);
|
s += strlen(s);
|
||||||
snprintf(s, smax - s, "/%" PRIdPTR, arity);
|
snprintf(s, smax - s, "/%"
|
||||||
|
PRIdPTR, arity);
|
||||||
return s0;
|
return s0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert from a text buffer (8-bit) to a term that has the same type as
|
* Convert from a text buffer (8-bit) to a term that has the same type as
|
||||||
* _Tguide_
|
* _Tguide_
|
||||||
*
|
*
|
||||||
@ -1155,8 +1164,8 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
≈ * @param tguide the guide
|
≈ * @param tguide the guide
|
||||||
*
|
*
|
||||||
≈ * @return the term
|
≈ * @return the term
|
||||||
*/
|
*/
|
||||||
Term Yap_MkTextTerm(const char *s, encoding_t enc, Term tguide) {
|
Term Yap_MkTextTerm(const char *s, encoding_t enc, Term tguide) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
if (IsAtomTerm(tguide))
|
if (IsAtomTerm(tguide))
|
||||||
return MkAtomTerm(Yap_LookupAtom(s));
|
return MkAtomTerm(Yap_LookupAtom(s));
|
||||||
@ -1166,4 +1175,4 @@ static unsigned char *latin2utf8(seq_tv_t *inp, size_t *lengp) {
|
|||||||
return Yap_CharsToListOfAtoms(s, enc PASS_REGS);
|
return Yap_CharsToListOfAtoms(s, enc PASS_REGS);
|
||||||
}
|
}
|
||||||
return Yap_CharsToListOfCodes(s, enc PASS_REGS);
|
return Yap_CharsToListOfCodes(s, enc PASS_REGS);
|
||||||
}
|
}
|
||||||
|
19
H/YapText.h
19
H/YapText.h
@ -660,6 +660,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.val.t = t0;
|
inp.val.t = t0;
|
||||||
inp.type = YAP_STRING_ATOM;
|
inp.type = YAP_STRING_ATOM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -687,6 +688,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES;
|
YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_ATOMS_CODES;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = YAP_STRING_STRING;
|
out.type = YAP_STRING_STRING;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -715,6 +717,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM;
|
YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = mod_to_type(mod PASS_REGS);
|
out.type = mod_to_type(mod PASS_REGS);
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -754,6 +757,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_CHARS;
|
inp.type = YAP_STRING_CHARS;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = YAP_STRING_ATOM;
|
out.type = YAP_STRING_ATOM;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
return out.val.a;
|
return out.val.a;
|
||||||
@ -925,6 +929,8 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_ATOMS;
|
inp.type = YAP_STRING_ATOMS;
|
||||||
out.type = YAP_STRING_ATOM;
|
out.type = YAP_STRING_ATOM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return (Atom)NULL;
|
return (Atom)NULL;
|
||||||
return out.val.a;
|
return out.val.a;
|
||||||
@ -937,6 +943,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
out.type =
|
out.type =
|
||||||
YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM;
|
YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG | YAP_STRING_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
return out.val.t;
|
return out.val.t;
|
||||||
@ -948,6 +955,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_ATOMS;
|
inp.type = YAP_STRING_ATOMS;
|
||||||
out.type = YAP_STRING_STRING;
|
out.type = YAP_STRING_STRING;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
return out.val.t;
|
return out.val.t;
|
||||||
@ -959,6 +967,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_CODES;
|
inp.type = YAP_STRING_CODES;
|
||||||
out.type = YAP_STRING_ATOM;
|
out.type = YAP_STRING_ATOM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return (Atom)NULL;
|
return (Atom)NULL;
|
||||||
return out.val.a;
|
return out.val.a;
|
||||||
@ -969,6 +978,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.val.t = t0;
|
inp.val.t = t0;
|
||||||
inp.type = YAP_STRING_CODES;
|
inp.type = YAP_STRING_CODES;
|
||||||
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -981,6 +991,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_CODES;
|
inp.type = YAP_STRING_CODES;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = YAP_STRING_STRING;
|
out.type = YAP_STRING_STRING;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
return out.val.t;
|
return out.val.t;
|
||||||
@ -992,6 +1003,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_ATOMS_CODES;
|
inp.type = YAP_STRING_ATOMS_CODES;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = YAP_STRING_ATOM;
|
out.type = YAP_STRING_ATOM;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
return out.val.a;
|
return out.val.a;
|
||||||
@ -1002,6 +1014,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.val.t = t0;
|
inp.val.t = t0;
|
||||||
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
out.type = YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
|
out.type = YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
|
||||||
YAP_STRING_BIG | YAP_STRING_OUTPUT_TERM;
|
YAP_STRING_BIG | YAP_STRING_OUTPUT_TERM;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
@ -1015,6 +1028,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.val.t = t0;
|
inp.val.t = t0;
|
||||||
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES;
|
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
out.type = YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
@ -1029,6 +1043,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = YAP_STRING_STRING;
|
out.type = YAP_STRING_STRING;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -1044,6 +1059,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
YAP_STRING_OUTPUT_TERM;
|
YAP_STRING_OUTPUT_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = YAP_STRING_STRING;
|
out.type = YAP_STRING_STRING;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -1057,6 +1073,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = mod_to_type(mod PASS_REGS);
|
out.type = mod_to_type(mod PASS_REGS);
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -1070,6 +1087,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
inp.type = YAP_STRING_STRING | YAP_STRING_ATOMS_CODES | YAP_STRING_TERM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.type = mod_to_bqtype(mod PASS_REGS);
|
out.type = mod_to_bqtype(mod PASS_REGS);
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
|
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
return 0L;
|
return 0L;
|
||||||
@ -1083,6 +1101,7 @@ static inline size_t Yap_AtomToLength(Term t0 USES_REGS) {
|
|||||||
inp.val.c0 = s;
|
inp.val.c0 = s;
|
||||||
inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS;
|
inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS;
|
||||||
inp.enc = enc;
|
inp.enc = enc;
|
||||||
|
out.enc = ENC_ISO_UTF8;
|
||||||
out.type = YAP_STRING_ATOM;
|
out.type = YAP_STRING_ATOM;
|
||||||
out.val.uc = NULL;
|
out.val.uc = NULL;
|
||||||
out.max = len;
|
out.max = len;
|
||||||
|
@ -379,8 +379,8 @@ typedef void (*YAP_halt_hook)(int exit_code, void *closure);
|
|||||||
/* each type has a tag */
|
/* each type has a tag */
|
||||||
typedef YAP_Int YAP_opaque_tag_t;
|
typedef YAP_Int YAP_opaque_tag_t;
|
||||||
|
|
||||||
typedef YAP_Bool (*YAP_Opaque_CallOnFail)(void *);
|
typedef YAP_Bool (*YAP_Opaque_CallOnFail)(YAP_Term);
|
||||||
typedef YAP_Bool (*YAP_Opaque_CallOnCut)(void *);
|
typedef YAP_Bool (*YAP_Opaque_CallOnCut)(YAP_Term);
|
||||||
typedef YAP_Bool (*YAP_Opaque_CallOnWrite)(FILE *, YAP_opaque_tag_t, void *,
|
typedef YAP_Bool (*YAP_Opaque_CallOnWrite)(FILE *, YAP_opaque_tag_t, void *,
|
||||||
int);
|
int);
|
||||||
typedef YAP_Int (*YAP_Opaque_CallOnGCMark)(YAP_opaque_tag_t, void *, YAP_Term *,
|
typedef YAP_Int (*YAP_Opaque_CallOnGCMark)(YAP_opaque_tag_t, void *, YAP_Term *,
|
||||||
|
@ -140,16 +140,16 @@ static UInt cvtFlags(unsigned flags) {
|
|||||||
inptype |= YAP_STRING_FLOAT;
|
inptype |= YAP_STRING_FLOAT;
|
||||||
}
|
}
|
||||||
if (flags & CVT_VARIABLE) {
|
if (flags & CVT_VARIABLE) {
|
||||||
inptype |= YAP_STRING_TERM;
|
inptype |= YAP_STRING_DATUM;
|
||||||
}
|
}
|
||||||
if (flags & CVT_WRITE) {
|
if (flags & CVT_WRITE) {
|
||||||
inptype |= YAP_STRING_TERM;
|
inptype |= YAP_STRING_DATUM;
|
||||||
}
|
}
|
||||||
if (flags & CVT_WRITEQ) {
|
if (flags & CVT_WRITEQ) {
|
||||||
inptype |= YAP_STRING_TERM | YAP_STRING_WQ;
|
inptype |= YAP_STRING_DATUM | YAP_STRING_WQ;
|
||||||
}
|
}
|
||||||
if (flags & CVT_WRITE_CANONICAL) {
|
if (flags & CVT_WRITE_CANONICAL) {
|
||||||
inptype |= YAP_STRING_TERM | YAP_STRING_WC;
|
inptype |= YAP_STRING_DATUM | YAP_STRING_WC;
|
||||||
}
|
}
|
||||||
return inptype;
|
return inptype;
|
||||||
}
|
}
|
||||||
|
@ -116,13 +116,14 @@ static char SccsId[] = "%W% %G%";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Yap_set_stream_to_buf(StreamDesc *st, const char *buf, size_t nchars) {
|
bool Yap_set_stream_to_buf(StreamDesc *st, const char *buf, encoding_t enc, size_t nchars) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
// like any file stream.
|
// like any file stream.
|
||||||
st->file = f = fmemopen((void *)buf, nchars, "r");
|
st->file = f = fmemopen((void *)buf, nchars, "r");
|
||||||
st->status = Input_Stream_f | InMemory_Stream_f | Seekable_Stream_f;
|
st->status = Input_Stream_f | InMemory_Stream_f | Seekable_Stream_f;
|
||||||
st->vfs = NULL;
|
st->vfs = NULL;
|
||||||
|
st->encoding = enc;
|
||||||
Yap_DefaultStreamOps(st);
|
Yap_DefaultStreamOps(st);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ extern Term Yap_StringToNumberTerm(const char *s, encoding_t *encp,
|
|||||||
extern int Yap_FormatFloat(Float f, char **s, size_t sz);
|
extern int Yap_FormatFloat(Float f, char **s, size_t sz);
|
||||||
extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
|
extern int Yap_open_buf_read_stream(const char *buf, size_t nchars,
|
||||||
encoding_t *encp, memBufSource src);
|
encoding_t *encp, memBufSource src);
|
||||||
extern bool Yap_set_stream_to_buf(struct stream_desc *st, const char *buf,
|
extern bool Yap_set_stream_to_buf(struct stream_desc *st, const char *buf, encoding_t enc,
|
||||||
size_t nchars);
|
size_t nchars);
|
||||||
extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src);
|
extern int Yap_open_buf_write_stream(encoding_t enc, memBufSource src);
|
||||||
extern Term Yap_BufferToTerm(const unsigned char *s, size_t sz, Term opts);
|
extern Term Yap_BufferToTerm(const unsigned char *s, size_t sz, Term opts);
|
||||||
|
@ -279,10 +279,352 @@ class YAPEngine;
|
|||||||
/* Put header files here or function declarations like below */
|
/* Put header files here or function declarations like below */
|
||||||
#include "yapi.hh"
|
#include "yapi.hh"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
#if THREADS
|
#if THREADS
|
||||||
#define Yap_regp regcache
|
#define Yap_regp regcache
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// we cannot consult YapInterface.h, that conflicts with what we
|
// we cannot consult YapInterface.h, that conflicts with what we
|
||||||
|
Reference in New Issue
Block a user