fix strings.
This commit is contained in:
parent
f04a153e42
commit
787ca8fd05
33
C/bignum.c
33
C/bignum.c
@ -314,10 +314,39 @@ Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
MP_INT *dst = (MP_INT *)(H+2);
|
MP_INT *dst = (MP_INT *)(H+2);
|
||||||
blob_string_t *sp;
|
blob_string_t *sp;
|
||||||
size_t siz;
|
size_t siz, i = 0;
|
||||||
|
|
||||||
sz = wcslen(s);
|
sz = wcslen(s);
|
||||||
if (len > 0 && sz > len) sz = len;
|
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) {
|
if (len/sizeof(CELL) > (ASP-ret)-1024) {
|
||||||
return TermNil;
|
return TermNil;
|
||||||
}
|
}
|
||||||
@ -330,7 +359,7 @@ Yap_MkBlobWideStringTerm(const wchar_t *s, size_t len)
|
|||||||
sp = (blob_string_t *)(dst+1);
|
sp = (blob_string_t *)(dst+1);
|
||||||
H = (CELL *)sp;
|
H = (CELL *)sp;
|
||||||
sp->len = sz;
|
sp->len = sz;
|
||||||
wcsncpy((wchar_t *)(sp+1), s, sz);
|
wcsncpy((wchar_t *)(sp+1), s, sz+1);
|
||||||
H += siz;
|
H += siz;
|
||||||
H[0] = EndSpecials;
|
H[0] = EndSpecials;
|
||||||
H++;
|
H++;
|
||||||
|
Reference in New Issue
Block a user