From: Adam Dickmeiss Date: Wed, 2 Feb 2005 20:50:38 +0000 (+0000) Subject: Fixed bug #263: YAZ MARCXML dump shows extra spaces after control fields. X-Git-Tag: YAZ.2.0.34~19 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=1769f2fbe5b8de995b351754eec51ccdb1824dd4;p=yaz-moved-to-github.git Fixed bug #263: YAZ MARCXML dump shows extra spaces after control fields. Added yaz_marc_subfield_str which defines subfield lead string which is used in YAZ_MARC_LINE format. Default string is blank+$. Added yaz_marc_endline_str which defines end of fields string used in YAZ_MARC_LINE format. Default string is newline. --- diff --git a/include/yaz/marcdisp.h b/include/yaz/marcdisp.h index 9078043..51fcf0e 100644 --- a/include/yaz/marcdisp.h +++ b/include/yaz/marcdisp.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: marcdisp.h,v 1.11 2005-01-15 19:47:09 adam Exp $ + * $Id: marcdisp.h,v 1.12 2005-02-02 20:50:38 adam Exp $ */ /** @@ -81,6 +81,8 @@ YAZ_EXPORT int marc_display_wrbuf (const char *buf, WRBUF wr, int debug, YAZ_EXPORT int yaz_marc_decode(const char *buf, WRBUF wr, int debug, int bsize, int xml); +YAZ_EXPORT void yaz_marc_subfield_str(yaz_marc_t mt, const char *s); +YAZ_EXPORT void yaz_marc_endline_str(yaz_marc_t mt, const char *s); /* like atoi except that it reads exactly len characters */ YAZ_EXPORT int atoi_n (const char *buf, int len); diff --git a/src/marcdisp.c b/src/marcdisp.c index bec05d9..d07d291 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.12 2005-01-15 19:47:14 adam Exp $ + * $Id: marcdisp.c,v 1.13 2005-02-02 20:50:38 adam Exp $ */ /** @@ -26,6 +26,8 @@ struct yaz_marc_t_ { int xml; int debug; yaz_iconv_t iconv_cd; + char subfield_str[8]; + char endline_str[8]; }; yaz_marc_t yaz_marc_create(void) @@ -35,9 +37,23 @@ yaz_marc_t yaz_marc_create(void) mt->debug = 0; mt->m_wr = wrbuf_alloc(); mt->iconv_cd = 0; + strcpy(mt->subfield_str, " $"); + strcpy(mt->endline_str, "\n"); return mt; } +void yaz_marc_subfield_str(yaz_marc_t mt, const char *s) +{ + strncpy(mt->subfield_str, s, sizeof(mt->subfield_str)-1); + mt->subfield_str[sizeof(mt->subfield_str)-1] = '\0'; +} + +void yaz_marc_endline_str(yaz_marc_t mt, const char *s) +{ + strncpy(mt->endline_str, s, sizeof(mt->endline_str)-1); + mt->endline_str[sizeof(mt->endline_str)-1] = '\0'; +} + void yaz_marc_destroy(yaz_marc_t mt) { if (!mt) @@ -376,7 +392,7 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) i += identifier_length; break; case YAZ_MARC_LINE: - wrbuf_puts (wr, " $"); + wrbuf_puts (wr, mt->subfield_str); marc_cdata(mt, buf+i, identifier_length-1, wr); i = i+identifier_length-1; wrbuf_putc (wr, ' '); @@ -425,7 +441,7 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) marc_cdata(mt, buf + i, 1, wr); } if (mt->xml == YAZ_MARC_LINE) - wrbuf_putc (wr, '\n'); + wrbuf_puts (wr, mt->endline_str); if (i < end_offset) wrbuf_printf(wr, " \n", data_length); if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS) @@ -437,15 +453,15 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr) break; case YAZ_MARC_OAIMARC: if (identifier_flag) - wrbuf_puts (wr, " \n"); + wrbuf_puts (wr, "\n"); else - wrbuf_puts (wr, " \n"); + wrbuf_puts (wr, "\n"); break; case YAZ_MARC_MARCXML: if (identifier_flag) - wrbuf_puts (wr, " \n"); + wrbuf_puts (wr, "\n"); else - wrbuf_puts (wr, " \n"); + wrbuf_puts (wr, "\n"); break; } }