From: handa Date: Wed, 22 Sep 2004 00:07:43 +0000 (+0000) Subject: (count_utf_16_chars): Count each code of invalid X-Git-Tag: REL-1-2-0~185 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25e8693c53d5e64194b06ebd62c775450bee0bc2;p=m17n%2Fm17n-lib.git (count_utf_16_chars): Count each code of invalid surrogates as one. --- diff --git a/src/mtext.c b/src/mtext.c index f34586f..7f17852 100644 --- a/src/mtext.c +++ b/src/mtext.c @@ -449,22 +449,18 @@ count_utf_16_chars (const void *data, int nitems, int swap) if (prev_surrogate) { if (c < 0xDC00 || c >= 0xE000) - return -1; - prev_surrogate = 0; + /* Invalid surrogate */ + nchars++; } else { - if (c < 0xD800) - ; - else if (c < 0xDC00) + if (c >= 0xD800 && c < 0xDC00) prev_surrogate = 1; - else if (c < 0xE000) - return -1; nchars++; } } if (prev_surrogate) - return -1; + nchars++; return nchars; }