From: Adam Dickmeiss Date: Wed, 3 Oct 2001 23:54:41 +0000 (+0000) Subject: Fixes for numeric ranges (date=1980-1990). X-Git-Tag: YAZ.1.8~36 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=bd6a2e5050dfc5ea460202106fe396c584c31838;p=yaz-moved-to-github.git Fixes for numeric ranges (date=1980-1990). --- diff --git a/ccl/cclfind.c b/ccl/cclfind.c index 59a9065..324cd58 100644 --- a/ccl/cclfind.c +++ b/ccl/cclfind.c @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: cclfind.c,v $ - * Revision 1.24 2001-03-22 21:23:30 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 @@ -328,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; @@ -375,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 @@ -548,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; @@ -558,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); } /* @@ -670,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))) @@ -679,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; @@ -766,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) @@ -774,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); @@ -787,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); diff --git a/ccl/cclsh.c b/ccl/cclsh.c index e0ed1fb..080bc85 100644 --- a/ccl/cclsh.c +++ b/ccl/cclsh.c @@ -45,7 +45,10 @@ * Europagate 1995 * * $Log: cclsh.c,v $ - * Revision 1.9 2001-05-16 07:30:16 adam + * Revision 1.10 2001-10-03 23:54:41 adam + * Fixes for numeric ranges (date=1980-1990). + * + * Revision 1.9 2001/05/16 07:30:16 adam * Minor cosmetic changes that makes checker gcc happier. * * Revision 1.8 2001/03/18 20:45:39 ja7 @@ -210,7 +213,19 @@ int main (int argc, char **argv) for (i = 0; i<1; i++) { - rpn = ccl_find_str (bibset, buf, &error, &pos); + CCL_parser cclp = ccl_parser_create (); + struct ccl_token *list; + struct ccl_rpn_node *p; + + cclp->bibset = bibset; + + list = ccl_parser_tokenize (cclp, buf); + rpn = ccl_parser_find (cclp, list); + + error = cclp->error_code; + if (error) + pos = cclp->error_pos - buf; + if (error) { printf ("%*s^ - ", 6+pos, " "); @@ -224,6 +239,14 @@ int main (int argc, char **argv) printf ("\n"); } } + if (debug) + { + struct ccl_token *lp; + for (lp = list; lp; lp = lp->next) + printf ("%d %.*s\n", lp->kind, lp->len, lp->name); + } + ccl_token_del (list); + ccl_parser_destroy (cclp); if (rpn) ccl_rpn_delete(rpn); } diff --git a/ccl/ccltoken.c b/ccl/ccltoken.c index b0e1b81..c89b155 100644 --- a/ccl/ccltoken.c +++ b/ccl/ccltoken.c @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: ccltoken.c,v $ - * Revision 1.16 2001-03-07 13:24:40 adam + * Revision 1.17 2001-10-03 23:54:41 adam + * Fixes for numeric ranges (date=1980-1990). + * + * Revision 1.16 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. * @@ -317,10 +320,13 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) cp++; break; default: - while (*cp && !strchr ("(),%!><=- \t\n\r", *cp)) + if (!strchr ("(),%!><=- \t\n\r", cp[-1])) { - cp++; - ++ last->len; + while (*cp && !strchr ("(),%!><=- \t\n\r", *cp)) + { + cp++; + ++ last->len; + } } last->kind = CCL_TOK_TERM;