The static function bool(), which is part of cql_to_ccl_r(), now makes
authorMike Taylor <mike@indexdata.com>
Tue, 5 Jul 2011 22:42:31 +0000 (23:42 +0100)
committerMike Taylor <mike@indexdata.com>
Tue, 5 Jul 2011 22:42:31 +0000 (23:42 +0100)
some attempt to recognise and deal with proximity.  Right now, all it
does it recognise the CQL operator name "prox" and map it to the CCL
operator "!" rather than the unrecognised plain word "prox" -- this
suffices to get SOME indication of proximity into the resulting CCL,
which is a big step forward for bug #4407.  We ought to check for a an
/ordered=0 relation modifier and emit "%" instead in that case.

src/cql2ccl.c

index f427e7c..4a3932e 100644 (file)
@@ -133,15 +133,19 @@ static int bool(struct cql_node *cn,
                 void (*pr)(const char *buf, void *client_data),
                 void *client_data)
 {
+    char *value = cn->u.boolean.value;
     int r;
 
+    /* Rather lame initial attempt at interpreting proximity */
+    if (!strcmp(value, "prox")) value = "!";
+
     pr("(", client_data);
     r = cql_to_ccl_r(cn->u.boolean.left, pr, client_data);
     if (r)
         return r;
     
     pr(" ", client_data);
-    pr(cn->u.boolean.value, client_data);
+    pr(value, client_data);
     pr(" ", client_data);
 
     r = cql_to_ccl_r(cn->u.boolean.right, pr, client_data);