- 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;
- else if (cmp_attr==-1)
- p->more_attr = rset_read (info->rset_attr, p->rfd_attr,
- p->buf_attr, &dummy_term);
- /* if we had a forward that went all the way to
- * the seqno, we could use that. But fwd only goes
- * to the sysno */
- else if (cmp_attr==-2)
- {
- p->more_attr = rset_forward(
- info->rset_attr, p->rfd_attr,
- p->buf_attr, &dummy_term,
- info->cmp, p->buf_l);
-#if RSBETWEEN_DEBUG
- logf(LOG_DEBUG, "btw: after frowarding attr m=%d",p->more_attr);
-#endif
- }
- } /* while more_attr */
- }
- }
-#define NEWCODE 1
-#if NEWCODE
- if (cmp_l==-2)
+/* 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++)