From: Adam Dickmeiss Date: Thu, 25 Aug 2011 11:56:20 +0000 (+0200) Subject: cql2ccl: deal with both * and ? in conversion X-Git-Tag: v4.2.11~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=2bbab1599d7da506eca84f47ff4d70b2829a45b6;p=yaz-moved-to-github.git cql2ccl: deal with both * and ? in conversion Also leave escaped ones as is, so that they are pass-through. --- diff --git a/src/cql2ccl.c b/src/cql2ccl.c index 0705ed5..df6e863 100644 --- a/src/cql2ccl.c +++ b/src/cql2ccl.c @@ -27,17 +27,35 @@ static void pr_term(struct cql_node *cn, while (cn) { const char *cp; - cp = cn->u.st.term; - while (*cp) + for (cp = cn->u.st.term; *cp; cp++) { - char x[2]; - if (*cp == '*') - x[0] = '?'; + char x[4]; + + if (*cp == '\\' && cp[1]) + { + x[0] = cp[0]; + x[1] = cp[1]; + x[2] = '\0'; + cp++; + } + else if (*cp == '#') + { + strcpy(x, "\\#"); + } + else if (*cp == '*') + { + strcpy(x, "?"); + } + else if (*cp == '?') + { + strcpy(x, "#"); + } else + { x[0] = *cp; - x[1] = 0; + x[1] = '\0'; + } pr(x, client_data); - cp++; } if (cn->u.st.extra_terms) pr(" ", client_data);