- const char *cp_value_start;
- const char *cp_value_end;
- const char *cp_pattern_end;
- const char *cp = line;
- while (*cp && !strchr(" \t=\r\n#", *cp))
- cp++;
- cp_pattern_end = cp;
- if (cp == line)
- continue;
- while (*cp && strchr(" \t\r\n", *cp))
- cp++;
- if (*cp != '=')
- continue;
- cp++;
- while (*cp && strchr(" \t\r\n", *cp))
- cp++;
- cp_value_start = cp;
- if (!(cp_value_end = strchr(cp, '#')))
- cp_value_end = strlen(line) + line;
-
- if (cp_value_end != cp_value_start &&
- strchr(" \t\r\n", cp_value_end[-1]))
- cp_value_end--;
- *pp = (struct cql_prop_entry *) xmalloc (sizeof(**pp));
- (*pp)->pattern = (char *) xmalloc (cp_pattern_end - line + 1);
- memcpy ((*pp)->pattern, line, cp_pattern_end - line);
- (*pp)->pattern[cp_pattern_end-line] = 0;
-
- (*pp)->value = (char *) xmalloc (cp_value_end - cp_value_start + 1);
- if (cp_value_start != cp_value_end)
- memcpy ((*pp)->value, cp_value_start, cp_value_end-cp_value_start);
- (*pp)->value[cp_value_end - cp_value_start] = 0;
- pp = &(*pp)->next;
+ yaz_tok_parse_t tp = yaz_tok_parse_buf(ct->tok_cfg, line);
+ int t;
+ wrbuf_rewind(ct->w);
+ t = yaz_tok_move(tp);
+ if (t == YAZ_TOK_STRING)
+ {
+ char * pattern = xstrdup(yaz_tok_parse_string(tp));
+ t = yaz_tok_move(tp);
+ if (t != '=')
+ {
+ yaz_tok_parse_destroy(tp);
+ cql_transform_close(ct);
+ return 0;
+ }
+ t = yaz_tok_move(tp);
+
+ while (t == YAZ_TOK_STRING)
+ {
+ /* attset type=value OR type=value */
+ wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
+ t = yaz_tok_move(tp);
+ if (t == YAZ_TOK_EOF)
+ break;
+ if (t == YAZ_TOK_STRING)
+ {
+ wrbuf_puts(ct->w, " ");
+ wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
+ t = yaz_tok_move(tp);
+ }
+ if (t != '=')
+ {
+ yaz_tok_parse_destroy(tp);
+ cql_transform_close(ct);
+ return 0;
+ }
+ t = yaz_tok_move(tp);
+ if (t != YAZ_TOK_STRING) /* value */
+ {
+ yaz_tok_parse_destroy(tp);
+ cql_transform_close(ct);
+ return 0;
+ }
+ wrbuf_puts(ct->w, "=");
+ wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
+ t = yaz_tok_move(tp);
+ wrbuf_puts(ct->w, " ");
+ }
+ *pp = (struct cql_prop_entry *) xmalloc(sizeof(**pp));
+ (*pp)->pattern = pattern;
+ (*pp)->value = xstrdup(wrbuf_cstr(ct->w));
+ pp = &(*pp)->next;
+ }
+ else if (t != YAZ_TOK_EOF)
+ {
+ yaz_tok_parse_destroy(tp);
+ cql_transform_close(ct);
+ return 0;
+ }
+ yaz_tok_parse_destroy(tp);