From: Adam Dickmeiss Date: Fri, 6 Oct 1995 13:52:00 +0000 (+0000) Subject: Bug fixes. Handler may abort further scanning. X-Git-Tag: ZEBRA.1.0~715 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=9af45a7f129664e5f802ff1cdfce08fbce8b1adb;p=idzebra-moved-to-github.git Bug fixes. Handler may abort further scanning. --- diff --git a/dict/scan.c b/dict/scan.c index fc80b6f..ba93ed6 100644 --- a/dict/scan.c +++ b/dict/scan.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: scan.c,v $ - * Revision 1.3 1995-10-06 11:06:07 adam + * Revision 1.4 1995-10-06 13:52:00 adam + * Bug fixes. Handler may abort further scanning. + * + * Revision 1.3 1995/10/06 11:06:07 adam * Bug fixes. * * Revision 1.2 1995/10/06 10:43:16 adam @@ -21,7 +24,7 @@ #include -void dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, +int dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, int start, int *count, int (*userfunc)(Dict_char *, const char *, int pos), int dir) @@ -51,7 +54,8 @@ void dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, for (j = 0; info[j] != DICT_EOS; j++) str[pos+j] = info[j]; str[pos+j] = DICT_EOS; - (*userfunc)(str, info+(j+1)*sizeof(Dict_char), *count * dir); + if ((*userfunc)(str, info+(j+1)*sizeof(Dict_char), *count * dir)) + return 1; --(*count); } else @@ -71,8 +75,9 @@ void dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, if (info[sizeof(Dict_ptr)+sizeof(Dict_char)]) { str[pos+1] = DICT_EOS; - (*userfunc)(str, info+sizeof(Dict_ptr)+sizeof(Dict_char), - *count * dir); + if ((*userfunc)(str, info+sizeof(Dict_ptr)+sizeof(Dict_char), + *count * dir)) + return 1; --(*count); } if (*count > 0 && subptr) @@ -81,6 +86,7 @@ void dict_scan_trav (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, } lo += dir; } + return 0; } int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, @@ -108,9 +114,13 @@ int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, cmp = dict_strcmp ((Dict_char*) info, str + pos); if (!cmp) { - (*userfunc)(str, info+(dict_strlen(info)+1)*sizeof(Dict_char) - , *after); - --(*after); + if (*after) + { + (*userfunc)(str, info+ + (dict_strlen(info)+1)*sizeof(Dict_char), + *after); + --(*after); + } break; } } @@ -133,18 +143,24 @@ int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, { if (info[sizeof(Dict_ptr)+sizeof(Dict_char)]) { - (*userfunc)(str, - info+sizeof(Dict_ptr)+sizeof(Dict_char), - *after); - --(*after); + if (*after) + { + (*userfunc)(str, + info+sizeof(Dict_ptr)+ + sizeof(Dict_char), + *after); + --(*after); + } } - if (*after > 0 && subptr) - dict_scan_trav (dict, subptr, pos+1, str, 0, - after, userfunc, 1); + if (*after && subptr) + if (dict_scan_trav (dict, subptr, pos+1, str, 0, + after, userfunc, 1)) + return 1; } - else if (*after > 0 && subptr) - dict_scan_r (dict, subptr, pos+1, str, before, after, - userfunc); + else if (subptr) + if (dict_scan_r (dict, subptr, pos+1, str, before, after, + userfunc)) + return 1; break; } } @@ -156,11 +172,13 @@ int dict_scan_r (Dict dict, Dict_ptr ptr, int pos, Dict_char *str, if (lo>hi && cmp < 0) ++mid; if (*after) - dict_scan_trav (dict, ptr, pos, str, cmp ? mid : mid+1, after, - userfunc, 1); + if (dict_scan_trav (dict, ptr, pos, str, cmp ? mid : mid+1, after, + userfunc, 1)) + return 1; if (*before && mid > 1) - dict_scan_trav (dict, ptr, pos, str, mid-1, before, - userfunc, -1); + if (dict_scan_trav (dict, ptr, pos, str, mid-1, before, + userfunc, -1)) + return 1; return 0; } diff --git a/index/extract.c b/index/extract.c index 718ef0c..ea31d07 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.19 1995-10-04 12:55:16 adam + * Revision 1.20 1995-10-06 13:52:05 adam + * Bug fixes. Handler may abort further scanning. + * + * Revision 1.19 1995/10/04 12:55:16 adam * Bug fix in ranked search. Use=Any keys inserted. * * Revision 1.18 1995/10/04 09:37:08 quinn @@ -224,7 +227,7 @@ static void wordAdd (const RecWord *p) static void wordAddAny (const RecWord *p) { - if (p->attrSet != 1 && p->attrUse != 1016) + if (p->attrSet != 1 || p->attrUse != 1016) { RecWord w; diff --git a/index/zrpn.c b/index/zrpn.c index 2246d08..4f50db2 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.20 1995-10-06 11:06:33 adam + * Revision 1.21 1995-10-06 13:52:06 adam + * Bug fixes. Handler may abort further scanning. + * + * Revision 1.20 1995/10/06 11:06:33 adam * Scan entries include 'occurrences' now. * * Revision 1.19 1995/10/06 10:43:56 adam @@ -678,36 +681,46 @@ int rpn_search (ZServerInfo *zi, return zi->errCode; count_set (rset, hits); resultSetAdd (zi, setname, 1, rset); + if (zi->errCode) + logf (LOG_DEBUG, "search error: %d", zi->errCode); return zi->errCode; } static struct scan_entry *scan_list; static ODR scan_odr; static int scan_before, scan_after; -static int scan_prefix; static ISAM scan_isam; +static char scan_prefix[20]; static int scan_handle (Dict_char *name, const char *info, int pos) { - int idx; + int len_prefix, idx; ISAM_P isam_p; RSET rset; rset_isam_parms parms; + len_prefix = strlen(scan_prefix); + if (memcmp (name, scan_prefix, len_prefix)) + return 1; if (pos > 0) idx = scan_after - pos + scan_before; else idx = - pos - 1; - scan_list[idx].term = odr_malloc (scan_odr, strlen(name + scan_prefix)+1); - strcpy (scan_list[idx].term, name + scan_prefix); + scan_list[idx].term = odr_malloc (scan_odr, strlen(name + len_prefix)+1); + strcpy (scan_list[idx].term, name + len_prefix); assert (*info == sizeof(isam_p)); memcpy (&isam_p, info+1, sizeof(isam_p)); parms.is = scan_isam; parms.pos = isam_p; +#if 1 rset = rset_create (rset_kind_isam, &parms); count_set (rset, &scan_list[idx].occurrences); rset_delete (rset); +#else + scan_list[idx].occurrences = 1; +#endif + logf (LOG_DEBUG, "pos=%3d idx=%3d name=%s", pos, idx, name); return 0; } @@ -733,13 +746,16 @@ int rpn_scan (ZServerInfo *zi, ODR odr, Z_AttributesPlusTerm *zapt, scan_isam = zi->wordIsam; scan_list = *list = odr_malloc (odr, (before+after)*sizeof(**list)); + for (j = 0; ju.general->len; if (sizez > IT_MAX_WORD) sizez = IT_MAX_WORD; @@ -748,6 +764,9 @@ int rpn_scan (ZServerInfo *zi, ODR odr, Z_AttributesPlusTerm *zapt, termz[j+i] = '\0'; dict_scan (zi->wordDict, termz, &before, &after, scan_handle); + + if (zi->errCode) + logf (LOG_DEBUG, "search error: %d", zi->errCode); return 0; } diff --git a/index/zserver.c b/index/zserver.c index 1a29c3b..797a884 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.11 1995-10-06 10:43:57 adam + * Revision 1.12 1995-10-06 13:52:06 adam + * Bug fixes. Handler may abort further scanning. + * + * Revision 1.11 1995/10/06 10:43:57 adam * Scan added. 'occurrences' in scan entries not set yet. * * Revision 1.10 1995/10/02 16:43:32 quinn @@ -90,7 +93,6 @@ bend_initresult *bend_init (bend_initrequest *q) r.errstring = "is_open fail: wordisam"; return &r; } - server_info.recordBuf = NULL; server_info.odr = odr_createmem (ODR_ENCODE); return &r; } @@ -103,6 +105,8 @@ bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd) r.errstring = 0; r.hits = 0; + odr_reset (server_info.odr); + server_info.errCode = 0; switch (q->query->which) { case Z_Query_type_1: @@ -176,8 +180,9 @@ bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num) r.last_in_set = 0; r.basename = "base"; - xfree (server_info.recordBuf); - server_info.recordBuf = NULL; + odr_reset (server_info.odr); + server_info.errCode = 0; + positions[0] = q->number; records = resultSetSysnoGet (&server_info, q->setname, 1, positions); if (!records) @@ -207,13 +212,14 @@ bend_scanresult *bend_scan (void *handle, bend_scanrequest *q, int *num) static bend_scanresult r; odr_reset (server_info.odr); + server_info.errCode = 0; + r.errstring = 0; r.term_position = q->term_position; r.num_entries = q->num_entries; r.errcode = rpn_scan (&server_info, server_info.odr, q->term, &r.term_position, &r.num_entries, &r.entries); - r.errstring = 0; return &r; } @@ -223,8 +229,6 @@ void bend_close (void *handle) dict_close (server_info.wordDict); is_close (server_info.wordIsam); close (server_info.sys_idx_fd); - xfree (server_info.recordBuf); - server_info.recordBuf = NULL; return; } diff --git a/index/zserver.h b/index/zserver.h index 60cb91c..3c144a6 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.7 1995-10-06 10:43:57 adam + * Revision 1.8 1995-10-06 13:52:06 adam + * Bug fixes. Handler may abort further scanning. + * + * Revision 1.7 1995/10/06 10:43:57 adam * Scan added. 'occurrences' in scan entries not set yet. * * Revision 1.6 1995/09/28 09:19:48 adam @@ -54,7 +57,6 @@ typedef struct { ISAM wordIsam; Dict fileDict; int sys_idx_fd; - char *recordBuf; int errCode; char *errString; ODR odr;