- while (p->more[0] && p->more[1])
- {
- int cmp = (*info->p.cmp)(p->buf[0], p->buf[1]);
- if (cmp < -1)
- p->more[0] = rset_forward (info->p.rset[0], p->rfd[0],
- p->buf[0],
- term_index, info->p.cmp, p->buf[0]);
- else if (cmp > 1)
- p->more[1] = rset_forward (info->p.rset[1], p->rfd[1],
- p->buf[1],
- term_index, info->p.cmp, p->buf[1]);
- else
- {
- int seqno[500];
- int n = 0;
-
- seqno[n++] = (*info->p.getseq)(p->buf[0]);
- while ((p->more[0] = rset_read (info->p.rset[0], p->rfd[0],
- p->buf[0],
- term_index)) >= -1 &&
- p->more[0] <= -1)
- if (n < 500)
- seqno[n++] = (*info->p.getseq)(p->buf[0]);
-
- for (i = 0; i<n; i++)
- {
- int diff = (*info->p.getseq)(p->buf[1]) - seqno[i];
- int excl = info->p.exclusion;
- if (!info->p.ordered && diff < 0)
- diff = -diff;
- switch (info->p.relation)
- {
- case 1: /* < */
- if (diff < info->p.distance && diff >= 0)
- excl = !excl;
- break;
- case 2: /* <= */
- if (diff <= info->p.distance && diff >= 0)
- excl = !excl;
- break;
- case 3: /* == */
- if (diff == info->p.distance && diff >= 0)
- excl = !excl;
- break;
- case 4: /* >= */
- if (diff >= info->p.distance && diff >= 0)
- excl = !excl;
- break;
- case 5: /* > */
- if (diff > info->p.distance && diff >= 0)
- excl = !excl;
- break;
- case 6: /* != */
- if (diff != info->p.distance && diff >= 0)
- excl = !excl;
- break;
- }
- if (excl)
- {
- memcpy (buf, p->buf[1], info->p.key_size);
- *term_index = 0;
-
- p->more[1] = rset_read (info->p.rset[1],
- p->rfd[1], p->buf[1],
- term_index);
- p->hits++;
- return 1;
- }
- }
- p->more[1] = rset_read (info->p.rset[1], p->rfd[1],
- p->buf[1],
- term_index);
- }
- }
+ while (p->more[0] && p->more[1])
+ {
+ int cmp = (*info->p.cmp)(p->buf[0], p->buf[1]);
+ if (cmp < -1)
+ p->more[0] = rset_forward (info->p.rset[0], p->rfd[0],
+ p->buf[0], info->p.cmp, p->buf[0]);
+ else if (cmp > 1)
+ p->more[1] = rset_forward (info->p.rset[1], p->rfd[1],
+ p->buf[1], info->p.cmp, p->buf[1]);
+ else
+ {
+ int seqno[500];
+ int n = 0;
+
+ seqno[n++] = (*info->p.getseq)(p->buf[0]);
+ while ((p->more[0] = rset_read (info->p.rset[0], p->rfd[0],
+ p->buf[0])) >= -1 &&
+ p->more[0] <= -1)
+ if (n < 500)
+ seqno[n++] = (*info->p.getseq)(p->buf[0]);
+
+ for (i = 0; i<n; i++)
+ {
+ int diff = (*info->p.getseq)(p->buf[1]) - seqno[i];
+ int excl = info->p.exclusion;
+ if (!info->p.ordered && diff < 0)
+ diff = -diff;
+ switch (info->p.relation)
+ {
+ case 1: /* < */
+ if (diff < info->p.distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 2: /* <= */
+ if (diff <= info->p.distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 3: /* == */
+ if (diff == info->p.distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 4: /* >= */
+ if (diff >= info->p.distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 5: /* > */
+ if (diff > info->p.distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 6: /* != */
+ if (diff != info->p.distance && diff >= 0)
+ excl = !excl;
+ break;
+ }
+ if (excl)
+ {
+ memcpy (buf, p->buf[1], info->p.key_size);
+
+ p->more[1] = rset_read (info->p.rset[1],
+ p->rfd[1], p->buf[1]);
+ p->hits++;
+ return 1;
+ }
+ }
+ p->more[1] = rset_read (info->p.rset[1], p->rfd[1],
+ p->buf[1]);
+ }
+ }