This commit is contained in:
Vitor Santos Costa 2016-08-22 17:01:31 -05:00
parent ce4b6c0931
commit a675f6f49e
2 changed files with 15 additions and 2 deletions

View File

@ -338,6 +338,11 @@ unsigned char *Yap_readText(seq_tv_t *inp, size_t *lengp) {
return latin2utf8(inp, lengp);
}
}
if (IsStringTerm(inp->val.t) && inp->type & YAP_STRING_STRING) {
// this is a term, extract to a buffer, and representation is wide
//Yap_DebugPlWriteln(inp->val.t);
return UStringOfTerm(inp->val.t);
}
if (((inp->type & (YAP_STRING_CODES | YAP_STRING_ATOMS)) ==
(YAP_STRING_CODES | YAP_STRING_ATOMS)) && IsPairTerm(inp->val.t)) {
//Yap_DebugPlWriteln(inp->val.t);

View File

@ -209,8 +209,12 @@ X_API int PL_get_nchars(term_t l, size_t *lengthp, char **s, unsigned flags) {
} else {
out.enc = ENC_ISO_LATIN1;
}
if (flags & BUF_MALLOC)
if (flags & BUF_MALLOC) {
out.type |= YAP_STRING_MALLOC;
out.val.c = *s;
} else {
out.val.c = NULL;
}
if (lengthp) {
out.type |= YAP_STRING_NCHARS;
out.max = *lengthp;
@ -232,8 +236,12 @@ int PL_get_wchars(term_t l, size_t *lengthp, wchar_t **s, unsigned flags) {
inp.val.t = Yap_GetFromSlot(l);
inp.type = cvtFlags(flags);
out.type = YAP_STRING_WCHARS;
if (flags & BUF_MALLOC)
if (flags & BUF_MALLOC) {
out.type |= YAP_STRING_MALLOC;
out.val.w = *s;
} else {
out.val.w = NULL;
}
if (lengthp) {
out.type |= YAP_STRING_NCHARS;
out.max = *lengthp;