From: Adam Dickmeiss Date: Wed, 7 Mar 2001 13:24:40 +0000 (+0000) Subject: Member and_not in Z_Operator is kept for backwards compatibility. X-Git-Tag: YAZ.1.8~120 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=da907ba05501a2050d0a70b1d1fdf22a8130589a Member and_not in Z_Operator is kept for backwards compatibility. Added support for definition of CCL operators in field spec file. --- diff --git a/CHANGELOG b/CHANGELOG index bdcb67d..aff4ee6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,12 @@ Possible compatibility problems with earlier versions marked with '*'. +CCL operator names may be set in field definition files (CCL_bibset). +See ccl/bib1 for an example. + Fixes in ASN.1 compiler for C++ compatibility. -* Changed member names "and", "or" and "and_not" in struct Z_Operator -to "op_and", "op_or" and "op_and_not" to avoid conflict with C++. +* Renamed members "and" and "or" in struct Z_Operator to "op_and" +and "op_or" to avoid conflict with C++. Fixed problem with GNU readline detection on Redhat 7.0. diff --git a/ccl/bib1 b/ccl/bib1 index 26e7792..fea798a 100644 --- a/ccl/bib1 +++ b/ccl/bib1 @@ -1,4 +1,4 @@ -# $Id: bib1,v 1.5 2000-12-29 11:12:12 adam Exp $ +# $Id: bib1,v 1.6 2001-03-07 13:24:40 adam Exp $ # CCL qualifiers and their mappings # # Each line takes the form: @@ -29,8 +29,8 @@ # This rule is for CCL tokens where no fields are specified term s=pw t=l,r s=al # Common short-hand access points. -au u=1 s=pw t=l,r -ti u=4 s=pw t=l,r +au u=1 s=pw t=l,r # author +ti u=4 s=pw t=l,r # title isbn u=7 issn u=8 cc u=20 @@ -97,3 +97,9 @@ com:cf c=3 exp:category exp1,1=1 +# These special directives defines names of keywords for parser +@and og * # either 'or' or * +@or eller + # either 'eller' or + +@not ikke - # and so on.. +@set s set +@case 0 # case insenstive (1 for case sensitive) diff --git a/ccl/cclfind.c b/ccl/cclfind.c index ec5e650..3a9fd83 100644 --- a/ccl/cclfind.c +++ b/ccl/cclfind.c @@ -45,7 +45,11 @@ * Europagate, 1995 * * $Log: cclfind.c,v $ - * Revision 1.21 2001-02-21 13:46:53 adam + * 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. + * + * Revision 1.21 2001/02/21 13:46:53 adam * C++ fixes. * * Revision 1.20 2000/11/16 13:03:12 adam @@ -905,6 +909,8 @@ struct ccl_rpn_node *ccl_parser_find (CCL_parser cclp, struct ccl_token *list) { struct ccl_rpn_node *p; + + cclp->look_token = list; p = find_spec (cclp, NULL); if (p && KIND != CCL_TOK_EOL) diff --git a/ccl/cclqfile.c b/ccl/cclqfile.c index fa93894..76fb21f 100644 --- a/ccl/cclqfile.c +++ b/ccl/cclqfile.c @@ -45,7 +45,11 @@ * Europagate, 1995 * * $Log: cclqfile.c,v $ - * Revision 1.8 2001-02-21 13:46:53 adam + * Revision 1.9 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. + * + * Revision 1.8 2001/02/21 13:46:53 adam * C++ fixes. * * Revision 1.7 2001/01/24 11:55:31 adam @@ -91,7 +95,7 @@ #include -void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) +void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name) { char qual_spec[128]; int no_scan; @@ -191,6 +195,14 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) ccl_qual_add_set (bibset, qual_name, pair_no, pair, attsets); } +void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) +{ + if (*qual_name == '@') + ccl_qual_add_special(bibset, qual_name+1, cp); + else + ccl_qual_field(bibset, cp, qual_name); +} + /* * ccl_qual_file: Read bibset definition from file. * bibset: Bibset @@ -207,7 +219,7 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) void ccl_qual_file (CCL_bibset bibset, FILE *inf) { char line[256]; - char *cp; + char *cp, *cp1; char qual_name[128]; int no_scan; @@ -219,6 +231,9 @@ void ccl_qual_file (CCL_bibset bibset, FILE *inf) if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1) continue; /* also ignore empty lines */ cp += no_scan; + cp1 = strchr(cp, '#'); + if (cp1) + *cp1 = '\0'; ccl_qual_fitem (bibset, cp, qual_name); } } diff --git a/ccl/cclqual.c b/ccl/cclqual.c index c19dede..8ccc643 100644 --- a/ccl/cclqual.c +++ b/ccl/cclqual.c @@ -45,7 +45,11 @@ * Europagate, 1995 * * $Log: cclqual.c,v $ - * Revision 1.14 2000-11-16 09:58:02 adam + * Revision 1.15 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. + * + * Revision 1.14 2000/11/16 09:58:02 adam * Implemented local AttributeSet setting for CCL field maps. * * Revision 1.13 2000/01/31 13:15:21 adam @@ -119,8 +123,46 @@ /* Definition of CCL_bibset pointer */ struct ccl_qualifiers { struct ccl_qualifier *list; + struct ccl_qualifier_special *special; +}; + + +/* CCL Qualifier special */ +struct ccl_qualifier_special { + char *name; + char *value; + struct ccl_qualifier_special *next; }; +void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v) +{ + struct ccl_qualifier_special *p; + const char *pe; + + for (p = bibset->special; p && strcmp(p->name, n); p = p->next) + ; + if (p) + free (p->value); + else + { + p = (struct ccl_qualifier_special *) malloc (sizeof(*p)); + p->name = ccl_strdup (n); + p->value = 0; + p->next = bibset->special; + bibset->special = p; + } + while (strchr(" \t", *v)) + ++v; + for (pe = v + strlen(v); pe != v; --pe) + if (!strchr(" \n\r\t", pe[-1])) + break; + p->value = (char*) malloc (pe - v + 1); + if (pe - v) + memcpy (p->value, v, pe - v); + p->value[pe - v] = '\0'; +} + + /* * ccl_qual_add: Add qualifier to Bibset. If qualifier already * exists, then attributes are appendend to old @@ -184,6 +226,7 @@ CCL_bibset ccl_qual_mk (void) CCL_bibset b = (CCL_bibset)malloc (sizeof(*b)); ccl_assert (b); b->list = NULL; + b->special = NULL; return b; } @@ -194,6 +237,7 @@ CCL_bibset ccl_qual_mk (void) void ccl_qual_rm (CCL_bibset *b) { struct ccl_qualifier *q, *q1; + struct ccl_qualifier_special *sp, *sp1; if (!*b) return; @@ -212,6 +256,13 @@ void ccl_qual_rm (CCL_bibset *b) free (q->name); free (q); } + for (sp = (*b)->special; sp; sp = sp1) + { + sp1 = sp->next; + free (sp->name); + free (sp->value); + free (sp); + } free (*b); *b = NULL; } @@ -248,3 +299,15 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, return NULL; } +const char *ccl_qual_search_special (CCL_bibset b, + const char *name) +{ + struct ccl_qualifier_special *q; + if (!b) + return 0; + for (q = b->special; q && strcmp(q->name, name); q = q->next) + ; + if (q) + return q->value; + return 0; +} diff --git a/ccl/ccltoken.c b/ccl/ccltoken.c index 1c45b55..b0e1b81 100644 --- a/ccl/ccltoken.c +++ b/ccl/ccltoken.c @@ -45,7 +45,11 @@ * Europagate, 1995 * * $Log: ccltoken.c,v $ - * Revision 1.15 2000-05-01 09:36:50 adam + * 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. + * + * Revision 1.15 2000/05/01 09:36:50 adam * Range operator only treated in ordered ranges so that minus (-) can be * used for, say, the and-not operator. * @@ -135,13 +139,19 @@ static int token_cmp (CCL_parser cclp, const char *kw, struct ccl_token *token) { const char *cp1 = kw; const char *cp2; + const char *aliases; + int case_sensitive = cclp->ccl_case_sensitive; + + aliases = ccl_qual_search_special(cclp->bibset, "case"); + if (aliases) + case_sensitive = atoi(aliases); if (!kw) return 0; while ((cp2 = strchr (cp1, ' '))) { if (token->len == (size_t) (cp2-cp1)) { - if (cclp->ccl_case_sensitive) + if (case_sensitive) { if (!memcmp (cp1, token->name, token->len)) return 1; @@ -154,7 +164,7 @@ static int token_cmp (CCL_parser cclp, const char *kw, struct ccl_token *token) } cp1 = cp2+1; } - if (cclp->ccl_case_sensitive) + if (case_sensitive) return token->len == strlen(cp1) && !memcmp (cp1, token->name, token->len); return token->len == strlen(cp1) && @@ -229,6 +239,7 @@ struct ccl_token *ccl_token_simple (const char *command) */ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) { + const char *aliases; const char *cp = command; struct ccl_token *first = NULL; struct ccl_token *last = NULL; @@ -311,16 +322,32 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command) cp++; ++ last->len; } - if (token_cmp (cclp, cclp->ccl_token_and, last)) + last->kind = CCL_TOK_TERM; + + aliases = ccl_qual_search_special(cclp->bibset, "and"); + if (!aliases) + aliases = cclp->ccl_token_and; + if (token_cmp (cclp, aliases, last)) last->kind = CCL_TOK_AND; - else if (token_cmp (cclp, cclp->ccl_token_or, last)) + + aliases = ccl_qual_search_special(cclp->bibset, "or"); + if (!aliases) + aliases = cclp->ccl_token_or; + if (token_cmp (cclp, aliases, last)) last->kind = CCL_TOK_OR; - else if (token_cmp (cclp, cclp->ccl_token_not, last)) + + aliases = ccl_qual_search_special(cclp->bibset, "not"); + if (!aliases) + aliases = cclp->ccl_token_not; + if (token_cmp (cclp, aliases, last)) last->kind = CCL_TOK_NOT; - else if (token_cmp (cclp, cclp->ccl_token_set, last)) + + aliases = ccl_qual_search_special(cclp->bibset, "set"); + if (!aliases) + aliases = cclp->ccl_token_set; + + if (token_cmp (cclp, aliases, last)) last->kind = CCL_TOK_SET; - else - last->kind = CCL_TOK_TERM; } } return first; @@ -352,7 +379,7 @@ void ccl_token_del (struct ccl_token *list) } } -static char *ccl_strdup (const char *str) +char *ccl_strdup (const char *str) { int len = strlen(str); char *p = (char*) malloc (len+1); @@ -393,23 +420,39 @@ void ccl_parser_destroy (CCL_parser p) void ccl_parser_set_op_and (CCL_parser p, const char *op) { if (p && op) + { + if (p->ccl_token_and) + free (p->ccl_token_and); p->ccl_token_and = ccl_strdup (op); + } } void ccl_parser_set_op_or (CCL_parser p, const char *op) { if (p && op) + { + if (p->ccl_token_or) + free (p->ccl_token_or); p->ccl_token_or = ccl_strdup (op); + } } void ccl_parser_set_op_not (CCL_parser p, const char *op) { if (p && op) + { + if (p->ccl_token_not) + free (p->ccl_token_not); p->ccl_token_not = ccl_strdup (op); + } } void ccl_parser_set_op_set (CCL_parser p, const char *op) { if (p && op) + { + if (p->ccl_token_set) + free (p->ccl_token_set); p->ccl_token_set = ccl_strdup (op); + } } void ccl_parser_set_case (CCL_parser p, int case_sensitivity_flag) diff --git a/include/yaz/ccl.h b/include/yaz/ccl.h index 1be91bd..2f984e8 100644 --- a/include/yaz/ccl.h +++ b/include/yaz/ccl.h @@ -46,7 +46,11 @@ * CCL - header file * * $Log: ccl.h,v $ - * Revision 1.8 2000-11-16 09:58:02 adam + * Revision 1.9 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. + * + * Revision 1.8 2000/11/16 09:58:02 adam * Implemented local AttributeSet setting for CCL field maps. * * Revision 1.7 2000/11/01 14:47:00 adam @@ -352,6 +356,10 @@ YAZ_EXPORT CCL_parser ccl_parser_create (void); /* Destroy CCL parser */ YAZ_EXPORT void ccl_parser_destroy (CCL_parser p); +YAZ_EXPORT char *ccl_strdup (const char *str); + +YAZ_EXPORT const char *ccl_qual_search_special (CCL_bibset b, + const char *name); #ifndef ccl_assert #define ccl_assert(x) ; diff --git a/z39.50/z.tcl b/z39.50/z.tcl index cdb08ca..275fdc8 100644 --- a/z39.50/z.tcl +++ b/z39.50/z.tcl @@ -1,5 +1,5 @@ # YC Sample Config File for Z39.50 -# $Id: z.tcl,v 1.4 2001-02-21 13:46:54 adam Exp $ +# $Id: z.tcl,v 1.5 2001-03-07 13:24:40 adam Exp $ # ---------------------------------------------------------- # Prefix Specifications # @@ -59,7 +59,7 @@ int z_ANY_type_0 (ODR o, void **p, int opt) set map($m,PDU) APDU set membermap($m,Operator,and) {Operator_and op_and} set membermap($m,Operator,or) {Operator_or op_or} -set membermap($m,Operator,and-not) {Operator_and_not op_and_not} +#set membermap($m,Operator,and-not) {Operator_and_not op_and_not} set map($m,AttributeElement_complex) ComplexAttribute set map($m,DeleteSetStatus) DeleteStatus set membermap($m,ProximityOperator,private) {ProximityOperator_private zprivate} diff --git a/zutil/pquery.c b/zutil/pquery.c index c7e2e84..92e45d4 100644 --- a/zutil/pquery.c +++ b/zutil/pquery.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: pquery.c,v $ - * Revision 1.5 2001-02-21 13:46:54 adam + * Revision 1.6 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. + * + * Revision 1.5 2001/02/21 13:46:54 adam * C++ fixes. * * Revision 1.4 1999/12/21 16:25:20 adam @@ -378,15 +382,15 @@ static Z_Complex *rpn_complex (struct lex_info *li, ODR o, oid_proto proto, { case 'a': zo->which = Z_Operator_and; - zo->u.op_and = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case 'o': zo->which = Z_Operator_or; - zo->u.op_or = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case 'n': zo->which = Z_Operator_and_not; - zo->u.op_and_not = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case 'p': zo->which = Z_Operator_prox; diff --git a/zutil/yaz-ccl.c b/zutil/yaz-ccl.c index d672503..f4033e1 100644 --- a/zutil/yaz-ccl.c +++ b/zutil/yaz-ccl.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-ccl.c,v $ - * Revision 1.11 2001-02-21 13:46:54 adam + * Revision 1.12 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. + * + * Revision 1.11 2001/02/21 13:46:54 adam * C++ fixes. * * Revision 1.10 2001/02/20 11:23:50 adam @@ -175,15 +179,15 @@ static Z_Complex *ccl_rpn_complex (ODR o, struct ccl_rpn_node *p) { case CCL_RPN_AND: zo->which = Z_Operator_and; - zo->u.op_and = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case CCL_RPN_OR: zo->which = Z_Operator_or; - zo->u.op_or = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case CCL_RPN_NOT: zo->which = Z_Operator_and_not; - zo->u.op_and_not = odr_nullval(); + zo->u.and_not = odr_nullval(); break; case CCL_RPN_PROX: zo->which = Z_Operator_prox;