fix strings.

This commit is contained in:
Vitor Santos Costa 2011-06-12 17:22:45 +01:00
parent f04a153e42
commit 787ca8fd05
1 changed files with 31 additions and 2 deletions

View File

@ -314,10 +314,39 @@ Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
size_t sz;
MP_INT *dst = (MP_INT *)(H+2);
blob_string_t *sp;
size_t siz;
size_t siz, i = 0;
sz = wcslen(s);
if (len > 0 && sz > len) sz = len;
while (i < sz) {
if (s[i++] >= 255) break;
}
if (i == sz) {
char *target;
size_t i = 0;
if (len/sizeof(CELL) > (ASP-ret)-1024) {
return TermNil;
}
H[0] = (CELL)FunctorBigInt;
H[1] = BLOB_STRING;
siz = (sizeof(size_t)+len+sizeof(CELL))/sizeof(CELL);
dst->_mp_size = siz;
dst->_mp_alloc = 0L;
sp = (blob_string_t *)(dst+1);
H = (CELL *)sp;
sp->len = sz;
target = (char *)(sp+1);
while (i < sz+1) {
target[i] = s[i];
i++;
}
H += siz;
H[0] = EndSpecials;
H++;
return AbsAppl(ret);
}
if (len/sizeof(CELL) > (ASP-ret)-1024) {
return TermNil;
}
@ -330,7 +359,7 @@ Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
sp = (blob_string_t *)(dst+1);
H = (CELL *)sp;
sp->len = sz;
wcsncpy((wchar_t *)(sp+1), s, sz);
wcsncpy((wchar_t *)(sp+1), s, sz+1);
H += siz;
H[0] = EndSpecials;
H++;