projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added extra presence check for tcl.h, because some systems have
[idzebra-moved-to-github.git]
/
rset
/
rsprox.c
diff --git
a/rset/rsprox.c
b/rset/rsprox.c
index
6a43203
..
dc70fd6
100644
(file)
--- a/
rset/rsprox.c
+++ b/
rset/rsprox.c
@@
-1,4
+1,4
@@
-/* $Id: rsprox.c,v 1.4 2004-08-03 12:15:45 heikki Exp $
+/* $Id: rsprox.c,v 1.5.2.2 2006-08-14 10:39:20 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
@@
-15,9
+15,9
@@
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
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>
*/
#include <stdio.h>
@@
-40,7
+40,6
@@
static void r_rewind (RSFD rfd);
static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index,
int (*cmpfunc)(const void *p1, const void *p2),
const void *untilbuf);
static int r_forward(RSET ct, RSFD rfd, void *buf, int *term_index,
int (*cmpfunc)(const void *p1, const void *p2),
const void *untilbuf);
-/* static int r_count (RSET ct); */
static int r_read (RSFD rfd, void *buf, int *term_index);
static int r_write (RSFD rfd, const void *buf);
static int r_read (RSFD rfd, void *buf, int *term_index);
static int r_write (RSFD rfd, const void *buf);
@@
-53,7
+52,7
@@
static const struct rset_control control_prox =
r_delete,
r_rewind,
r_forward,
r_delete,
r_rewind,
r_forward,
- /* r_count, */
+ rset_default_pos,
r_read,
r_write,
};
r_read,
r_write,
};
@@
-72,6
+71,8
@@
struct rset_prox_rfd {
char *more; /* more in each lookahead? */
struct rset_prox_rfd *next;
struct rset_prox_info *info;
char *more; /* more in each lookahead? */
struct rset_prox_rfd *next;
struct rset_prox_info *info;
+ int *countp;
+ char *pbuf;
};
static void *r_create (RSET ct, const struct rset_control *sel, void *parms)
};
static void *r_create (RSET ct, const struct rset_control *sel, void *parms)
@@
-127,6
+128,7
@@
static void *r_create (RSET ct, const struct rset_control *sel, void *parms)
ct->rset_terms[0] = rset_term_create (prox_term, length_prox_term,
flags, term_type);
ct->rset_terms[0] = rset_term_create (prox_term, length_prox_term,
flags, term_type);
+
return info;
}
return info;
}
@@
-160,6
+162,9
@@
static RSFD r_open (RSET ct, int flag)
for (i = 0; i < info->p.rset_no; i++)
rfd->more[i] = rset_read (info->p.rset[i], rfd->rfd[i],
rfd->buf[i], &dummy);
for (i = 0; i < info->p.rset_no; i++)
rfd->more[i] = rset_read (info->p.rset[i], rfd->rfd[i],
rfd->buf[i], &dummy);
+
+ rfd->countp = &ct->rset_terms[0]->count;
+ rfd->pbuf = xmalloc (info->p.key_size);
return rfd;
}
return rfd;
}
@@
-177,6
+182,8
@@
static void r_close (RSFD rfd)
xfree ((*rfdp)->buf);
xfree ((*rfdp)->more);
xfree ((*rfdp)->buf);
xfree ((*rfdp)->more);
+ xfree ((*rfdp)->pbuf);
+
for (i = 0; i<info->p.rset_no; i++)
rset_close (info->p.rset[i], (*rfdp)->rfd[i]);
xfree ((*rfdp)->rfd);
for (i = 0; i<info->p.rset_no; i++)
rset_close (info->p.rset[i], (*rfdp)->rfd[i]);
xfree ((*rfdp)->rfd);
@@
-287,6
+294,13
@@
static int r_forward (RSET ct, RSFD rfd, void *buf, int *term_index,
p->more[0] = rset_read (info->p.rset[0], p->rfd[0],
p->buf[0], &dummy);
p->more[0] = rset_read (info->p.rset[0], p->rfd[0],
p->buf[0], &dummy);
+
+ if (p->countp && (
+ *p->countp == 0 || (*info->p.cmp)(buf, p->pbuf) > 1))
+ {
+ memcpy (p->pbuf, buf, info->p.key_size);
+ (*p->countp)++;
+ }
return 1;
}
}
return 1;
}
}
@@
-370,12
+384,6
@@
static int r_forward (RSET ct, RSFD rfd, void *buf, int *term_index,
return 0;
}
return 0;
}
-/*
-static int r_count (RSET ct)
-{
- return 0;
-}
-*/
static int r_read (RSFD rfd, void *buf, int *term_index)
{
static int r_read (RSFD rfd, void *buf, int *term_index)
{