X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ccl%2Fcclfind.c;h=324cd58f45b8fa7a46cbac761a2bc3ffe9111eab;hb=717e787416d8f78f327fd6d458c82e8a4829c405;hp=3a9fd833fca4dbc5b6acbe9a3db2470c203ab11a;hpb=da907ba05501a2050d0a70b1d1fdf22a8130589a;p=yaz-moved-to-github.git diff --git a/ccl/cclfind.c b/ccl/cclfind.c index 3a9fd83..324cd58 100644 --- a/ccl/cclfind.c +++ b/ccl/cclfind.c @@ -45,7 +45,16 @@ * Europagate, 1995 * * $Log: cclfind.c,v $ - * Revision 1.22 2001-03-07 13:24:40 adam + * Revision 1.25 2001-10-03 23:54:41 adam + * Fixes for numeric ranges (date=1980-1990). + * + * Revision 1.24 2001/03/22 21:23:30 adam + * Directive s=pw sets structure to phrase if term includes blank(s). + * + * Revision 1.23 2001/03/20 11:22:58 adam + * CCL Truncation character may be defined. + * + * Revision 1.22 2001/03/07 13:24:40 adam * Member and_not in Z_Operator is kept for backwards compatibility. * Added support for definition of CCL operators in field spec file. * @@ -322,11 +331,13 @@ static void add_attr (struct ccl_rpn_node *p, const char *set, * search_term: Parse CCL search term. * cclp: CCL Parser * qa: Qualifier attributes already applied. + * term_list: tokens we accept as terms in context + * multi: whether we accept "multiple" tokens * return: pointer to node(s); NULL on error. */ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, struct ccl_rpn_attr **qa, - int *term_list) + int *term_list, int multi) { struct ccl_rpn_attr *qa_tmp[2]; struct ccl_rpn_node *p_top = 0; @@ -334,6 +345,12 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, int and_list = 0; int or_list = 0; char *attset; + const char *truncation_aliases; + + truncation_aliases = + ccl_qual_search_special(cclp->bibset, "truncation"); + if (!truncation_aliases) + truncation_aliases = "?"; if (!qa) { @@ -352,6 +369,7 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, { struct ccl_rpn_node *p; size_t no, i; + int no_spaces = 0; int left_trunc = 0; int right_trunc = 0; int mid_trunc = 0; @@ -362,7 +380,7 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, int completeness_value = -1; int len = 0; size_t max = 200; - if (and_list || or_list) + if (and_list || or_list || !multi) max = 1; /* go through each TERM token. If no truncation attribute is yet @@ -371,7 +389,9 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, for (no = 0; no < max && is_term_ok(lookahead->kind, term_list); no++) { for (i = 0; ilen; i++) - if (truncation_value == -1 && lookahead->name[i] == '?') + if (lookahead->name[i] == ' ') + no_spaces++; + else if (strchr(truncation_aliases, lookahead->name[i])) { if (no == 0 && i == 0 && lookahead->len >= 1) left_trunc = 1; @@ -459,7 +479,7 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, qual_val_type (qa, CCL_BIB1_STR, CCL_BIB1_STR_WP, &attset)) { /* no structure attribute met. Apply either structure attribute WORD or PHRASE depending on number of CCL tokens */ - if (no == 1) + if (no == 1 && no_spaces == 0) add_attr (p, attset, CCL_BIB1_STR, 2); else add_attr (p, attset, CCL_BIB1_STR, 1); @@ -533,6 +553,8 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp, &attset)) add_attr (p, attset, CCL_BIB1_TRU, 100); } + if (!multi) + break; } if (!p_top) cclp->error_code = CCL_ERR_TERM_EXPECTED; @@ -543,7 +565,7 @@ static struct ccl_rpn_node *search_term (CCL_parser cclp, struct ccl_rpn_attr **qa) { static int list[] = {CCL_TOK_TERM, CCL_TOK_COMMA, -1}; - return search_term_x(cclp, qa, list); + return search_term_x(cclp, qa, list, 0); } /* @@ -655,8 +677,8 @@ static struct ccl_rpn_node *qualifiers (CCL_parser cclp, struct ccl_token *la, ADVANCE; /* skip relation */ if (KIND == CCL_TOK_TERM && - cclp->look_token->next->len == 1 && - cclp->look_token->next->name[0] == '-') + cclp->look_token->next && cclp->look_token->next->len == 1 && + cclp->look_token->next->name[0] == '-') { struct ccl_rpn_node *p1; if (!(p1 = search_term (cclp, ap))) @@ -664,7 +686,7 @@ static struct ccl_rpn_node *qualifiers (CCL_parser cclp, struct ccl_token *la, free (ap); return NULL; } - ADVANCE; /* skip '-' */ + ADVANCE; /* skip '-' */ if (KIND == CCL_TOK_TERM) /* = term - term ? */ { struct ccl_rpn_node *p2; @@ -751,7 +773,7 @@ static struct ccl_rpn_node *search_terms (CCL_parser cclp, static int list[] = { CCL_TOK_TERM, CCL_TOK_COMMA,CCL_TOK_EQ, CCL_TOK_REL, -1}; struct ccl_rpn_node *p1, *p2, *pn; - p1 = search_term_x (cclp, qa, list); + p1 = search_term_x (cclp, qa, list, 1); if (!p1) return NULL; while (1) @@ -759,7 +781,7 @@ static struct ccl_rpn_node *search_terms (CCL_parser cclp, if (KIND == CCL_TOK_PROX) { ADVANCE; - p2 = search_term_x (cclp, qa, list); + p2 = search_term_x (cclp, qa, list, 1); if (!p2) { ccl_rpn_delete (p1); @@ -772,7 +794,7 @@ static struct ccl_rpn_node *search_terms (CCL_parser cclp, } else if (is_term_ok(KIND, list)) { - p2 = search_term_x (cclp, qa, list); + p2 = search_term_x (cclp, qa, list, 1); if (!p2) { ccl_rpn_delete (p1);