From 77ed4252c6c8b2c99069cc4f6214821a3068a04d Mon Sep 17 00:00:00 2001 From: Luo Jinghua Date: Thu, 7 Jan 2010 20:11:06 +0800 Subject: uniconv: replace short with uc_uint16_t --- unicode.c | 5 ++--- unicode.h | 4 ++-- utfconverter.c | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/unicode.c b/unicode.c index 68b9a31..fe87fb1 100644 --- a/unicode.c +++ b/unicode.c @@ -12,7 +12,7 @@ unicode_valide(uc_char_t unichar) } int -ucs4toutf16(uc_char_t unichar, short *utf16) +ucs4toutf16(uc_char_t unichar, uc_uint16_t *utf16) { unsigned len; @@ -39,13 +39,12 @@ ucs4toutf16(uc_char_t unichar, short *utf16) } int -ucs4fromutf16(const short *str, uc_char_t *ret, int inlen) +ucs4fromutf16(const uc_uint16_t *utf16, uc_char_t *ret, int inlen) { static const uc_char_t UNI_SUR_HIGH_START = 0xd800; static const uc_char_t UNI_SUR_HIGH_END = 0xdbff; static const uc_char_t UNI_SUR_LOW_START = 0xdc00; static const uc_char_t UNI_SUR_LOW_END = 0xdfff; - const unsigned short *utf16 = (const unsigned short *)str; uc_char_t ch; int len = 1; diff --git a/unicode.h b/unicode.h index 168d8a2..6a74557 100644 --- a/unicode.h +++ b/unicode.h @@ -4,10 +4,10 @@ #include int -ucs4toutf16(uc_char_t unichar, short *utf16); +ucs4toutf16(uc_char_t unichar, uc_uint16_t *utf16); int -ucs4fromutf16(const short *utf16, uc_char_t *ucs4, int len); +ucs4fromutf16(const uc_uint16_t *utf16, uc_char_t *ucs4, int len); int ucs4toutf8(uc_char_t unichar, char *utf8); diff --git a/utfconverter.c b/utfconverter.c index 039c39f..9818c27 100644 --- a/utfconverter.c +++ b/utfconverter.c @@ -73,13 +73,13 @@ utf16_encode(struct converter *conv, size_t outleft) { size_t i; - short **soutbuf = (short **)outbuf; + uc_uint16_t **soutbuf = (uc_uint16_t **)outbuf; for (i = 0; i < inleft; i++) { int seqlen = ucs4toutf16(**inbuf, NULL); if (seqlen < 0) return UNICONV_EILSEQ; - if (seqlen * sizeof(short) > outleft) + if (seqlen * sizeof(uc_uint16_t) > outleft) return UNICONV_E2BIG; ucs4toutf16(**inbuf, *soutbuf); @@ -93,16 +93,17 @@ utf16_encode(struct converter *conv, static int utf16_decode(struct converter *conv, - const char **inbuf, - size_t inleft, - uc_char_t **outbuf, - size_t outleft) + const char **inbuf, + size_t inleft, + uc_char_t **outbuf, + size_t outleft) { - const short **sinbuf = (const short**)inbuf; + const uc_uint16_t **sinbuf = (const uc_uint16_t**)inbuf; while (inleft) { uc_char_t unichar; - int seqlen = ucs4fromutf16(*sinbuf, &unichar, inleft / sizeof(short)); + int seqlen = ucs4fromutf16(*sinbuf, &unichar, + inleft / sizeof(uc_uint16_t)); if (seqlen == -2) return UNICONV_E2BIG; else if (seqlen < 0) @@ -115,7 +116,7 @@ utf16_decode(struct converter *conv, outleft -= 1; (*sinbuf) += seqlen; - inleft -= seqlen * sizeof(short); + inleft -= seqlen * sizeof(uc_uint16_t); } return UNICONV_SUCCESS; -- cgit v1.2.3