From bb543c3427ce87194159825ca265477245f0db9a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 18 Jan 2006 16:21:48 +0000 Subject: [PATCH] Consider border conditions for scan --- src/filter_multi.cpp | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index 03916ba..075c640 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_multi.cpp,v 1.10 2006-01-18 14:36:15 adam Exp $ +/* $Id: filter_multi.cpp,v 1.11 2006-01-18 16:21:48 adam Exp $ Copyright (c) 2005, Index Data. %LICENSE% @@ -766,7 +766,6 @@ Z_Entry *yf::Multi::ScanTermInfo::get_entry(ODR odr) void yf::Multi::Frontend::scan2(Package &package, Z_APDU *apdu_req) { Z_ScanRequest *req = apdu_req->u.scanRequest; - int no_targets = 0; int default_num_db = req->num_databaseNames; char **default_db = req->databaseNames; @@ -786,7 +785,6 @@ void yf::Multi::Frontend::scan2(Package &package, Z_APDU *apdu_req) } p->request() = apdu_req; p->copy_filter(package); - no_targets++; } multi_move(m_backend_list); @@ -873,7 +871,11 @@ void yf::Multi::Frontend::scan2(Package &package, Z_APDU *apdu_req) } } // after - for (i = position-1; inumberOfTermsRequested; int position_returned = *req->preferredPositionInResponse; - resp->positionOfTerm = odr_intdup(odr, position_returned); - resp->numberOfEntriesReturned = odr_intdup(odr, number_returned); - resp->entries->num_entries = number_returned; resp->entries->entries = (Z_Entry**) odr_malloc(odr, sizeof(Z_Entry*) * number_returned); int i; - + + int lbefore = entries_before.size(); + if (lbefore < position_returned-1) + position_returned = lbefore+1; + ScanTermInfoList::iterator it = entries_before.begin(); - for (i = 0; ientries->entries[i] = it->get_entry(odr); + resp->entries->entries[position_returned-2-i] = it->get_entry(odr); } + it = entries_after.begin(); - for (i = position_returned-1; ientries->entries[i] = it->get_entry(odr); } + + number_returned = i; + + resp->positionOfTerm = odr_intdup(odr, position_returned); + resp->numberOfEntriesReturned = odr_intdup(odr, number_returned); + resp->entries->num_entries = number_returned; + package.response() = f_apdu; } } -- 1.7.10.4