/* This file is part of the Zebra server.
- Copyright (C) 1994-2011 Index Data
+ Copyright (C) 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
#define WORD_BITS 32
#define MAX_LENGTH 1024
-/* This code is based
+/* This code is based
* Sun Wu and Udi Manber: Fast Text Searching Allowing Errors.
* Communications of the ACM, pp. 83-91, Vol. 35, No. 10, Oct. 1992, USA.
* PostScript version of the paper in its submitted form: agrep1.ps)
- * recommended reading to understand AGREP !
+ * recommended reading to understand AGREP !
*
* http://www.tgries.de/agrep/#AGREP1PS
* http://www.tgries.de/agrep/doc/agrep1ps.zip
MatchWord *match_mask; /* match_mask */
} MatchContext;
-#define INLINE
+#define INLINE
static INLINE void set_bit(MatchContext *mc, MatchWord *m, int ch, int state)
{
int off = state & (WORD_BITS-1);
int wno = state / WORD_BITS;
-
+
m[mc->n * ch + wno] |= 1<<off;
}
for (d = 1; d <= mc->range; d++)
{
or(mc, Rtmp, Rj, Rj1); /* 2,3 */
-
+
shift(mc, Rtmp_2, Rtmp, dfa);
mask_shift(mc, Rtmp, Rj+mc->n, dfa, ch); /* 1 */
-
+
or(mc, Rtmp, Rtmp_2, Rtmp); /* 1,2,3*/
Rj1 += mc->n;
-
+
or(mc, Rj1, Rtmp, Rj); /* 1,2,3,4 */
Rj += mc->n;
{
if (was_match)
{
- int ret = userfunc((char*) prefix,
+ int ret = userfunc((char*) prefix,
info+(j+1)*sizeof(Dict_char), client);
if (ret)
return ret;
info = (char*)p - indxp[-lo];
memcpy(&ch, info+sizeof(Dict_ptr), sizeof(Dict_char));
prefix[pos] = ch;
-
+
if (pos > *max_pos)
*max_pos = pos;
if (pos >= init_pos)
yaz_log(YLOG_DEBUG, " %2d %3d %c", i, pattern[i],
(pattern[i] > ' ' && pattern[i] < 127) ? pattern[i] : '?');
}
-
+
dfa_set_cmap(dfa, dict->grep_cmap_data, dict->grep_cmap);
i = dfa_parse(dfa, &this_pattern);
mc = mk_MatchContext(dfa, range);
- Rj = (MatchWord *) xcalloc((MAX_LENGTH+1) * mc->n, sizeof(*Rj));
+ Rj = (MatchWord *) xcalloc((MAX_LENGTH+2) * mc->fact, sizeof(*Rj));
set_bit (mc, Rj, 0, 0);
for (d = 1; d<=mc->range; d++)