cql2ccl: handle CQL \-sequences differently
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 29 Aug 2011 10:06:18 +0000 (12:06 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 29 Aug 2011 10:06:18 +0000 (12:06 +0200)
For most CQL \-sequences do not produce \-sequence in resulting
CCL term. Only \" and \\ are special

src/cql2ccl.c

index ab358f6..54b16e7 100644 (file)
@@ -38,11 +38,20 @@ static void pr_term(struct cql_node *cn,
                 
                 if (*cp == '\\' && cp[1])
                 {
-                    x[0] = cp[0];
-                    x[1] = cp[1];
-                    x[2] = '\0';
+                    if (!quote_mode)
+                    {
+                        pr("\"", client_data);
+                        quote_mode = 1;
+                    }
                     cp++;
-                    pr(x, client_data);
+                    if (*cp == '\"' || *cp == '\\')
+                        pr("\\\"", client_data);
+                    else
+                    {
+                        x[0] = *cp;
+                        x[1] = '\0';
+                        pr(x, client_data);
+                    }
                 }
                 else if (*cp == '*')
                 {