+ else if (cmp > 1) /* cmp == 2 */
+ {
+#define OLDCODE 0
+#if OLDCODE
+ memcpy (buf, p->buf_r, info->key_size);
+ *term_index = p->term_index_r + info->term_index_s;
+
+ p->more_r = rset_read (info->rset_r, p->rfd_r, p->buf_r,
+ &p->term_index_r);
+ if (p->tail)
+ {
+ if (!p->more_r || (*info->cmp)(p->buf_r, buf) > 1)
+ p->tail = 0;
+#if RSET_DEBUG
+ logf (LOG_DEBUG, "r_read_and returning C m=%d/%d c=%d",
+ p->more_l, p->more_r, cmp);
+ (*info->log_item)(LOG_DEBUG, buf, "");
+#endif
+ p->hits++;
+ return 1;
+ }
+#else
+
+ if (p->tail)
+ {
+ memcpy (buf, p->buf_r, info->key_size);
+ *term_index = p->term_index_r + info->term_index_s;
+ p->more_r = rset_read (info->rset_r, p->rfd_r, p->buf_r,
+ &p->term_index_r);
+ if (!p->more_r || (*info->cmp)(p->buf_r, buf) > 1)
+ p->tail = 0;
+#if RSET_DEBUG
+ logf (LOG_DEBUG, "r_read_and [%p] returning R tail m=%d/%d c=%d",
+ rfd, p->more_l, p->more_r, cmp);
+ (*info->log_item)(LOG_DEBUG, buf, "");
+#endif
+ p->hits++;
+ return 1;
+ }
+ else
+ {
+#if RSET_DEBUG
+ logf (LOG_DEBUG, "r_read_and [%p] about to forward R m=%d/%d c=%d",
+ rfd, p->more_l, p->more_r, cmp);
+#endif
+ if (p->more_r && p->more_l)
+ p->more_r = rset_forward(
+ info->rset_r, p->rfd_r,
+ p->buf_r, &p->term_index_r,
+ (info->cmp), p->buf_l);
+ else
+ return 0; /* no point in reading further */
+ }
+#endif
+ }
+ else /* cmp == -2 */
+ {
+#if OLDCODE
+ memcpy (buf, p->buf_l, info->key_size);
+ *term_index = p->term_index_l;
+ p->more_l = rset_read (info->rset_l, p->rfd_l, p->buf_l,
+ &p->term_index_l);
+ if (p->tail)
+ {
+ if (!p->more_l || (*info->cmp)(p->buf_l, buf) > 1)
+ p->tail = 0;
+#if RSET_DEBUG
+ logf (LOG_DEBUG, "r_read_and [%p] returning R tail m=%d/%d c=%d",
+ rfd, p->more_l, p->more_r, cmp);
+ (*info->log_item)(LOG_DEBUG, buf, "");
+#endif
+ p->hits++;
+ return 1;
+ }
+#else
+ if (p->tail)
+ {
+ memcpy (buf, p->buf_l, info->key_size);
+ *term_index = p->term_index_l;
+ p->more_l = rset_read (info->rset_l, p->rfd_l, p->buf_l,
+ &p->term_index_l);
+ if (!p->more_l || (*info->cmp)(p->buf_l, buf) > 1)
+ p->tail = 0;
+#if RSET_DEBUG
+ logf (LOG_DEBUG, "r_read_and [%p] returning L tail m=%d/%d c=%d",
+ rfd, p->more_l, p->more_r, cmp);
+ (*info->log_item)(LOG_DEBUG, buf, "");
+#endif
+ p->hits++;
+ return 1;
+ }
+ else
+ {
+#if RSET_DEBUG
+ logf (LOG_DEBUG, "r_read_and [%p] about to forward L m=%d/%d c=%d",
+ rfd, p->more_l, p->more_r, cmp);
+#endif
+ if (p->more_r && p->more_l)
+ p->more_l = rset_forward(
+ /* p->more_l = rset_default_forward( */
+ info->rset_l, p->rfd_l,
+ p->buf_l, &p->term_index_l,
+ (info->cmp), p->buf_r);
+ else
+ return 0; /* no point in reading further */
+ }
+#endif
+ }