From: Adam Dickmeiss Date: Thu, 8 Mar 2007 14:19:24 +0000 (+0000) Subject: For MARC reading skip until RS is met X-Git-Tag: ZEBRA.1.3.50~4 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=6cdb9c7f23fdaf5d769a7492cd9efb68a0006ff4;p=idzebra-moved-to-github.git For MARC reading skip until RS is met --- diff --git a/recctrl/marcread.c b/recctrl/marcread.c index 2815382..4d894ad 100644 --- a/recctrl/marcread.c +++ b/recctrl/marcread.c @@ -1,4 +1,4 @@ -/* $Id: marcread.c,v 1.24.2.7 2006-12-05 21:14:44 adam Exp $ +/* $Id: marcread.c,v 1.24.2.8 2007-03-08 14:19:24 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -74,21 +74,37 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) yaz_log(YLOG_WARN, "MARC record length < 25, is %d", record_length); return NULL; } - /* read remaining part - attempt to read one byte furhter... */ - read_bytes = (*p->readf)(p->fh, buf+5, record_length-4); + + + + read_bytes = (*p->readf)(p->fh, buf+5, record_length-5); if (read_bytes < record_length-5) { - yaz_log(YLOG_WARN, "Couldn't read whole MARC record"); + yaz_log (YLOG_WARN, "Couldn't read whole MARC record"); return NULL; } - if (read_bytes == record_length - 4) + /* skip until we meet a record separator */ + while (buf[record_length-1] != ISO2709_RS) + { + if (record_length > sizeof(buf)-2) + break; + read_bytes = (*p->readf)(p->fh, buf+record_length, 1); + if (read_bytes != 1) + break; + record_length++; + } + /* read one byte ahead to see if there is more ... */ + read_bytes = (*p->readf)(p->fh, buf+record_length, 1); + if (read_bytes == 1) { off_t cur_offset = (*p->tellf)(p->fh); - if (cur_offset <= 27) - return NULL; if (p->endf) - (*p->endf)(p->fh, cur_offset - 1); + { + off_t end_offset = cur_offset - 1; + (*p->endf)(p->fh, end_offset); + } } + absynName = p->type; res_root = data1_mk_root (p->dh, p->mem, absynName); if (!res_root)