* 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
#include <dict.h>
-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)
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
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)
}
lo += dir;
}
+ return 0;
}
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;
}
}
{
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;
}
}
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;
}
* 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
static void wordAddAny (const RecWord *p)
{
- if (p->attrSet != 1 && p->attrUse != 1016)
+ if (p->attrSet != 1 || p->attrUse != 1016)
{
RecWord w;
* 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
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;
}
scan_isam = zi->wordIsam;
scan_list = *list = odr_malloc (odr, (before+after)*sizeof(**list));
+ for (j = 0; j<before+after; j++)
+ scan_list[j].term = "------";
attr_init (&use, zapt, 1);
use_value = attr_find (&use);
logf (LOG_DEBUG, "use value %d", use_value);
if (use_value == -1)
use_value = 1016;
- scan_prefix = i = index_word_prefix (termz, 1, use_value);
+ i = index_word_prefix (termz, 1, use_value);
+ strcpy (scan_prefix, termz);
sizez = term->u.general->len;
if (sizez > IT_MAX_WORD)
sizez = IT_MAX_WORD;
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;
}
* 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
r.errstring = "is_open fail: wordisam";
return &r;
}
- server_info.recordBuf = NULL;
server_info.odr = odr_createmem (ODR_ENCODE);
return &r;
}
r.errstring = 0;
r.hits = 0;
+ odr_reset (server_info.odr);
+ server_info.errCode = 0;
switch (q->query->which)
{
case Z_Query_type_1:
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)
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;
}
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;
}
* 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
ISAM wordIsam;
Dict fileDict;
int sys_idx_fd;
- char *recordBuf;
int errCode;
char *errString;
ODR odr;