-/* $Id: rsprox.c,v 1.31 2006-06-06 21:01:31 adam Exp $
- Copyright (C) 1995-2006
- Index Data ApS
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) 1994-2009 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
#include <stdio.h>
}
if (i == ct->no_children)
{
- memcpy (buf, p->buf[0], kctrl->key_size);
+ i = ct->no_children-1;
+ memcpy(buf, p->buf[i], kctrl->key_size);
if (term)
- *term = p->terms[0];
- p->more[0] = rset_read (p->rfd[0], p->buf[0], &p->terms[0]);
+ *term = p->terms[i];
+ p->more[i] = rset_read(p->rfd[i], p->buf[i], &p->terms[i]);
p->hits++;
return 1;
}
seqno[n++] = (*kctrl->getseq)(p->buf[0]);
while ((p->more[0] = rset_read (p->rfd[0],
- p->buf[0], &p->terms[0])) >= -1 &&
- p->more[0] <= -1)
+ p->buf[0], &p->terms[0])))
+ {
+ cmp = (*kctrl->cmp)(p->buf[0], p->buf[1]);
+ if (cmp <= - rfd->rset->scope || cmp >= rfd->rset->scope)
+ break;
if (n < 500)
seqno[n++] = (*kctrl->getseq)(p->buf[0]);
-
- for (i = 0; i<n; i++)
+ }
+ /* set up return buffer.. (save buf[1]) */
+ memcpy(buf, p->buf[1], kctrl->key_size);
+ if (term)
+ *term = p->terms[1];
+ while (1)
{
- zint diff = (*kctrl->getseq)(p->buf[1]) - seqno[i];
- int excl = info->exclusion;
- if (!info->ordered && diff < 0)
- diff = -diff;
- switch (info->relation)
+ for (i = 0; i < n; i++)
{
- case 1: /* < */
- if (diff < info->distance && diff >= 0)
- excl = !excl;
- break;
- case 2: /* <= */
- if (diff <= info->distance && diff >= 0)
- excl = !excl;
- break;
- case 3: /* == */
- if (diff == info->distance && diff >= 0)
- excl = !excl;
- break;
- case 4: /* >= */
- if (diff >= info->distance && diff >= 0)
- excl = !excl;
- break;
- case 5: /* > */
- if (diff > info->distance && diff >= 0)
- excl = !excl;
+ zint diff = (*kctrl->getseq)(p->buf[1]) - seqno[i];
+ int excl = info->exclusion;
+ if (!info->ordered && diff < 0)
+ diff = -diff;
+ switch (info->relation)
+ {
+ case 1: /* < */
+ if (diff < info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 2: /* <= */
+ if (diff <= info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 3: /* == */
+ if (diff == info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 4: /* >= */
+ if (diff >= info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 5: /* > */
+ if (diff > info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ case 6: /* != */
+ if (diff != info->distance && diff >= 0)
+ excl = !excl;
+ break;
+ }
+ if (excl)
+ {
+ p->more[1] = rset_read ( p->rfd[1], p->buf[1],
+ &p->terms[1]);
+ p->hits++;
+ return 1;
+ }
+ }
+ p->more[1] = rset_read(p->rfd[1], p->buf[1], &p->terms[1]);
+ if (!p->more[1])
break;
- case 6: /* != */
- if (diff != info->distance && diff >= 0)
- excl = !excl;
+ cmp = (*kctrl->cmp)(buf, p->buf[1]);
+ if (cmp <= - rfd->rset->scope || cmp >= rfd->rset->scope)
break;
- }
- if (excl)
- {
- memcpy (buf, p->buf[1], kctrl->key_size);
- if (term)
- *term = p->terms[1];
- p->more[1] = rset_read ( p->rfd[1], p->buf[1],
- &p->terms[1]);
- p->hits++;
- return 1;
- }
}
- p->more[1] = rset_read (p->rfd[1], p->buf[1], &p->terms[1]);
}
}
}
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab