- 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);
- }
- }
- }
- p->more_l = rset_read (info->rset_l, p->rfd_l, p->buf_l,
- &p->term_index_l);
- if (p->more_l)
- {
- cmp_l= (*info->cmp)(p->buf_l, p->buf_m);
- }
- else
- cmp_l=2;
- log2( p, "end of L loop", cmp_l, cmp_r);
- } /* forward L */
-
-
- /* forward R until past m, count levels */
- log2( p, "Before moving R", cmp_l, cmp_r);
- if (p->more_r)
- cmp_r= (*info->cmp)(p->buf_r, p->buf_m);
- else
- cmp_r=2;
- log2( p, "after first R", cmp_l, 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)
- {
- p->more_r = rset_read (info->rset_r, p->rfd_r, p->buf_r,
- &p->term_index_r);
- cmp_r= (*info->cmp)(p->buf_r, p->buf_m);
- }
- else
- cmp_r=2;
- log2( p, "End of R loop", cmp_l, cmp_r);
- } /* forward R */
-
- if ( ( p->level <= 0 ) && ! p->more_l)
- return 0; /* no more start tags, nothing more to find */
-
- if ( attr_match && p->level > 0) /* within a tag pair (or deeper) */
+ 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)