Fix crash in record conv rule select YAZ-812
[yaz-moved-to-github.git] / src / querytowrbuf.c
index f36844d..79a9b6e 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2013 Index Data
+ * Copyright (C) Index Data
  * See the file LICENSE for details.
  */
 /** \file querytowrbuf.c
@@ -107,13 +107,16 @@ static const char *complex_op_name(const Z_Operator *op)
     }
 }
 
-static void yaz_apt_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt)
+static void yaz_attributes_to_wrbuf(WRBUF w, const Z_AttributeList *al)
 {
-    int num_attributes = zapt->attributes->num_attributes;
     int i;
-    for (i = 0; i < num_attributes; i++)
-        yaz_attribute_element_to_wrbuf(b,zapt->attributes->attributes[i]);
+    for (i = 0; i < al->num_attributes; i++)
+        yaz_attribute_element_to_wrbuf(w, al->attributes[i]);
+}
 
+static void yaz_apt_to_wrbuf(WRBUF b, const Z_AttributesPlusTerm *zapt)
+{
+    yaz_attributes_to_wrbuf(b, zapt->attributes);
     switch (zapt->term->which)
     {
     case Z_Term_general:
@@ -266,6 +269,19 @@ void wrbuf_diags(WRBUF b, int num_diagnostics, Z_DiagRec **diags)
     }
 }
 
+void yaz_facet_list_to_wrbuf(WRBUF w, const Z_FacetList *fl)
+{
+    int i;
+    for (i = 0; i < fl->num; i++)
+    {
+        Z_FacetField *ff = fl->elements[i];
+
+        if (i)
+            wrbuf_puts(w, ", ");
+        yaz_attributes_to_wrbuf(w, ff->attributes);
+    }
+}
+
 /*
  * Local variables:
  * c-basic-offset: 4