X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fsafari.c;h=7ad9a5ed2750de0e23c707fb0c5853b6494dd93a;hb=3731bdaf94aeba2550fc553aebe34831c203dc36;hp=4210a9288f1b0c8405cafd15d8141eaf1f79d275;hpb=1b5ef8265837240930862dddd2d7ef963a0cc211;p=idzebra-moved-to-github.git diff --git a/index/safari.c b/index/safari.c index 4210a92..7ad9a5e 100644 --- a/index/safari.c +++ b/index/safari.c @@ -1,4 +1,4 @@ -/* $Id: safari.c,v 1.7 2007-04-16 21:54:37 adam Exp $ +/* $Id: safari.c,v 1.10 2007-10-29 16:57:53 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -127,21 +127,29 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) (*p->init)(p, &recWord); if (!fi_gets(fi, line, sizeof(line)-1)) - return RECCTRL_EXTRACT_ERROR_GENERIC; + return RECCTRL_EXTRACT_EOF; sscanf(line, "%255s", p->match_criteria); - recWord.index_type = '0'; while (fi_gets(fi, line, sizeof(line)-1)) { int nor = 0; char field[40]; - char *cp; + const char *cp = line; + char type_cstr[2]; #if 0 yaz_log(YLOG_LOG, "safari line: %s", line); #endif + type_cstr[1] = '\0'; + if (*cp >= '0' && *cp <= '9') + type_cstr[0] = '0'; /* the default is 0 (raw) */ + else + type_cstr[0] = *cp++; /* type given */ + type_cstr[1] = '\0'; + + recWord.index_type = type_cstr; if (tinfo->segments) { - if (sscanf(line, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT + if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT ZINT_FORMAT " %39s %n", &recWord.record_id, &recWord.section_id, &recWord.segment, @@ -154,7 +162,7 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) } else { - if (sscanf(line, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT " %39s %n", + if (sscanf(cp, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT " %39s %n", &recWord.record_id, &recWord.section_id, &recWord.seqno, field, &nor) < 4) { @@ -162,7 +170,7 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) return RECCTRL_EXTRACT_ERROR_GENERIC; } } - for (cp = line + nor; *cp == ' '; cp++) + for (cp = cp + nor; *cp == ' '; cp++) ; recWord.index_name = field; recWord.term_buf = cp;