From c093259af1129171ffb244fe10f5110d7463d88d Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 5 Aug 2005 10:40:13 +0000 Subject: [PATCH] Fixed bug #400: Generic record IDs doesn't match. --- index/extract.c | 37 +++++++++++++++++++------------------ index/kdump.c | 3 ++- index/zinfo.c | 16 +++++++++++++++- index/zinfo.h | 4 +++- test/api/t6.c | 4 ++-- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/index/extract.c b/index/extract.c index 59822b9..25a20fc 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.187 2005-06-23 06:45:46 adam Exp $ +/* $Id: extract.c,v 1.188 2005-08-05 10:40:13 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -98,42 +98,45 @@ static void extract_init (struct recExtractCtrl *p, RecWord *w) w->section_id = 0; } -static const char **searchRecordKey (ZebraHandle zh, - struct recKeys *reckeys, - int attrSetS, int attrUseS) +static void searchRecordKey(ZebraHandle zh, + const struct recKeys *reckeys, + int attrSetS, int attrUseS, + const char **ws, int ws_length) { - static const char *ws[32]; void *decode_handle = iscz1_start(); int off = 0; int startSeq = -1; int seqno = 0; int i; + int ch; - for (i = 0; i<32; i++) + for (i = 0; ireg->zei, + attrSetS, attrUseS); + if (ch < 0) + return ; + while (off < reckeys->buf_used) { const char *src = reckeys->buf + off; struct it_key key; char *dst = (char*) &key; - int attrSet, attrUse; iscz1_decode(decode_handle, &dst, &src); assert(key.len <= 4 && key.len > 2); - attrSet = (int) key.mem[0] >> 16; - attrUse = (int) key.mem[0] & 65535; seqno = (int) key.mem[key.len-1]; - if (attrUseS == attrUse && attrSetS == attrSet) + if (key.mem[0] == ch) { int woff; if (startSeq == -1) startSeq = seqno; woff = seqno - startSeq; - if (woff >= 0 && woff < 31) + if (woff >= 0 && woff < ws_length) ws[woff] = src; } @@ -143,7 +146,6 @@ static const char **searchRecordKey (ZebraHandle zh, } iscz1_stop(decode_handle); assert (off == reckeys->buf_used); - return ws; } struct file_read_info { @@ -218,7 +220,6 @@ static char *fileMatchStr (ZebraHandle zh, static char dstBuf[2048]; /* static here ??? */ char *dst = dstBuf; const char *s = spec; - static const char **w; while (1) { @@ -228,6 +229,7 @@ static char *fileMatchStr (ZebraHandle zh, break; if (*s == '(') { + const char *ws[32]; char attset_str[64], attname_str[64]; data1_attset *attset; int i; @@ -260,8 +262,7 @@ static char *fileMatchStr (ZebraHandle zh, else attUse = atoi (attname_str); } - w = searchRecordKey (zh, reckeys, attSet, attUse); - assert (w); + searchRecordKey (zh, reckeys, attSet, attUse, ws, 32); if (*s == ')') { @@ -277,15 +278,15 @@ static char *fileMatchStr (ZebraHandle zh, s++; for (i = 0; i<32; i++) - if (matchFlag[i] && w[i]) + if (matchFlag[i] && ws[i]) { if (first) { *dst++ = ' '; first = 0; } - strcpy (dst, w[i]); - dst += strlen(w[i]); + strcpy (dst, ws[i]); + dst += strlen(ws[i]); } if (first) { diff --git a/index/kdump.c b/index/kdump.c index c899eda..ce273be 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -1,4 +1,4 @@ -/* $Id: kdump.c,v 1.29 2005-06-14 20:28:54 adam Exp $ +/* $Id: kdump.c,v 1.30 2005-08-05 10:40:13 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -23,6 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include #ifdef WIN32 #include #endif diff --git a/index/zinfo.c b/index/zinfo.c index c40e76e..fc355db 100644 --- a/index/zinfo.c +++ b/index/zinfo.c @@ -1,4 +1,4 @@ -/* $Id: zinfo.c,v 1.46 2005-06-23 06:45:46 adam Exp $ +/* $Id: zinfo.c,v 1.47 2005-08-05 10:40:13 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1359,6 +1359,20 @@ static void zebraExplain_writeTarget (ZebraExplainInfo zei, int key_flush) rec_put (zei->records, &trec); } +int zebraExplain_lookup_attr_su_any_index(ZebraExplainInfo zei, + int set, int use) +{ + struct zebSUInfoB *zsui; + + assert (zei->curDatabaseInfo); + for (zsui = zei->curDatabaseInfo->attributeDetails->SUInfo; + zsui; zsui=zsui->next) + if (zsui->info.which == ZEB_SU_SET_USE && + zsui->info.u.su.use == use && zsui->info.u.su.set == set) + return zsui->info.ordinal; + return -1; +} + int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type, int set, int use) { diff --git a/index/zinfo.h b/index/zinfo.h index a7c0bce..1c55b81 100644 --- a/index/zinfo.h +++ b/index/zinfo.h @@ -1,4 +1,4 @@ -/* $Id: zinfo.h,v 1.24 2005-06-23 06:45:46 adam Exp $ +/* $Id: zinfo.h,v 1.25 2005-08-05 10:40:13 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -52,6 +52,8 @@ int zebraExplain_newDatabase (ZebraExplainInfo zei, const char *database, int explain_database); int zebraExplain_lookup_attr_su(ZebraExplainInfo zei, int index_type, int set, int use); +int zebraExplain_lookup_attr_su_any_index(ZebraExplainInfo zei, + int set, int use); int zebraExplain_add_attr_su(ZebraExplainInfo zei, int index_type, int set, int use); int zebraExplain_lookup_attr_str(ZebraExplainInfo zei, int index_type, diff --git a/test/api/t6.c b/test/api/t6.c index 33ea395..5d73bf2 100644 --- a/test/api/t6.c +++ b/test/api/t6.c @@ -1,4 +1,4 @@ -/* $Id: t6.c,v 1.9 2005-06-14 20:01:21 adam Exp $ +/* $Id: t6.c,v 1.10 2005-08-05 10:40:13 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -27,7 +27,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA int main(int argc, char **argv) { int i; - ZebraService zs = start_up(0, argc, argv); + ZebraService zs = start_up("zebra6.cfg", argc, argv); ZebraHandle zh = zebra_open(zs); srand(17); -- 1.7.10.4