Decode SRU 2.0 responses
[yaz-moved-to-github.git] / src / cqltransform.c
index 117ca97..aea8bdc 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) 1995-2012 Index Data
  * See the file LICENSE for details.
  */
 /**
@@ -500,8 +500,7 @@ static int cql_pr_prox(cql_transform_t ct, struct cql_node *mods,
                        void *client_data)
 {
     int exclusion = 0;
-    int distance;               /* to be filled in later depending on unit */
-    int distance_defined = 0;
+    int distance = -1;
     int ordered = 0;
     int proxrel = 2;            /* less than or equal */
     int unit = 2;               /* word */
@@ -514,7 +513,6 @@ static int cql_pr_prox(cql_transform_t ct, struct cql_node *mods,
 
         if (!strcmp(name, "distance")) {
             distance = strtol(term, (char**) 0, 0);
-            distance_defined = 1;
             if (!strcmp(relation, "="))
                 proxrel = 3;
             else if (!strcmp(relation, ">"))
@@ -564,7 +562,7 @@ static int cql_pr_prox(cql_transform_t ct, struct cql_node *mods,
         mods = mods->u.st.modifiers;
     }
 
-    if (!distance_defined)
+    if (distance == -1)
         distance = (unit == 2) ? 1 : 0;
 
     cql_pr_int(exclusion, pr, client_data);
@@ -616,9 +614,17 @@ static void emit_term(cql_transform_t ct,
 {
     int i;
     const char *ns = cn->u.st.index_uri;
-    int process_term = !has_modifier(cn, "regexp");
     int z3958_mode = 0;
+    int process_term = 1;
 
+    if (has_modifier(cn, "regexp"))
+        process_term = 0;
+    else if (cql_lookup_property(ct, "truncation", 0, "cql"))
+    {
+        process_term = 0;
+        cql_pr_attr(ct, "truncation", "cql", 0,
+                    pr, client_data, YAZ_SRW_MASKING_CHAR_UNSUPP);
+    }
     assert(cn->which == CQL_NODE_ST);
 
     if (process_term && length > 0)