- 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 (p->more_l)
+ p->attrdepth=-1; /* matches always */
+ return;
+ }
+ if ( p->startbufok && p->attrbufok )
+ { /* have buffers to compare */
+ cmp=(*info->cmp)(p->startbuf,p->attrbuf);
+ if (0==cmp) /* and the keys match */
+ {
+ p->attrdepth=p->depth;
+#if RSBETWEEN_DEBUG
+ yaz_log(log_level, "found attribute match at depth %d",p->attrdepth);
+#endif
+ }
+ }
+}
+
+
+/* Implements a multi-and between the l,r, and m rfds. Returns all */
+/* hits from those, provided that all three point to the same record */
+/* See rsmultiandor.c in zebra 1.4 for details */
+static int read_anded(struct rset_between_rfd *p,void *buf,
+ int *term, int *which) {
+ RSFD rfds[4];
+ RSET rsets[4];
+ void *bufs[4];
+ int *terms[4];
+ int dummyterm;
+ struct rset_between_info *info =p->info;
+ int i, mintail;
+ int n;
+ int cmp;
+
+ /* make the individual args into arrays, to match rsmultiandor */
+ rfds[WHICH_L]=p->rfd_l;
+ rfds[WHICH_M]=p->rfd_m;
+ rfds[WHICH_R]=p->rfd_r;
+ rfds[WHICH_A]=p->rfd_attr;
+ rsets[WHICH_L]=info->rset_l;
+ rsets[WHICH_M]=info->rset_m;
+ rsets[WHICH_R]=info->rset_r;
+ rsets[WHICH_A]=info->rset_attr;
+ bufs[WHICH_L]=p->buf_l;
+ bufs[WHICH_M]=p->buf_m;
+ bufs[WHICH_R]=p->buf_r;
+ bufs[WHICH_A]=p->buf_attr;
+ terms[WHICH_L]=&(p->term_index_l);
+ terms[WHICH_M]=&(p->term_index_m);
+ terms[WHICH_R]=&(p->term_index_r);
+ terms[WHICH_A]=&dummyterm;
+ dummyterm=0;
+ if (info->rset_attr)
+ n=4;
+ else
+ n=3;
+ while (1) {
+ if (p->tailcount)
+ { /* we are tailing */
+ mintail=0;
+ while ((mintail<n) && !p->tailbits[mintail])
+ mintail++; /* first tail */
+ for (i=mintail+1;i<n;i++)