cql2ccl: fix handling of \\
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 29 Aug 2011 10:33:30 +0000 (12:33 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 29 Aug 2011 10:33:30 +0000 (12:33 +0200)
src/cql2ccl.c
test/test_cql2ccl.c

index 54b16e7..99c90c4 100644 (file)
@@ -4,7 +4,7 @@
  */
 /**
  * \file cql2ccl.c
- * \brief Implements CQL to XCQL conversion.
+ * \brief Implements CQL to CCL conversion.
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -45,13 +45,10 @@ static void pr_term(struct cql_node *cn,
                     }
                     cp++;
                     if (*cp == '\"' || *cp == '\\')
-                        pr("\\\"", client_data);
-                    else
-                    {
-                        x[0] = *cp;
-                        x[1] = '\0';
-                        pr(x, client_data);
-                    }
+                        pr("\\", client_data);
+                    x[0] = *cp;
+                    x[1] = '\0';
+                    pr(x, client_data);
                 }
                 else if (*cp == '*')
                 {
@@ -214,7 +211,7 @@ static int bool(struct cql_node *cn,
                     if (!strcmp(n->u.st.relation, "<="))
                         distance = atoi(n->u.st.term);
                     else if (!strcmp(n->u.st.relation, "<"))
-                        distance = atoi(n->u.st.term) - 1;
+                            distance = atoi(n->u.st.term) - 1;
                     else
                         return -1;
                 }
index cd1547b..6426d87 100644 (file)
@@ -77,8 +77,9 @@ static void tst(void)
     YAZ_CHECK(tst_query("a b", "\"a\" \"b\""));
     YAZ_CHECK(tst_query("ab bc", "\"ab\" \"bc\""));
 
-    YAZ_CHECK(tst_query("\\\\", "\"\\\"\""));
-    YAZ_CHECK(tst_query("\\\"",   "\"\\\"\""));
+    YAZ_CHECK(tst_query("\\\\", "\"\\\\\""));
+    YAZ_CHECK(tst_query("\\\"", "\"\\\"\""));
+    YAZ_CHECK(tst_query("\\x" , "\"x\""));
 
     YAZ_CHECK(tst_query("\\*", "\"*\""));
     YAZ_CHECK(tst_query("\"\\*\"", "\"*\""));