X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Frpnscan.c;h=341acb2ac38461898ee83a7094c55b745c5a20ee;hp=005bc1cfb62b087545d4eb33de4eef508c65b34d;hb=049a7363a54b6e467e8f0d2202b01848fe98dc70;hpb=56f6460914459b1162ffc68d7021e5a29b409f99 diff --git a/index/rpnscan.c b/index/rpnscan.c index 005bc1c..341acb2 100644 --- a/index/rpnscan.c +++ b/index/rpnscan.c @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #ifdef WIN32 @@ -297,13 +300,6 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, odr_malloc(stream, *num_entries * sizeof(*glist)); *is_partial = 0; - if (*position > *num_entries+1) - { - *is_partial = 1; - *position = 1; - *num_entries = 0; - return ZEBRA_OK; - } rpn_char_map_prepare(zh->reg, zm, &rcmi); for (i = 0; i < ord_no; i++) @@ -373,8 +369,13 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, { /* did not get all terms; adjust the real position and reduce number of entries */ - glist = glist + dif; - *num_entries -= dif; + if (dif < *num_entries) + { + glist = glist + dif; + *num_entries -= dif; + } + else + *num_entries = 0; *position -= dif; *is_partial = 1; } @@ -435,7 +436,7 @@ static ZEBRA_RES rpn_scan_norm(ZebraHandle zh, ODR stream, NMEM nmem, pos++; } - if (pos != *num_entries) + if (pos < *num_entries) { if (pos >= 0) *num_entries = pos;