From 8bfa835959ce6983b50c6babd34ec631625106d0 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Tue, 17 Apr 2018 18:28:37 +0100 Subject: [PATCH] avoid getting stuck ith output. --- H/YapText.h | 4 ++-- os/format.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/H/YapText.h b/H/YapText.h index 7d5ac5a83..2c5738203 100644 --- a/H/YapText.h +++ b/H/YapText.h @@ -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, diff --git a/os/format.c b/os/format.c index 1b3faff12..00f40802c 100644 --- a/os/format.c +++ b/os/format.c @@ -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) {