From 2bbab1599d7da506eca84f47ff4d70b2829a45b6 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 25 Aug 2011 13:56:20 +0200 Subject: [PATCH] cql2ccl: deal with both * and ? in conversion Also leave escaped ones as is, so that they are pass-through. --- src/cql2ccl.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) 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); -- 1.7.10.4