+ if (cmpfunc)
+ assert(cmpfunc==mrfd->info->cmp);
+ *term_index=0;
+ it = *(mrfd->h->heap[1]);
+ memcpy(buf,it.buf, info->key_size);
+ if (mrfd->countp) {
+ if (mrfd->prevvalue) { /* in another record */
+ if ( (*mrfd->info->cmp)(mrfd->prevvalue,it.buf) < -1)
+ (*mrfd->countp)++;
+ } else {
+ mrfd->prevvalue=xmalloc(info->key_size);
+ (*mrfd->countp)++;
+ }
+ memcpy(mrfd->prevvalue,it.buf, info->key_size);
+ }
+ if (untilbuf)
+ rdres=rset_forward(it.rset, it.fd, it.buf, &dummycount,
+ cmpfunc,untilbuf);
+ else
+ rdres=rset_read(it.rset, it.fd, it.buf, &dummycount);
+ if ( rdres )
+ heap_balance(mrfd->h);
+ else
+ heap_delete(mrfd->h);
+ return 1;
+
+}
+
+static int r_read (RSFD rfd, void *buf, int *term_index)
+{
+ return r_forward(0,rfd, buf, term_index,0,0);
+}
+
+#if 0
+static int old_read
+{
+ struct rset_multior_rfd *mrfd = (struct rset_multior_rfd *) rfd;