X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcql2ccl.c;h=0705ed5c77922f8de26712bdc445636db3aef114;hp=f427e7c310994d6bce2c8e8557cea9eebb015780;hb=a01e8d12dab3fbde9c494338f15f8177e04e98a1;hpb=1a2bd22f51e34404b8bc130a3314ad8e99e2e2d7 diff --git a/src/cql2ccl.c b/src/cql2ccl.c index f427e7c..0705ed5 100644 --- a/src/cql2ccl.c +++ b/src/cql2ccl.c @@ -133,6 +133,7 @@ static int bool(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data) { + char *value = cn->u.boolean.value; int r; pr("(", client_data); @@ -141,7 +142,54 @@ static int bool(struct cql_node *cn, return r; pr(" ", client_data); - pr(cn->u.boolean.value, client_data); + + if (strcmp(value, "prox")) + { /* not proximity. assuming boolean */ + pr(value, client_data); + } + else + { + struct cql_node *n = cn->u.boolean.modifiers; + int ordered = 0; + int distance = 1; + for (; n ; n = n->u.st.modifiers) + if (n->which == CQL_NODE_ST) + { + if (!strcmp(n->u.st.index, "unit")) + { + if (!strcmp(n->u.st.term, "word")) + ; + else + return -1; + } + else if (!strcmp(n->u.st.index, "distance")) + { + if (!strcmp(n->u.st.relation, "<=")) + distance = atoi(n->u.st.term); + else if (!strcmp(n->u.st.relation, "<")) + distance = atoi(n->u.st.term) - 1; + else + return -1; + } + else if (!strcmp(n->u.st.index, "unordered")) + { + ordered = 0; + } + else if (!strcmp(n->u.st.index, "ordered")) + { + ordered = 1; + } + else + return -1; + } + pr(ordered ? "!" : "%", client_data); + if (distance != 1) + { + char x[40]; + sprintf(x, "%d", distance); + pr(x, client_data); + } + } pr(" ", client_data); r = cql_to_ccl_r(cn->u.boolean.right, pr, client_data);