Improve display of MARC records with multi-byte subfield IDs YAZ-695
[yaz-moved-to-github.git] / src / rpn2cql.c
index c59ca90..cac867d 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2012 Index Data
+ * Copyright (C) 1995-2013 Index Data
  * See the file LICENSE for details.
  */
 /**
@@ -173,7 +173,7 @@ static Odr_int lookup_truncation(Z_AttributeList *attributes)
     }
     /* No truncation specified */
     return 0;
-};
+}
 
 static int rpn2cql_simple(cql_transform_t ct,
                           void (*pr)(const char *buf, void *client_data),
@@ -218,10 +218,17 @@ static int rpn2cql_simple(cql_transform_t ct,
 
         if (trunc <= 3 || trunc == 100 || trunc == 102 || trunc == 104)
         {
+            int quote_it = 0;
             for (i = 0 ; i < lterm; i++)
                 if (strchr(" ()=></", sterm[i]))
+                {
+                    quote_it = 1;
                     break;
-            wrbuf_puts(w, "\"");
+                }
+            if (lterm == 0)
+                quote_it = 1;
+            if (quote_it)
+                wrbuf_puts(w, "\"");
             if (trunc == 2 || trunc == 3)
                 wrbuf_puts(w, "*");
             for (i = 0; i < lterm; i++)
@@ -254,7 +261,8 @@ static int rpn2cql_simple(cql_transform_t ct,
             }
             if (trunc == 1 || trunc == 3)
                 wrbuf_puts(w, "*");
-            wrbuf_puts(w, "\"");
+            if (quote_it)
+                wrbuf_puts(w, "\"");
         }
         else
         {