X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=index%2Fzrpn.c;h=24a7ae71f60dd83f239a6e601f651f1999173d46;hb=162fa86044b5aa303c03fa26f1ecf140b34060d5;hp=b6ee62d3ab1a62726b506d094bc8c4f269b83d22;hpb=6617321a09d4d5bf442feaea2d7f1347acd82e3c;p=idzebra-moved-to-github.git diff --git a/index/zrpn.c b/index/zrpn.c index b6ee62d..24a7ae7 100644 --- a/index/zrpn.c +++ b/index/zrpn.c @@ -4,7 +4,16 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zrpn.c,v $ - * Revision 1.32 1995-10-27 14:00:11 adam + * Revision 1.35 1995-11-27 09:29:00 adam + * Bug fixes regarding conversion to regular expressions. + * + * Revision 1.34 1995/11/16 17:00:56 adam + * Better logging of rpn query. + * + * Revision 1.33 1995/11/01 13:58:28 quinn + * Moving data1 to yaz/retrieval + * + * Revision 1.32 1995/10/27 14:00:11 adam * Implemented detection of database availability. * * Revision 1.31 1995/10/17 18:02:10 adam @@ -112,7 +121,7 @@ #include #include "zserver.h" -#include +#include "attribute.h" #include #include @@ -134,45 +143,6 @@ int index_word_prefix_map (char *string, oid_value attrSet, int attrUse, attp->local_attribute, basename); } -/* - * attr_print: log attributes - */ -static void attr_print (Z_AttributesPlusTerm *t) -{ - int of, i; - for (of = 0; of < t->num_attributes; of++) - { - Z_AttributeElement *element; - element = t->attributeList[of]; - - switch (element->which) - { - case Z_AttributeValue_numeric: - logf (LOG_DEBUG, "attributeType=%d value=%d", - *element->attributeType, - *element->value.numeric); - break; - case Z_AttributeValue_complex: - logf (LOG_DEBUG, "attributeType=%d complex", - *element->attributeType); - for (i = 0; ivalue.complex->num_list; i++) - { - if (element->value.complex->list[i]->which == - Z_StringOrNumeric_string) - logf (LOG_DEBUG, " string: '%s'", - element->value.complex->list[i]->u.string); - else if (element->value.complex->list[i]->which == - Z_StringOrNumeric_numeric) - logf (LOG_DEBUG, " numeric: '%d'", - *element->value.complex->list[i]->u.numeric); - } - break; - default: - assert (0); - } - } -} - typedef struct { int type; int major; @@ -688,9 +658,8 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, { case -1: /* not specified */ case 100: /* do not truncate */ - strcat (term_dict, "("); - strcat (term_dict, term_sub); - strcat (term_dict, ")"); + sprintf (term_dict + strlen(term_dict), + "([]%d %s)", strlen(term_sub), term_sub); logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict); r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, &max_pos, grep_handle); @@ -698,8 +667,8 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, logf (LOG_WARN, "dict_lookup_grep err, trunc=none:%d", r); break; case 1: /* right truncation */ - strcat (term_dict, term_sub); - strcat (term_dict, ".*"); + sprintf (term_dict + strlen(term_dict), + "([]%d %s.*)", strlen(term_sub), term_sub); dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, &max_pos, grep_handle); break; @@ -708,17 +677,20 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, zi->errCode = 120; return -1; case 101: /* process # in term */ - for (j = strlen(term_dict), i = 0; term_sub[i] && i < 2; i++) - term_dict[j++] = term_sub[i]; - for (; term_sub[i]; i++) - if (term_sub[i] == '#') + strcat (term_dict, "("); + j = strlen(term_dict); + for (i=0; term_sub[i]; i++) + if (i > 2 && term_sub[i] == '#') { term_dict[j++] = '.'; term_dict[j++] = '*'; } else + { + term_dict[j++] = '\\'; term_dict[j++] = term_sub[i]; - term_dict[j] = '\0'; + } + strcpy (term_dict+j, ")"); r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, &max_pos, grep_handle); if (r) @@ -726,9 +698,7 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, r); break; case 102: /* regular expression */ - strcat (term_dict, "("); - strcat (term_dict, term_sub); - strcat (term_dict, ")"); + sprintf (term_dict + strlen(term_dict), "(%s)", term_sub); logf (LOG_DEBUG, "dict_lookup_grep: %s", term_dict); r = dict_lookup_grep (zi->wordDict, term_dict, 0, grep_info, &max_pos, grep_handle); @@ -738,7 +708,6 @@ static int trunc_term (ZServerInfo *zi, Z_AttributesPlusTerm *zapt, break; } } - logf (LOG_DEBUG, "max_pos = %d", max_pos); if (max_pos <= strlen(basenames[base_no])) { zi->errCode = 109; /* Database unavailable */ @@ -1215,12 +1184,13 @@ int rpn_search (ZServerInfo *zi, oident *attrset; oid_value attributeSet; + zlog_rpn (rpn); + zi->errCode = 0; zi->errString = NULL; - + attrset = oid_getentbyoid (rpn->attributeSetId); attributeSet = attrset->value; - rset = rpn_search_structure (zi, rpn->RPNStructure, attributeSet, num_bases, basenames); if (!rset)