-struct xpath_predicate *get_xpath_predicate(char *predicates, NMEM mem) {
- char *p1;
- char *p2;
- char *p3;
- char *p4;
-
- struct xpath_predicate *r1;
- struct xpath_predicate *r2;
- struct xpath_predicate *res = 0;
-
- char *pr = predicates;
-
- if ((p1 = get_xp_part(&pr, mem))) {
- if ((p2 = get_xp_part(&pr, mem))) {
- if (!strcmp (p2, "and") || !strcmp (p2, "or") || !strcmp (p2, "not")) {
- r1=nmem_malloc(mem, sizeof(struct xpath_predicate));
- r1->which = XPATH_PREDICATE_RELATION;
- r1->u.relation.name = p1;
- r1->u.relation.op = "";
- r1->u.relation.value = "";
-
- r2 = get_xpath_predicate (pr, mem);
-
- res = nmem_malloc(mem, sizeof(struct xpath_predicate));
- res->which = XPATH_PREDICATE_BOOLEAN;
- res->u.boolean.op = p2;
- res->u.boolean.left = r1;
- res->u.boolean.right = r2;
-
- return (res);
- }
-
- if (strchr("><=] ", *p2)) {
- r1 = nmem_malloc(mem, sizeof(struct xpath_predicate));
-
- r1->which = XPATH_PREDICATE_RELATION;
- r1->u.relation.name = p1;
- r1->u.relation.op = p2;
-
- if ((p3 = get_xp_part(&pr, mem))) {
- r1->u.relation.value = p3;
- } else {
- /* error */
- }
- }
-
- if ((p4 = get_xp_part(&pr, mem))) {
- if (!strcmp (p4, "and") || !strcmp (p4, "or") || !strcmp (p4, "not")) {
-
- r2 = get_xpath_predicate (pr, mem);
-
- res = nmem_malloc(mem, sizeof(struct xpath_predicate));
- res->which = XPATH_PREDICATE_BOOLEAN;
- res->u.boolean.op = p4;
- res->u.boolean.left = r1;
- res->u.boolean.right = r2;
- return (res);
- } else {
- /* error */
- }
- } else {
- return (r1);
- }
-
- } else {
- r1 = nmem_malloc(mem, sizeof(struct xpath_predicate));
-
- r1->which = XPATH_PREDICATE_RELATION;
- r1->u.relation.name = p1;
- r1->u.relation.op = "";
- r1->u.relation.value = "";
-
- return (r1);
+struct xpath_predicate *get_xpath_predicate(char *predicates, NMEM mem)
+{
+ char *p1;
+ char *p2;
+ char *p3;
+ char *p4;
+
+ struct xpath_predicate *r1;
+ struct xpath_predicate *r2;
+ struct xpath_predicate *res = 0;
+
+ char *pr = predicates;
+
+ if ((p1 = get_xp_part(&pr, mem))) {
+ if ((p2 = get_xp_part(&pr, mem))) {
+ if (!strcmp (p2, "and") || !strcmp (p2, "or") || !strcmp (p2, "not")) {
+ r1=nmem_malloc(mem, sizeof(struct xpath_predicate));
+ r1->which = XPATH_PREDICATE_RELATION;
+ r1->u.relation.name = p1;
+ r1->u.relation.op = "";
+ r1->u.relation.value = "";
+
+ r2 = get_xpath_predicate (pr, mem);
+
+ res = nmem_malloc(mem, sizeof(struct xpath_predicate));
+ res->which = XPATH_PREDICATE_BOOLEAN;
+ res->u.boolean.op = p2;
+ res->u.boolean.left = r1;
+ res->u.boolean.right = r2;
+
+ return (res);
+ }
+
+ if (strchr("><=] ", *p2)) {
+ r1 = nmem_malloc(mem, sizeof(struct xpath_predicate));
+
+ r1->which = XPATH_PREDICATE_RELATION;
+ r1->u.relation.name = p1;
+ r1->u.relation.op = p2;
+ r1->u.relation.value = "";
+
+ if ((p3 = get_xp_part(&pr, mem))) {
+ r1->u.relation.value = p3;
+ } else {
+ /* error */
+ }
+ }
+
+ if ((p4 = get_xp_part(&pr, mem))) {
+ if (!strcmp (p4, "and") || !strcmp (p4, "or") ||
+ !strcmp (p4, "not"))
+ {
+
+ r2 = get_xpath_predicate (pr, mem);
+
+ res = nmem_malloc(mem, sizeof(struct xpath_predicate));
+ res->which = XPATH_PREDICATE_BOOLEAN;
+ res->u.boolean.op = p4;
+ res->u.boolean.left = r1;
+ res->u.boolean.right = r2;
+ return (res);
+ } else {
+ /* error */
+ }
+ } else {
+ return (r1);
+ }
+
+ } else {
+ r1 = nmem_malloc(mem, sizeof(struct xpath_predicate));
+
+ r1->which = XPATH_PREDICATE_RELATION;
+ r1->u.relation.name = p1;
+ r1->u.relation.op = "";
+ r1->u.relation.value = "";
+
+ return (r1);
+ }