From e87336d1ad9587d0a7fdc805e2b53c77d435d67c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 4 Aug 2006 14:35:39 +0000 Subject: [PATCH] Use yaz_read_UTF8_char instead of xmlGetUTF8Char --- include/yaz/yaz-iconv.h | 7 +++++- src/nfaxml.c | 60 +++++++++++++++++++++++------------------------ src/siconv.c | 27 +++++++++++++-------- 3 files changed, 52 insertions(+), 42 deletions(-) diff --git a/include/yaz/yaz-iconv.h b/include/yaz/yaz-iconv.h index b629e92..599f8ad 100644 --- a/include/yaz/yaz-iconv.h +++ b/include/yaz/yaz-iconv.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: yaz-iconv.h,v 1.9 2006-04-19 23:15:39 adam Exp $ + * $Id: yaz-iconv.h,v 1.10 2006-08-04 14:35:39 adam Exp $ */ /** * \file yaz-iconv.h @@ -69,6 +69,11 @@ YAZ_EXPORT int yaz_matchstr(const char *s1, const char *s2); YAZ_EXPORT int yaz_strcmp_del(const char *a, const char *b, const char *b_del); +YAZ_EXPORT unsigned long yaz_read_UTF8_char(unsigned char *inp, + size_t inbytesleft, + size_t *no_read, + int *error); + YAZ_END_CDECL #endif diff --git a/src/nfaxml.c b/src/nfaxml.c index 94ef5e6..8a49693 100644 --- a/src/nfaxml.c +++ b/src/nfaxml.c @@ -1,7 +1,7 @@ /* Copyright (C) 2006, Index Data ApS * See the file LICENSE for details. * - * $Id: nfaxml.c,v 1.9 2006-07-14 13:06:38 heikki Exp $ + * $Id: nfaxml.c,v 1.10 2006-08-04 14:35:40 adam Exp $ */ /** @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -34,14 +35,14 @@ static int utf16_content(xmlNodePtr node, yaz_nfa_char *buf, int maxlen, { int bufidx=0; xmlChar *content = xmlNodeGetContent(node); - xmlChar *cp=content; - int conlen=strlen((char *)content); - int len; - int res; - while (*cp && (bufidx= 0xfe) { *no_read = 0; - cd->my_errno = YAZ_ICONV_EILSEQ; + *error = YAZ_ICONV_EILSEQ; } else if (inp[0] <= 0xdf && inbytesleft >= 2) { @@ -221,7 +222,7 @@ static unsigned long yaz_read_UTF8 (yaz_iconv_t cd, unsigned char *inp, else { *no_read = 0; - cd->my_errno = YAZ_ICONV_EILSEQ; + *error = YAZ_ICONV_EILSEQ; } } else if (inp[0] <= 0xef && inbytesleft >= 3) @@ -233,7 +234,7 @@ static unsigned long yaz_read_UTF8 (yaz_iconv_t cd, unsigned char *inp, else { *no_read = 0; - cd->my_errno = YAZ_ICONV_EILSEQ; + *error = YAZ_ICONV_EILSEQ; } } else if (inp[0] <= 0xf7 && inbytesleft >= 4) @@ -245,7 +246,7 @@ static unsigned long yaz_read_UTF8 (yaz_iconv_t cd, unsigned char *inp, else { *no_read = 0; - cd->my_errno = YAZ_ICONV_EILSEQ; + *error = YAZ_ICONV_EILSEQ; } } else if (inp[0] <= 0xfb && inbytesleft >= 5) @@ -258,7 +259,7 @@ static unsigned long yaz_read_UTF8 (yaz_iconv_t cd, unsigned char *inp, else { *no_read = 0; - cd->my_errno = YAZ_ICONV_EILSEQ; + *error = YAZ_ICONV_EILSEQ; } } else if (inp[0] <= 0xfd && inbytesleft >= 6) @@ -271,17 +272,23 @@ static unsigned long yaz_read_UTF8 (yaz_iconv_t cd, unsigned char *inp, else { *no_read = 0; - cd->my_errno = YAZ_ICONV_EILSEQ; + *error = YAZ_ICONV_EILSEQ; } } else { *no_read = 0; - cd->my_errno = YAZ_ICONV_EINVAL; + *error = YAZ_ICONV_EINVAL; } return x; } +static unsigned long yaz_read_UTF8 (yaz_iconv_t cd, unsigned char *inp, + size_t inbytesleft, size_t *no_read) +{ + return yaz_read_UTF8_char(inp, inbytesleft, no_read, &cd->my_errno); +} + static unsigned long yaz_read_UCS4 (yaz_iconv_t cd, unsigned char *inp, size_t inbytesleft, size_t *no_read) { -- 1.7.10.4