- while (p->more_m)
- {
- log2( p, "start of loop", cmp_l, cmp_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
- {
- p->level = 0;
- cmp_l=2; /* past this record */
- }
- log2( p, "after first L", cmp_l, cmp_r);
-
- 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);
- }
- }
- }
- 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)
+ 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)