support text to buffer
This commit is contained in:
parent
15c6381579
commit
1ead544a50
33
H/YapText.h
33
H/YapText.h
@ -181,7 +181,6 @@ inline static utf8proc_ssize_t strlen_utf8(const utf8proc_uint8_t *pt) {
|
|||||||
} else {
|
} else {
|
||||||
pt++;
|
pt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -391,8 +390,7 @@ static inline seq_type_t mod_to_bqtype(Term mod USES_REGS) {
|
|||||||
|
|
||||||
// the routines
|
// the routines
|
||||||
|
|
||||||
extern unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp
|
extern unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp USES_REGS);
|
||||||
USES_REGS);
|
|
||||||
extern bool write_Text(unsigned char *inp, seq_tv_t *out,
|
extern bool write_Text(unsigned char *inp, seq_tv_t *out,
|
||||||
size_t leng USES_REGS);
|
size_t leng USES_REGS);
|
||||||
extern bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS);
|
extern bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS);
|
||||||
@ -738,7 +736,6 @@ static inline Atom Yap_UTF8ToAtom(const unsigned char *s USES_REGS) {
|
|||||||
return out.val.a;
|
return out.val.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail,
|
static inline Term Yap_CharsToDiffListOfCodes(const char *s, Term tail,
|
||||||
encoding_t enc USES_REGS) {
|
encoding_t enc USES_REGS) {
|
||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
@ -1083,7 +1080,6 @@ static inline Term Yap_NCharsToTBQ(const char *s, size_t len, encoding_t enc,
|
|||||||
inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS;
|
inp.type = YAP_STRING_CHARS | YAP_STRING_NCHARS;
|
||||||
inp.enc = enc;
|
inp.enc = enc;
|
||||||
|
|
||||||
|
|
||||||
out.type = mod_to_bqtype(mod PASS_REGS);
|
out.type = mod_to_bqtype(mod PASS_REGS);
|
||||||
out.max = len;
|
out.max = len;
|
||||||
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
if (!Yap_CVT_Text(&inp, &out PASS_REGS))
|
||||||
@ -1215,8 +1211,8 @@ static inline size_t Yap_StringToAtomic(Term t0 USES_REGS) {
|
|||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
inp.val.t = t0;
|
inp.val.t = t0;
|
||||||
inp.type = YAP_STRING_STRING;
|
inp.type = YAP_STRING_STRING;
|
||||||
out.type = YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT |
|
out.type =
|
||||||
YAP_STRING_BIG ;
|
YAP_STRING_ATOM | YAP_STRING_INT | YAP_STRING_FLOAT | YAP_STRING_BIG;
|
||||||
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;
|
||||||
@ -1322,6 +1318,17 @@ static inline Term Yap_TextToString(Term t0 USES_REGS) {
|
|||||||
return out.val.t;
|
return out.val.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void Yap_OverwriteUTF8BufferToLowCase(void *buf USES_REGS) {
|
||||||
|
unsigned char *s = (unsigned char *)buf;
|
||||||
|
while (*s) {
|
||||||
|
// assumes the two code have always the same size;
|
||||||
|
utf8proc_int32_t chr;
|
||||||
|
get_utf8(s, -1, &chr);
|
||||||
|
chr = utf8proc_tolower(chr);
|
||||||
|
s += put_utf8(s, chr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) {
|
static inline const unsigned char *Yap_TextToUTF8Buffer(Term t0 USES_REGS) {
|
||||||
seq_tv_t inp, out;
|
seq_tv_t inp, out;
|
||||||
|
|
||||||
@ -1456,8 +1463,7 @@ static inline Atom Yap_SubtractHeadAtom(Term t1, Term th USES_REGS) {
|
|||||||
outv[0].val.t = th;
|
outv[0].val.t = th;
|
||||||
outv[1].type = YAP_STRING_ATOM;
|
outv[1].type = YAP_STRING_ATOM;
|
||||||
outv[1].val.t = 0;
|
outv[1].val.t = 0;
|
||||||
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp,
|
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS))
|
||||||
outv PASS_REGS))
|
|
||||||
return (Atom)NULL;
|
return (Atom)NULL;
|
||||||
return outv[1].val.a;
|
return outv[1].val.a;
|
||||||
}
|
}
|
||||||
@ -1470,8 +1476,7 @@ static inline Atom Yap_SubtractTailAtom(Term t1, Term th USES_REGS) {
|
|||||||
outv[0].val.t = 0;
|
outv[0].val.t = 0;
|
||||||
outv[1].type = YAP_STRING_ATOM;
|
outv[1].type = YAP_STRING_ATOM;
|
||||||
outv[1].val.t = th;
|
outv[1].val.t = th;
|
||||||
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp,
|
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS))
|
||||||
outv PASS_REGS))
|
|
||||||
return (Atom)NULL;
|
return (Atom)NULL;
|
||||||
return outv[0].val.a;
|
return outv[0].val.a;
|
||||||
}
|
}
|
||||||
@ -1501,8 +1506,7 @@ static inline Term Yap_SubtractHeadString(Term t1, Term th USES_REGS) {
|
|||||||
outv[0].val.t = th;
|
outv[0].val.t = th;
|
||||||
outv[1].type = YAP_STRING_STRING;
|
outv[1].type = YAP_STRING_STRING;
|
||||||
outv[1].val.t = 0;
|
outv[1].val.t = 0;
|
||||||
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp,
|
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS))
|
||||||
outv PASS_REGS))
|
|
||||||
return 0L;
|
return 0L;
|
||||||
return outv[1].val.t;
|
return outv[1].val.t;
|
||||||
}
|
}
|
||||||
@ -1515,8 +1519,7 @@ static inline Term Yap_SubtractTailString(Term t1, Term th USES_REGS) {
|
|||||||
outv[0].val.t = 0;
|
outv[0].val.t = 0;
|
||||||
outv[1].type = YAP_STRING_STRING;
|
outv[1].type = YAP_STRING_STRING;
|
||||||
outv[1].val.t = th;
|
outv[1].val.t = th;
|
||||||
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp,
|
if (!Yap_Splice_Text(2, (size_t *)NULL, &inp, outv PASS_REGS))
|
||||||
outv PASS_REGS))
|
|
||||||
return 0L;
|
return 0L;
|
||||||
return outv[0].val.t;
|
return outv[0].val.t;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user