-#define FACET_DElIMITER ','
-
-static int scan_facet_argument(const char *arg) {
- int index;
- int length = strlen(arg);
- int count = 1;
- for (index = 0; index < length; index++) {
- if (arg[index] == FACET_DElIMITER)
- count++;
- }
- return count;
-}
-
-/**
- * yax_pdg_parse_facet_list: Parses a comma-separated list of AttributeList(s) into a FacetList.
- * It does not handle the optional facet term(s).
- *
- */
-Z_FacetList *yaz_pqf_parse_facet_list(ODR odr, const char *facet) {
- Z_FacetList *facet_list = 0;
- Z_FacetField **elements;
- int index = 0;
- int num_elements = scan_facet_argument(facet);
- if (num_elements == 0)
- return facet_list;
- facet_list = odr_malloc(odr, sizeof(*facet_list));
- facet_list->num = num_elements;
- elements = odr_malloc(odr, num_elements * sizeof(*elements));
- facet_list->elements = elements;
- for (index = 0; index < num_elements;) {
- const char *pos = strchr(facet, FACET_DElIMITER);
- if (pos == 0)
- pos = facet + strlen(facet);
- elements[index] = parse_facet(odr, (const char *) facet, (pos - facet));
- if (elements[index]) {
- index++;
- }
- else {
- num_elements--;
- facet_list->num = num_elements;
+Z_FacetList *yaz_pqf_parse_facet_list(ODR o, const char *qbuf)
+{
+ char **darray;
+ int num;
+
+ nmem_strsplit(odr_getmem(o), ",", qbuf, &darray, &num);
+ if (num > 0)
+ {
+ int i;
+ Z_FacetList *fl = (Z_FacetList*) odr_malloc(o, sizeof(*fl));
+ fl->num = num;
+ fl->elements = (Z_FacetField **)
+ odr_malloc(o, num * sizeof(*fl->elements));
+ for (i = 0; i < num; i++)
+ {
+ fl->elements[i] = parse_facet(o, darray[i]);
+ if (!fl->elements[i])
+ return 0;