X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fcql2ccl.c;h=331b6dbfc14e23bba0664bed14681e595d118023;hb=b9e057ce1b31f4cef4364de7c36b5c119cc94cc3;hp=58b5804c407d989afc936706862ce325e73fd104;hpb=871f1239cc0c8a2d4b2bd16a918a39c97633faa8;p=yaz-moved-to-github.git diff --git a/src/cql2ccl.c b/src/cql2ccl.c index 58b5804..331b6db 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) 1995-2013 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) @@ -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) { @@ -91,6 +91,7 @@ static int node(struct cql_node *cn, const char *split_op = 0; const char *ccl_rel = 0; const char *rel = cn->u.st.relation; + const char *cp; if (cn->u.st.index && strcmp(cn->u.st.index, "cql.serverChoice")) @@ -121,45 +122,33 @@ static int node(struct cql_node *cn, /* unsupported relation */ return -1; } - for (; cn; cn = cn->u.st.extra_terms) + cp = cn->u.st.term; + while (1) { - const char *cp = cn->u.st.term; - while (1) + if (ccl_field && ccl_rel) { - if (ccl_field && ccl_rel) - { - 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); - while (*cp == ' ') - cp++; - if (*cp == '\0') - break; - pr(" ", client_data); - if (split_op) - { - pr(split_op, client_data); - pr(" ", client_data); - } + pr(ccl_field, client_data); + pr(ccl_rel, client_data); + if (!split_op) + ccl_rel = 0; } - if (cn->u.st.extra_terms) + pr_term(&cp, split_op ? 1 : 0, pr, client_data); + while (*cp == ' ') + cp++; + if (*cp == '\0') + break; + pr(" ", client_data); + if (split_op) { + pr(split_op, client_data); pr(" ", client_data); - if (split_op) - { - pr(split_op, client_data); - pr(" ", client_data); - } } } return 0; } -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) { @@ -170,7 +159,7 @@ 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); if (strcmp(value, "prox")) @@ -227,7 +216,7 @@ static int bool(struct cql_node *cn, 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) { @@ -246,7 +235,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) {