X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fcql2ccl.c;h=f427e7c310994d6bce2c8e8557cea9eebb015780;hp=90ee5d647637ebb64e93850b1a4ec9eb6ea22403;hb=1a2bd22f51e34404b8bc130a3314ad8e99e2e2d7;hpb=02d2f2409c58ab49ab535758d85d70fae0f651f4 diff --git a/src/cql2ccl.c b/src/cql2ccl.c index 90ee5d6..f427e7c 100644 --- a/src/cql2ccl.c +++ b/src/cql2ccl.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. */ /** - * \file xcqlutil.c + * \file cql2ccl.c * \brief Implements CQL to XCQL conversion. */ #if HAVE_CONFIG_H @@ -21,14 +21,24 @@ static int cql_to_ccl_r(struct cql_node *cn, void *client_data); static void pr_term(struct cql_node *cn, - void (*pr)(const char *buf, void *client_data), - void *client_data) + void (*pr)(const char *buf, void *client_data), + void *client_data) { while (cn) { - pr("\"", client_data); - pr(cn->u.st.term, client_data); - pr("\"", client_data); + const char *cp; + cp = cn->u.st.term; + while (*cp) + { + char x[2]; + if (*cp == '*') + x[0] = '?'; + else + x[0] = *cp; + x[1] = 0; + pr(x, client_data); + cp++; + } if (cn->u.st.extra_terms) pr(" ", client_data); cn = cn->u.st.extra_terms; @@ -98,7 +108,10 @@ static int node(struct cql_node *cn, while (*cp && *cp != ' ') { char x[2]; - x[0] = *cp; + if (*cp == '*') + x[0] = '?'; + else + x[0] = *cp; x[1] = '\0'; pr(x, client_data); cp++; @@ -111,7 +124,6 @@ static int node(struct cql_node *cn, pr(split_op, client_data); pr(" ", client_data); } - return -1; } return 0; } @@ -171,13 +183,16 @@ void cql_to_ccl_stdio(struct cql_node *cn, FILE *f) int cql_to_ccl_buf(struct cql_node *cn, char *out, int max) { struct cql_buf_write_info info; + int r; info.off = 0; info.max = max; info.buf = out; - cql_to_ccl(cn, cql_buf_write_handler, &info); + r = cql_to_ccl(cn, cql_buf_write_handler, &info); if (info.off >= 0) info.buf[info.off] = '\0'; - return info.off; + else + return -2; /* buffer overflow */ + return r; } /*