From 6b0e4847ddb1d62dffd5d4de4a1240b3fa3afd8a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 14 Nov 2014 13:39:47 +0000 Subject: Update with API extension from the NetSurf version --- src/utf8proc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/utf8proc.c') diff --git a/src/utf8proc.c b/src/utf8proc.c index ef2d433..3e0b25f 100644 --- a/src/utf8proc.c +++ b/src/utf8proc.c @@ -387,7 +387,7 @@ ssize_t utf8proc_decompose( if (decomp_result < 0) return decomp_result; wpos += decomp_result; /* prohibiting integer overflows due to too long strings: */ - if (wpos < 0 || wpos > SSIZE_MAX/sizeof(int32_t)/2) + if (wpos < 0 || wpos > (ssize_t)(SSIZE_MAX/sizeof(int32_t)/2)) return UTF8PROC_ERROR_OVERFLOW; } } @@ -413,7 +413,7 @@ ssize_t utf8proc_decompose( return wpos; } -ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) { +ssize_t utf8proc_normalise(int32_t *buffer, ssize_t length, int options) { /* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored ASSERT: 'buffer' has one spare byte of free space at the end! */ if (options & (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS | UTF8PROC_STRIPCC)) { @@ -516,6 +516,13 @@ ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) { } length = wpos; } + return length; +} + +ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) { + length = utf8proc_normalise(buffer, length, options); + if (length < 0) return length; + { ssize_t rpos, wpos = 0; int32_t uc; -- cgit v1.2.3