+ int i = 0;
+ while (*cp && !strchr("/[",*cp))
+ {
+ i++;
+ cp++;
+ }
+ xpath[no].predicate = 0;
+ xpath[no].part = nmem_malloc (mem, i+1);
+ memcpy (xpath[no].part, cp - i, i);
+ xpath[no].part[i] = 0;
+
+ if (*cp == '[')
+ {
+ struct xpath_predicate *p = xpath[no].predicate =
+ nmem_malloc (mem, sizeof(struct xpath_predicate));
+
+ p->which = XPATH_PREDICATE_RELATION;
+ cp++;
+ while (*cp == ' ')
+ cp++;
+
+ for (i = 0; *cp && !strchr("><=] ", *cp); i++)
+ cp++;
+ p->u.relation.name = nmem_malloc (mem, i+1);
+ memcpy (p->u.relation.name, cp - i, i);
+ p->u.relation.name[i] = 0;
+ while (*cp == ' ')
+ cp++;
+ if (*cp != ']')
+ {
+ for (i = 0; *cp && strchr(">=<!", *cp); i++)
+ cp++;
+
+ p->u.relation.op = nmem_malloc (mem, i+1);
+ if (i)
+ memcpy (p->u.relation.op, cp - i, i);
+ p->u.relation.op[i] = 0;
+
+ while (*cp == ' ')
+ cp++;
+
+ if (strchr("\"'", *cp))
+ {
+ cp++;
+ for (i = 0; *cp && !strchr("\"'", *cp); i++)
+ cp++;
+
+ p->u.relation.value = nmem_malloc (mem, i+1);
+ if (i)
+ memcpy (p->u.relation.value, cp - i, i);
+ p->u.relation.value[i] = 0;
+
+ cp++;
+ }
+ else
+ {
+ for (i = 0; *cp && !strchr(" ]", *cp); i++)
+ cp++;
+ p->u.relation.value = nmem_malloc (mem, i+1);
+ if (i)
+ memcpy (p->u.relation.value, cp - i, i);
+ p->u.relation.value[i] = 0;
+ }
+ while (*cp == ' ')
+ cp++;
+ }
+ if (*cp == ']')
+ cp++;
+ } /* end of ] predicate */
+ no++;
+ if (*cp != '/')
+ break;
+ cp++;