X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=recctrl%2Frectext.c;h=ba618d6b30c8eeb4fe9380c2a133a2c00f7d7f46;hb=296574b8e825da3594047d8d63c9639d90866047;hp=c243f8c68dad2a85e8a082ef43e78b2ccac263fc;hpb=3c4d4c20c0735741737e66cf8d270a87fa7eb58e;p=idzebra-moved-to-github.git diff --git a/recctrl/rectext.c b/recctrl/rectext.c index c243f8c..ba618d6 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -1,4 +1,4 @@ -/* $Id: rectext.c,v 1.26 2005-03-31 12:42:07 adam Exp $ +/* $Id: rectext.c,v 1.31 2006-05-10 08:13:30 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -39,9 +39,14 @@ static void *filter_init (Res res, RecType recType) return tinfo; } -static void filter_config(void *clientData, Res res, const char *args) +static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) { - + struct filter_info *tinfo = (struct filter_info*) clientData; + xfree(tinfo->sep); + tinfo->sep = 0; + if (args && *args) + tinfo->sep = xstrdup(args); + return ZEBRA_OK; } static void filter_destroy (void *clientData) @@ -69,7 +74,7 @@ static struct buf_info *buf_open (struct recExtractCtrl *p) return fi; } -static int buf_read (struct filter_info *tinfo, struct buf_info *fi, char *dst) +static int buf_getchar (struct filter_info *tinfo, struct buf_info *fi, char *dst) { if (fi->offset >= fi->max) { @@ -103,33 +108,34 @@ static int filter_extract (void *clientData, struct recExtractCtrl *p) RecWord recWord; int r; struct buf_info *fi = buf_open (p); + int no_read = 0; #if 0 yaz_log(YLOG_LOG, "filter_extract off=%ld", (long) (*fi->p->tellf)(fi->p->fh)); #endif - xfree(tinfo->sep); - tinfo->sep = 0; (*p->init)(p, &recWord); - recWord.reg_type = 'w'; do { int i = 0; - r = buf_read (tinfo, fi, w); + r = buf_getchar (tinfo, fi, w); while (r > 0 && i < 511 && w[i] != '\n' && w[i] != '\r') { i++; - r = buf_read (tinfo, fi, w + i); + r = buf_getchar (tinfo, fi, w + i); } if (i) { + no_read += i; recWord.term_buf = w; recWord.term_len = i; (*p->tokenAdd)(&recWord); } } while (r > 0); buf_close (fi); + if (no_read == 0) + return RECCTRL_EXTRACT_EOF; return RECCTRL_EXTRACT_OK; } @@ -249,3 +255,11 @@ idzebra_filter &filter_type, 0, }; +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +