X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=4f50db2eae6ceb49c9edb220e2ea174bb9d6642f;hb=9af45a7f129664e5f802ff1cdfce08fbce8b1adb;hp=2246d083af6f0caecfd00a76ae466d7a4b070c8f;hpb=a5cd2d2f5db7fde5a699ad3fadc82cce5149b284;p=idzebra-moved-to-github.git 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; }