From 46d18b14e7af411cd9b9a4614e6bb0cb1a99069c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 20 Mar 2007 22:07:35 +0000 Subject: [PATCH] Use yaz_iconv flushing. --- data1/d1_read.c | 7 ++++--- index/untrans.c | 5 ++++- index/zaptterm.c | 3 ++- index/zsets.c | 6 +++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/data1/d1_read.c b/data1/d1_read.c index 68ee97f..8247e62 100644 --- a/data1/d1_read.c +++ b/data1/d1_read.c @@ -1,4 +1,4 @@ -/* $Id: d1_read.c,v 1.23 2007-03-19 21:50:39 adam Exp $ +/* $Id: d1_read.c,v 1.24 2007-03-20 22:07:35 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -1013,14 +1013,15 @@ static int conv_item (NMEM m, yaz_iconv_t t, { char *outbuf = wrbuf->buf + wrbuf->pos; size_t outlen = wrbuf->size - wrbuf->pos; - if (yaz_iconv (t, &inbuf, &inlen, &outbuf, &outlen) == + if (yaz_iconv(t, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1) && yaz_iconv_error(t) != YAZ_ICONV_E2BIG) { /* bad data. stop and skip conversion entirely */ return -1; } else if (inlen == 0) - { /* finished converting */ + { /* finished converting, flush it */ + yaz_iconv(t, 0, 0, &outbuf, &outlen); wrbuf->pos = wrbuf->size - outlen; break; } diff --git a/index/untrans.c b/index/untrans.c index fce2372..0e9adf1 100644 --- a/index/untrans.c +++ b/index/untrans.c @@ -1,4 +1,4 @@ -/* $Id: untrans.c,v 1.2 2007-01-15 15:10:17 adam Exp $ +/* $Id: untrans.c,v 1.3 2007-03-20 22:07:35 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -71,7 +71,10 @@ void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, int reg_type, if (ret == (size_t)(-1)) len = 0; else + { + yaz_iconv (zh->iconv_from_utf8, 0, 0, &outbuf, &outleft); len = outbuf - term_dst; + } *dst = nmem_malloc(stream, len + 1); if (len > 0) memcpy (*dst, term_dst, len); diff --git a/index/zaptterm.c b/index/zaptterm.c index 591e1c4..42a5912 100644 --- a/index/zaptterm.c +++ b/index/zaptterm.c @@ -1,4 +1,4 @@ -/* $Id: zaptterm.c,v 1.2 2007-01-15 15:10:17 adam Exp $ +/* $Id: zaptterm.c,v 1.3 2007-03-20 22:07:35 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -57,6 +57,7 @@ ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt, 0); return ZEBRA_FAIL; } + yaz_iconv(zh->iconv_to_utf8, 0, 0, &outbuf, &outleft); *outbuf = 0; } else diff --git a/index/zsets.c b/index/zsets.c index 111649d..a81f4d8 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.119 2007-01-17 15:35:48 adam Exp $ +/* $Id: zsets.c,v 1.120 2007-03-20 22:07:35 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -1207,7 +1207,11 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, if (ret == (size_t)(-1)) *termlen = 0; else + { + yaz_iconv(zh->iconv_from_utf8, 0, 0, + &outbuf, &outleft); *termlen = outbuf - termbuf; + } } else { -- 1.7.10.4