+ p = mk_node (CCL_RPN_AND);
+ p->u.p[0] = p1;
+ add_attr (p1, attset, CCL_BIB1_REL, 4);
+ p->u.p[1] = p2;
+ add_attr (p2, attset, CCL_BIB1_REL, 2);
+ return p;
+ }
+ else /* = term - */
+ {
+ add_attr (p1, attset, CCL_BIB1_REL, 4);
+ return p1;
+ }
+ }
+ else if (cclp->look_token->len == 1 &&
+ cclp->look_token->name[0] == '-') /* = - term ? */
+ {
+ ADVANCE;
+ if (!(p = search_term (cclp, ap)))
+ return NULL;
+ add_attr (p, attset, CCL_BIB1_REL, 2);
+ return p;
+ }
+ else if (KIND == CCL_TOK_LP)
+ {
+ ADVANCE;
+ if (!(p = find_spec (cclp, ap)))
+ return NULL;
+ if (KIND != CCL_TOK_RP)
+ {
+ cclp->error_code = CCL_ERR_RP_EXPECTED;
+ ccl_rpn_delete (p);
+ return NULL;
+ }
+ ADVANCE;
+ return p;
+ }
+ else
+ {
+ if (!(p = search_terms (cclp, ap)))
+ return NULL;
+ add_attr (p, attset, CCL_BIB1_REL, rel);
+ return p;
+ }
+ cclp->error_code = CCL_ERR_TERM_EXPECTED;
+ }
+ return NULL;
+}
+
+/*
+ * qualifiers1: Parse CCL qualifiers and search terms.
+ * cclp: CCL Parser
+ * la: Token pointer to RELATION token.
+ * qa: Qualifier attributes already applied.
+ * return: pointer to node(s); NULL on error.
+ */
+static struct ccl_rpn_node *qualifiers1 (CCL_parser cclp, struct ccl_token *la,
+ struct ccl_rpn_attr **qa)
+{
+ struct ccl_token *lookahead = cclp->look_token;
+ struct ccl_token *look_start = cclp->look_token;
+ struct ccl_rpn_attr **ap;
+ struct ccl_rpn_node *node = 0;
+ const char *field_str;
+ int no = 0;
+ int seq = 0;
+ int i;
+ int mode_merge = 1;
+#if 0
+ if (qa)
+ {
+ cclp->error_code = CCL_ERR_DOUBLE_QUAL;
+ return NULL;
+ }
+#endif
+ for (lookahead = cclp->look_token; lookahead != la;
+ lookahead=lookahead->next)
+ no++;
+ if (qa)
+ for (i=0; qa[i]; i++)
+ no++;
+ ap = (struct ccl_rpn_attr **)xmalloc ((no ? (no+1) : 2) * sizeof(*ap));
+ ccl_assert (ap);
+
+ field_str = ccl_qual_search_special(cclp->bibset, "field");
+ if (field_str)
+ {
+ if (!strcmp (field_str, "or"))
+ mode_merge = 0;
+ else if (!strcmp (field_str, "merge"))
+ mode_merge = 1;
+ }
+ if (!mode_merge)
+ {
+ /* consider each field separately and OR */
+ lookahead = look_start;
+ while (lookahead != la)
+ {
+ ap[1] = 0;
+ seq = 0;
+ while ((ap[0] = ccl_qual_search (cclp, lookahead->name,
+ lookahead->len, seq)) != 0)
+ {
+ struct ccl_rpn_node *node_sub;
+ cclp->look_token = la;
+
+ node_sub = qualifiers2(cclp, ap);
+ if (!node_sub)