return p;
}
+static struct ccl_rpn_node *ccl_rpn_node_mkbool(struct ccl_rpn_node *l,
+ struct ccl_rpn_node *r,
+ enum ccl_rpn_kind op)
+{
+ if (l && r)
+ {
+ struct ccl_rpn_node *tmp = ccl_rpn_node_create(op);
+ tmp->u.p[0] = l;
+ tmp->u.p[1] = r;
+ tmp->u.p[2] = 0;
+ return tmp;
+ }
+ else if (r)
+ return r;
+ return l;
+}
+
static struct ccl_rpn_node *ccl_rpn_dup(struct ccl_rpn_node *rpn)
{
struct ccl_rpn_node *n;
ccl_rpn_delete(p);
return 0;
}
- if (!p)
- p = tmp2;
- else
- {
- struct ccl_rpn_node *tmp1;
- tmp1 = ccl_rpn_node_create(CCL_RPN_OR);
- tmp1->u.p[0] = p;
- tmp1->u.p[1] = tmp2;
- p = tmp1;
- }
+ p = ccl_rpn_node_mkbool(p, tmp2, CCL_RPN_OR);
}
}
if (!p)
p1 = split_recur(cclp, qa, p2, ar + l, sz - l);
else
p1 = p2;
- if (p_top)
- {
- struct ccl_rpn_node *tmp = ccl_rpn_node_create(CCL_RPN_OR);
- tmp->u.p[0] = p_top;
- tmp->u.p[1] = p1;
- p_top = tmp;
- }
- else
- p_top = p1;
+ p_top = ccl_rpn_node_mkbool(p_top, p1, CCL_RPN_OR);
}
assert(p_top);
return p_top;
ADVANCE;
if (!p)
return 0;
- /* make the top node point to us.. */
- if (p_top)
- {
- struct ccl_rpn_node *tmp;
-
- if (or_list)
- tmp = ccl_rpn_node_create(CCL_RPN_OR);
- else if (and_list)
- tmp = ccl_rpn_node_create(CCL_RPN_AND);
- else
- tmp = ccl_rpn_node_create(CCL_RPN_AND);
- tmp->u.p[0] = p_top;
- tmp->u.p[1] = p;
-
- p_top = tmp;
- }
- else
- p_top = p;
-
+ p_top = ccl_rpn_node_mkbool(p_top, p, or_list ? CCL_RPN_OR : CCL_RPN_AND);
if (!multi)
break;
}
xfree(ap);
return 0;
}
- if (node)
- {
- struct ccl_rpn_node *node_this =
- ccl_rpn_node_create(CCL_RPN_OR);
- node_this->u.p[0] = node;
- node_this->u.p[1] = node_sub;
- node = node_this;
- }
- else
- node = node_sub;
+ node = ccl_rpn_node_mkbool(node, node_sub, CCL_RPN_OR);
seq++;
}
if (seq == 0)
ccl_rpn_delete(node);
break;
}
- if (node)
- {
- struct ccl_rpn_node *node_this =
- ccl_rpn_node_create(CCL_RPN_OR);
- node_this->u.p[0] = node;
- node_this->u.p[1] = node_sub;
- node = node_this;
- }
- else
- node = node_sub;
+ node = ccl_rpn_node_mkbool(node, node_sub, CCL_RPN_OR);
seq++;
}
}
ccl_rpn_delete(node);
return 0;
}
- if (node)
- {
- struct ccl_rpn_node *node_this =
- ccl_rpn_node_create(CCL_RPN_OR);
- node_this->u.p[0] = node;
- node_this->u.p[1] = node_sub;
- node_this->u.p[2] = 0;
- node = node_this;
- }
- else
- node = node_sub;
+ node = ccl_rpn_node_mkbool(node, node_sub, CCL_RPN_OR);
}
if (!node)
node = search_terms(cclp, 0);
*/
static struct ccl_rpn_node *find_spec(CCL_parser cclp, ccl_qualifier_t *qa)
{
- struct ccl_rpn_node *p1, *p2, *pn;
+ struct ccl_rpn_node *p1, *p2;
if (!(p1 = search_elements(cclp, qa)))
return NULL;
while (1)
ccl_rpn_delete(p1);
return NULL;
}
- pn = ccl_rpn_node_create(CCL_RPN_AND);
- pn->u.p[0] = p1;
- pn->u.p[1] = p2;
- pn->u.p[2] = 0;
- p1 = pn;
+ p1 = ccl_rpn_node_mkbool(p1, p2, CCL_RPN_AND);
continue;
case CCL_TOK_OR:
ADVANCE;
ccl_rpn_delete(p1);
return NULL;
}
- pn = ccl_rpn_node_create(CCL_RPN_OR);
- pn->u.p[0] = p1;
- pn->u.p[1] = p2;
- pn->u.p[2] = 0;
- p1 = pn;
+ p1 = ccl_rpn_node_mkbool(p1, p2, CCL_RPN_OR);
continue;
case CCL_TOK_NOT:
ADVANCE;
ccl_rpn_delete(p1);
return NULL;
}
- pn = ccl_rpn_node_create(CCL_RPN_NOT);
- pn->u.p[0] = p1;
- pn->u.p[1] = p2;
- pn->u.p[2] = 0;
- p1 = pn;
+ p1 = ccl_rpn_node_mkbool(p1, p2, CCL_RPN_NOT);
continue;
}
break;