From: Adam Dickmeiss Date: Mon, 28 Aug 2006 12:34:40 +0000 (+0000) Subject: Fixed bug #643: Bad sequence for MARC conversions from UTF-8 to MARC-8. X-Git-Tag: YAZ.2.1.28~20 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=b925ea17d6f146a28d745b0d34e9eec6eafda21f Fixed bug #643: Bad sequence for MARC conversions from UTF-8 to MARC-8. Added test tstmarccol.sh for testing this. All sample ISO2709 marc records renamed to have suffix .marc. --- diff --git a/include/yaz/wrbuf.h b/include/yaz/wrbuf.h index c6df481..46e7e09 100644 --- a/include/yaz/wrbuf.h +++ b/include/yaz/wrbuf.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: wrbuf.h,v 1.18 2006-07-07 10:31:26 marc Exp $ + * $Id: wrbuf.h,v 1.19 2006-08-28 12:34:40 adam Exp $ */ /** * \file wrbuf.h @@ -67,6 +67,8 @@ YAZ_EXPORT int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, int size); YAZ_EXPORT int wrbuf_iconv_puts(WRBUF b, yaz_iconv_t cd, const char *strz); +YAZ_EXPORT int wrbuf_iconv_putchar(WRBUF b, yaz_iconv_t cd, int ch); + YAZ_EXPORT void wrbuf_chop_right(WRBUF b); #define wrbuf_len(b) ((b)->pos) diff --git a/src/marcdisp.c b/src/marcdisp.c index 1680ea5..1d408be 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.32 2006-08-01 09:28:04 adam Exp $ + * $Id: marcdisp.c,v 1.33 2006-08-28 12:34:40 adam Exp $ */ /** @@ -422,15 +422,20 @@ int yaz_marc_write_line(yaz_marc_t mt, WRBUF wr) wrbuf_puts (wr, mt->subfield_str); wrbuf_iconv_write(wr, mt->iconv_cd, s->code_data, using_code_len); - wrbuf_printf(wr, " "); + wrbuf_iconv_puts(wr, mt->iconv_cd, " "); wrbuf_iconv_puts(wr, mt->iconv_cd, s->code_data + using_code_len); + wrbuf_iconv_puts(wr, mt->iconv_cd, " "); + wr->pos--; } wrbuf_puts (wr, mt->endline_str); break; case YAZ_MARC_CONTROLFIELD: - wrbuf_printf(wr, "%s ", n->u.controlfield.tag); + wrbuf_printf(wr, "%s", n->u.controlfield.tag); + wrbuf_iconv_puts(wr, mt->iconv_cd, " "); wrbuf_iconv_puts(wr, mt->iconv_cd, n->u.controlfield.data); + wrbuf_iconv_puts(wr, mt->iconv_cd, " "); + wr->pos--; wrbuf_puts (wr, mt->endline_str); break; case YAZ_MARC_COMMENT: @@ -499,6 +504,7 @@ static int yaz_marc_write_marcxml_ns(yaz_marc_t mt, WRBUF wr, for (n = mt->nodes; n; n = n->next) { struct yaz_marc_subfield *s; + switch(n->which) { case YAZ_MARC_DATAFIELD: @@ -514,7 +520,7 @@ static int yaz_marc_write_marcxml_ns(yaz_marc_t mt, WRBUF wr, wrbuf_printf(wr, " ind%d=\"", i+1); wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.datafield.indicator+i, 1); - wrbuf_printf(wr, "\""); + wrbuf_iconv_puts(wr, mt->iconv_cd, "\""); } } wrbuf_printf(wr, ">\n"); @@ -528,14 +534,15 @@ static int yaz_marc_write_marcxml_ns(yaz_marc_t mt, WRBUF wr, : cdata_one_character(mt, s->code_data); - wrbuf_puts(wr, " iconv_cd, " iconv_cd, s->code_data, using_code_len); - wrbuf_puts(wr, "\">"); + wrbuf_iconv_puts(wr, mt->iconv_cd, "\">"); wrbuf_iconv_write_cdata(wr, mt->iconv_cd, s->code_data + using_code_len, strlen(s->code_data + using_code_len)); - wrbuf_puts(wr, "\n"); + wrbuf_iconv_puts(wr, mt->iconv_cd, ""); + wrbuf_puts(wr, "\n"); } wrbuf_printf(wr, " \n"); break; @@ -543,9 +550,10 @@ static int yaz_marc_write_marcxml_ns(yaz_marc_t mt, WRBUF wr, wrbuf_printf(wr, " iconv_cd, n->u.controlfield.tag, strlen(n->u.controlfield.tag)); - wrbuf_printf(wr, "\">"); + wrbuf_iconv_puts(wr, mt->iconv_cd, "\">"); wrbuf_iconv_puts(wr, mt->iconv_cd, n->u.controlfield.data); - wrbuf_printf(wr, "\n"); + wrbuf_iconv_puts(wr, mt->iconv_cd, ""); + wrbuf_puts(wr, "\n"); break; case YAZ_MARC_COMMENT: wrbuf_printf(wr, "