- j = prefix_len;
- switch (truncation_value)
- {
- case -1: /* not specified */
- case 100: /* do not truncate */
- term_dict[j++] = '(';
- for (i = 0; term_sub[i]; i++)
- verbatim_char (term_sub[i], &j, term_dict);
- strcpy (term_dict+j, ")");
- r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=none:%d", r);
- break;
- case 1: /* right truncation */
- term_dict[j++] = '(';
- for (i = 0; term_sub[i]; i++)
- verbatim_char (term_sub[i], &j, term_dict);
- strcpy (term_dict+j, ".*)");
- dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- break;
- case 2: /* left truncation */
- case 3: /* left&right truncation */
- zi->errCode = 120;
- return -1;
- case 101: /* process # in term */
- term_dict[j++] = '(';
- for (i=0; term_sub[i]; i++)
- if (term_sub[i] == '#' && i > 2)
- {
- term_dict[j++] = '.';
- term_dict[j++] = '*';
- }
- else
- verbatim_char (term_sub[i], &j, term_dict);
- strcpy (term_dict+j, ")");
- r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=#: %d",
- r);
- break;
- case 102: /* regular expression */
- sprintf (term_dict + j, "(%s)", term_sub);
- r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info,
- &max_pos, 0, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=regular: %d",
- r);
- break;
- case 103: /* regular expression with error correction */
- cp = term_sub;
- r = 0;
- if (*cp == '*' && cp[1] && cp[2])
- {
- r = atoi (cp+1);
- cp += 2;
- }
- sprintf (term_dict + j, "(%s)", cp);
- r = dict_lookup_grep (zi->wordDict, term_dict, r, grep_info,
- &max_pos, j, grep_handle);
- if (r)
- logf (LOG_WARN, "dict_lookup_grep err, trunc=eregular: %d",
- r);
- break;
- }
- }
- if (max_pos <= strlen(basenames[base_no]))
- {
- zi->errCode = 109; /* Database unavailable */
- zi->errString = basenames[base_no];
- return -1;
- }
-#endif
-#endif
- }
- logf (LOG_DEBUG, "%d positions", grep_info->isam_p_indx);
- return 0;
-}
-
-static void trans_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt,
- int regType, char *termz)
-{
- size_t i, sizez;
- Z_Term *term = zapt->term;
-
- sizez = term->u.general->len;
- if (sizez > IT_MAX_WORD-1)
- sizez = IT_MAX_WORD-1;
- termz[0] = regType;
- for (i = 0; i < sizez; i++)
- termz[i+1] = index_char_cvt (term->u.general->buf[i]);
- termz[i+1] = '\0';
-}
-
-static RSET rpn_search_APT_relevance (ZServerInfo *zi,
- Z_AttributesPlusTerm *zapt,
- oid_value attributeSet,
- int num_bases, char **basenames)