X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=recctrl%2Frectext.c;h=7c7c9c0338a4cc3caf33e588371497f76d420d7f;hb=5b886a7358c16434d5c9f5f0d4af2f6e2e5d5c73;hp=0dba6455a67568022ea0190f718b1a93705e5414;hpb=94ad502634fd97a08c4af0731eb3eddca13a3691;p=idzebra-moved-to-github.git diff --git a/recctrl/rectext.c b/recctrl/rectext.c index 0dba645..7c7c9c0 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -4,7 +4,19 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: rectext.c,v $ - * Revision 1.2 1996-10-29 14:02:45 adam + * Revision 1.5 1997-10-27 14:33:06 adam + * Moved towards generic character mapping depending on "structure" + * field in abstract syntax file. Fixed a few memory leaks. Fixed + * bug with negative integers when doing searches with relational + * operators. + * + * Revision 1.4 1996/11/04 14:09:16 adam + * Minor changes. + * + * Revision 1.3 1996/11/01 09:00:33 adam + * This simple "text" format now supports element specs B and M. + * + * Revision 1.2 1996/10/29 14:02:45 adam * Uses buffered read to speed up things. * * Revision 1.1 1996/10/11 10:57:28 adam @@ -66,10 +78,10 @@ struct buf_info *buf_open (struct recExtractCtrl *p) int buf_read (struct buf_info *fi, char *dst) { - if (fi->max <= 0) - return 0; if (fi->offset >= fi->max) { + if (fi->max <= 0) + return 0; fi->max = (*fi->p->readf)(fi->p->fh, fi->buf, 4096); fi->offset = 0; if (fi->max <= 0) @@ -93,7 +105,7 @@ static int text_extract (struct recExtractCtrl *p) struct buf_info *fi = buf_open (p); (*p->init)(&recWord); - recWord.which = Word_String; + recWord.reg_type = 'w'; do { int i = 0; @@ -111,7 +123,7 @@ static int text_extract (struct recExtractCtrl *p) w[j] = tolower(w[j]); w[i] = 0; recWord.seqno = seqno++; - recWord.u.string = w; + recWord.string = w; (*p->add)(&recWord); } } while (r > 0); @@ -125,6 +137,12 @@ static int text_retrieve (struct recRetrieveCtrl *p) static char *text_buf = NULL; static int text_size = 0; int start_flag = 1; + const char *elementSetName = NULL; + int no_lines = 0; + + if (p->comp && p->comp->which == Z_RecordComp_simple && + p->comp->u.simple->which == Z_ElementSetNames_generic) + elementSetName = p->comp->u.simple->u.generic; while (1) { @@ -157,6 +175,27 @@ static int text_retrieve (struct recRetrieveCtrl *p) break; text_ptr += r; } + text_buf[text_ptr] = '\0'; + if (elementSetName) + { + if (!strcmp (elementSetName, "B")) + no_lines = 4; + if (!strcmp (elementSetName, "M")) + no_lines = 20; + } + if (no_lines) + { + char *p = text_buf; + int i = 0; + + while (++i <= no_lines && (p = strchr (p, '\n'))) + p++; + if (p) + { + p[1] = '\0'; + text_ptr = p-text_buf; + } + } p->output_format = VAL_SUTRS; p->rec_buf = text_buf; p->rec_len = text_ptr;