avoid getting stuck ith output.

This commit is contained in:
Vitor Santos Costa 2018-04-17 18:28:37 +01:00
parent 4b1efa59b4
commit 8bfa835959
2 changed files with 6 additions and 4 deletions

View File

@ -190,7 +190,7 @@ INLINE_ONLY inline EXTERN utf8proc_ssize_t get_utf8(const utf8proc_uint8_t *ptr,
if (rc < 0) {
LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_IN_CHARACTER_CODE;
}
return rc;
return rc < 1 ? 1 : rc;
}
INLINE_ONLY inline EXTERN utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr,
@ -202,7 +202,7 @@ INLINE_ONLY inline EXTERN utf8proc_ssize_t put_utf8(utf8proc_uint8_t *ptr,
if (rc < 0) {
LOCAL_ActiveError->errorNo = REPRESENTATION_ERROR_CHARACTER_CODE;
}
return rc;
return rc < 1 ? 1 : rc;
}
inline static const utf8proc_uint8_t *skip_utf8(const utf8proc_uint8_t *pt,

View File

@ -277,8 +277,10 @@ static int format_print_str(Int sno, Int size, Int has_size, Term args,
const unsigned char *pt = UStringOfTerm(args);
while (*pt && (!has_size || size > 0)) {
utf8proc_int32_t ch;
pt += get_utf8(pt, -1, &ch);
f_putc(sno, ch);
if ((pt += get_utf8(pt, -1, &ch)) > 0) {
f_putc(sno, ch);
}
}
} else {
while (!has_size || size > 0) {