/* This file is part of the Zebra server.
- Copyright (C) 1994-2009 Index Data
+ Copyright (C) 1994-2011 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
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
else
idx = -pos - 1;
- yaz_log(YLOG_DEBUG, "pos=%d idx=%d name=%s", pos, idx, name);
if (idx < 0)
return 0;
- if (idx < hi->start_cut || idx >= hi->end_cut)
+ if (idx < hi->start_cut || idx > hi->end_cut)
{
return 1;
}
hi.a = after;
hi.b = before;
hi.ar = malloc(sizeof(char*) * (after+before+1));
- for (i = 0; i<after+before; i++)
+ for (i = 0; i <= after+before; i++)
hi.ar[i] = 0;
yaz_log(YLOG_DEBUG, "dict_scan before=%d after=%d term=%s",
before, after, scan_term);
{
if (!cmp_strs)
{
- if (i >= start_cut && i < end_cut)
+ if (i >= start_cut && i <= end_cut)
{
if (!hi.ar[i])
{
}
else
{
- if (i >= start_cut && i < end_cut)
+ if (i >= start_cut && i <= end_cut)
{
if (!hi.ar[i])
{
YAZ_CHECK_EQ(dict_insert(dict, w, sizeof(v), &v), 1);
}
+#if 1
{
char *cs[] = {
"4497",
"45"};
YAZ_CHECK_EQ(do_scan(dict, 2, 2, "4499", cs, 0, 0, 3), 0);
}
+#endif
+#if 1
{
char *cs[] = {
"4498",
"450"};
YAZ_CHECK_EQ(do_scan(dict, 2, 2, "45", cs, 0, 0, 3), 0);
}
-
+#endif
+#if 1
+ /* bug 4592 */
+ {
+ char *cs[] = {
+ "4499",
+ "45", /* missing entry ! */
+ "450",
+ "4500"};
+ YAZ_CHECK_EQ(do_scan(dict, 4, 0, "4501", cs, 0, 0, 4), 0);
+ }
+#endif
+#if 1
+ {
+ char *cs[] = {
+ "9996",
+ "9997",
+ "9998",
+ "9999"};
+ YAZ_CHECK_EQ(do_scan(dict, 4, 0, "a", cs, 0, 0, 4), 0);
+ YAZ_CHECK_EQ(do_scan(dict, 3, 1, "9999", cs, 0, 0, 4), 0);
+ }
+#endif
+#if 1
+ {
+ char *cs[] = {
+ "10",
+ "100",
+ "1000",
+ "1001" };
+ YAZ_CHECK_EQ(do_scan(dict, 0, 4, "10", cs, 0, 0, 4), 0);
+ YAZ_CHECK_EQ(do_scan(dict, 0, 4, "1", cs, 0, 0, 4), 0);
+ YAZ_CHECK_EQ(do_scan(dict, 0, 4, " ", cs, 0, 0, 4), 0);
+ YAZ_CHECK_EQ(do_scan(dict, 0, 4, "", cs, 0, 0, 4), 0);
+ }
+#endif
+#if 1
for (i = 0; i < 20; i++)
YAZ_CHECK_EQ(do_scan(dict, 20, 20, "45", 0, 0, 20-i, 20+i), 0);
+#endif
}
int main(int argc, char **argv)
if (bfs)
{
bf_reset(bfs);
- dict = dict_open(bfs, "dict", 10, 1, 0, 0);
+ dict = dict_open(bfs, "dict", 100, 1, 0, 0);
YAZ_CHECK(dict);
}
if (dict)
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab