X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Frpn2cql.c;h=25ee13894976f56aea84e3ecf7425122e8d8d7ca;hp=d892986c62b4692a23300ec4f83eda49f1bf5c67;hb=266cfeafc17930bfa6fb7eed92f80b8c751f43b4;hpb=ea883a980a6b7c787a7f68d3e270d94630048666 diff --git a/src/rpn2cql.c b/src/rpn2cql.c index d892986..25ee138 100644 --- a/src/rpn2cql.c +++ b/src/rpn2cql.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) 1995-2012 Index Data * See the file LICENSE for details. */ /** @@ -69,27 +69,27 @@ static const char *lookup_relation_index_from_attr(Z_AttributeList *attributes) switch (*relation) { /* Unsure on whether this is the relation attribute constants? */ - case Z_ProximityOperator_Prox_lessThan: + case Z_ProximityOperator_Prox_lessThan: return "<"; - case Z_ProximityOperator_Prox_lessThanOrEqual: - return "<="; - case Z_ProximityOperator_Prox_equal: - return "="; - case Z_ProximityOperator_Prox_greaterThanOrEqual: - return ">="; - case Z_ProximityOperator_Prox_greaterThan: - return ">"; - case Z_ProximityOperator_Prox_notEqual: - return "<>"; - case 100: + case Z_ProximityOperator_Prox_lessThanOrEqual: + return "<="; + case Z_ProximityOperator_Prox_equal: + return "="; + case Z_ProximityOperator_Prox_greaterThanOrEqual: + return ">="; + case Z_ProximityOperator_Prox_greaterThan: + return ">"; + case Z_ProximityOperator_Prox_notEqual: + return "<>"; + case 100: /* phonetic is not supported in CQL */ - return 0; - case 101: + return 0; + case 101: /* stem is not supported in CQL */ - return 0; - case 102: + return 0; + case 102: /* relevance is supported in CQL, but not implemented yet */ - return 0; + return 0; default: /* Invalid relation */ return 0; @@ -117,7 +117,7 @@ static int rpn2cql_attr(cql_transform_t ct, index = lookup_index_from_string_attr(attributes); /* Attempt to fix bug #2978: Look for a relation attribute */ - if (!relation) + if (!relation) relation = lookup_relation_index_from_attr(attributes); if (!index) @@ -192,11 +192,13 @@ static int rpn2cql_simple(cql_transform_t ct, Z_Term *term = apt->term; const char *sterm = 0; size_t lterm = 0; + Odr_int trunc = lookup_truncation(apt->attributes); + size_t i; wrbuf_rewind(w); ret = rpn2cql_attr(ct, apt->attributes, w); - switch(term->which) + switch (term->which) { case Z_Term_general: lterm = term->u.general->len; @@ -210,35 +212,64 @@ static int rpn2cql_simple(cql_transform_t ct, lterm = strlen(sterm); break; default: - ret = -1; cql_transform_set_error(ct, YAZ_BIB1_TERM_TYPE_UNSUPP, 0); + return -1; } - if (term) + if (trunc <= 3 || trunc == 100 || trunc == 102 || trunc == 104) { - size_t i; - int must_quote = 0; - Odr_int trunc = lookup_truncation(apt->attributes); - - if (trunc > 3 && trunc != 100) - { - cql_transform_set_error( - ct, YAZ_BIB1_UNSUPP_TRUNCATION_ATTRIBUTE, 0); - ret = -1; - } + int quote_it = 0; for (i = 0 ; i < lterm; i++) - if (sterm[i] == ' ') - must_quote = 1; - if (must_quote) + if (strchr(" ()=>u.complex->roperator; + Z_ProximityOperator *prox; int r; if (nested) @@ -278,7 +310,7 @@ static int rpn2cql_structure(cql_transform_t ct, break; case Z_Operator_prox: { pr(" prox", client_data); - Z_ProximityOperator *prox = op->u.prox; + prox = op->u.prox; /* No way to express Odr_bool *exclusion -- ignore it */ if (prox->distance) { char buf[21]; /* Enough for any 64-bit int */