- while (p->more_m)
- {
- logit( info, "start of loop", p->buf_l, p->buf_m, p->buf_r);
-
- /* forward L until past m, count levels, note rec boundaries */
- if (p->more_l)
- cmp_l= (*info->cmp)(p->buf_l, p->buf_m);
- else
- cmp_l=2; /* past this record */
- logf(LOG_DEBUG, "cmp_l=%d", cmp_l);
-
- while (cmp_l < 0) /* l before m */
- {
- if (cmp_l == -2)
- p->level=0; /* earlier record */
- if (cmp_l == -1)
- {
- p->level++; /* relevant start tag */
-
- if (!info->rset_attr)
- attr_match = 1;
- else
- {
- int cmp_attr;
- int dummy_term;
- attr_match = 0;
- while (p->more_attr)
- {
- cmp_attr = (*info->cmp)(p->buf_attr, p->buf_l);
- if (cmp_attr == 0)
- {
- attr_match = 1;
- break;
- }
- else if (cmp_attr > 0)
- break;
- p->more_attr = rset_read (info->rset_attr, p->rfd_attr,
- p->buf_attr, &dummy_term);
- }
- }
- }
- if (p->more_l)
- {
- p->more_l = rset_read (info->rset_l, p->rfd_l, p->buf_l,
- &p->term_index_l);
- cmp_l= (*info->cmp)(p->buf_l, p->buf_m);
- logit( info, "forwarded L", p->buf_l, p->buf_m, p->buf_r);
- logf(LOG_DEBUG, " cmp_l=%d", cmp_l);
- }
- else
- cmp_l=2;
- } /* forward L */
-
-
- /* forward R until past m, count levels */
- if (p->more_r)
- cmp_r= (*info->cmp)(p->buf_r, p->buf_m);
- else
- cmp_r=2;
- logf(LOG_DEBUG, "cmp_r=%d", cmp_r);
- while (cmp_r < 0) /* r before m */
- {
- /* -2, earlier record, doesn't matter */
- if (cmp_r == -1)
- p->level--; /* relevant end tag */
- if (p->more_r)
+ if (*term)
+ yaz_log(log_level, " term: '%s'", (*term)->name);
+ if (*term==info->startterm)
+ {
+ p->depth++;
+ yaz_log(log_level, "read start tag. d=%d", p->depth);
+ memcpy(p->startbuf, buf, kctrl->key_size);
+ p->startbufok = 1;
+ checkattr(rfd); /* in case we already saw the attr here */
+ }
+ else if (*term==info->stopterm)
+ {
+ if (p->depth == p->attrdepth)
+ p->attrdepth = 0; /* ending the tag with attr match */
+ p->depth--;
+ yaz_log(log_level,"read end tag. d=%d ad=%d", p->depth,
+ p->attrdepth);
+ }
+ else if (*term==info->attrterm)
+ {
+ yaz_log(log_level,"read attr");
+ memcpy(p->attrbuf, buf, kctrl->key_size);
+ p->attrbufok = 1;
+ checkattr(rfd); /* in case the start tag came first */
+ }
+ else
+ { /* mut be a real hit */
+ if (p->depth && p->attrdepth)