X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcql2ccl.c;h=d08536f20c17a3c13716f104b01b2ccc8bbf85f5;hp=d7d05cca04e8e57472a8911d4b8541e09150b0ca;hb=3c51b85ff62261acc19c6995a041569ec4ef6d63;hpb=454ce0647544a588751b4a0fe536253a84867362 diff --git a/src/cql2ccl.c b/src/cql2ccl.c index d7d05cc..d08536f 100644 --- a/src/cql2ccl.c +++ b/src/cql2ccl.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2011 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -16,7 +16,7 @@ #include -static int cql_to_ccl_r(struct cql_node *cn, +static int cql_to_ccl_r(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data); @@ -29,7 +29,7 @@ static void pr_term(const char **cpp, int stop_at_space, for (cp = *cpp; *cp; cp++) { char x[4]; - + if (*cp == '\\' && cp[1]) { if (!quote_mode) @@ -62,7 +62,7 @@ static void pr_term(const char **cpp, int stop_at_space, } pr("#", client_data); } - else if (*cp == ' ') + else if (*cp == ' ' && stop_at_space) break; else { @@ -83,7 +83,7 @@ static void pr_term(const char **cpp, int stop_at_space, *cpp = cp; } -static int node(struct cql_node *cn, +static int node(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data) { @@ -130,17 +130,20 @@ static int node(struct cql_node *cn, { pr(ccl_field, client_data); pr(ccl_rel, client_data); + if (!split_op) + ccl_rel = 0; } pr_term(&cp, split_op ? 1 : 0, pr, client_data); - if (!split_op) - break; while (*cp == ' ') cp++; if (*cp == '\0') break; pr(" ", client_data); - pr(split_op, client_data); - pr(" ", client_data); + if (split_op) + { + pr(split_op, client_data); + pr(" ", client_data); + } } if (cn->u.st.extra_terms) { @@ -156,7 +159,7 @@ static int node(struct cql_node *cn, } -static int bool(struct cql_node *cn, +static int bool(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data) { @@ -167,8 +170,8 @@ static int bool(struct cql_node *cn, r = cql_to_ccl_r(cn->u.boolean.left, pr, client_data); if (r) return r; - - pr(" ", client_data); + + pr(") ", client_data); if (strcmp(value, "prox")) { /* not proximity. assuming boolean */ @@ -217,14 +220,14 @@ static int bool(struct cql_node *cn, pr(x, client_data); } } - pr(" ", client_data); + pr(" (", client_data); r = cql_to_ccl_r(cn->u.boolean.right, pr, client_data); pr(")", client_data); return r; } -static int cql_to_ccl_r(struct cql_node *cn, +static int cql_to_ccl_r(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data) { @@ -243,7 +246,7 @@ static int cql_to_ccl_r(struct cql_node *cn, return -1; } -int cql_to_ccl(struct cql_node *cn, +int cql_to_ccl(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data) {