From 003edeb05e43971cc5b1a99ca894ff506cd2dd8b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 17 Oct 1995 18:01:22 +0000 Subject: [PATCH] Userfunc may return non-zero in which case the the grepping stops immediately. --- dict/lookgrep.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/dict/lookgrep.c b/dict/lookgrep.c index f3a5504..4304610 100644 --- a/dict/lookgrep.c +++ b/dict/lookgrep.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lookgrep.c,v $ - * Revision 1.6 1995-10-09 16:18:32 adam + * Revision 1.7 1995-10-17 18:01:22 adam + * Userfunc may return non-zero in which case the the grepping stops + * immediately. + * + * Revision 1.6 1995/10/09 16:18:32 adam * Function dict_lookup_grep got extra client data parameter. * * Revision 1.5 1995/09/14 11:52:59 adam @@ -270,8 +274,9 @@ static int dict_grep (Dict dict, Dict_ptr ptr, MatchContext *mc, if (ch == DICT_EOS) { if (was_match) - (*userfunc)(prefix, info+(j+1)*sizeof(Dict_char), - client); + if ((*userfunc)(prefix, info+(j+1)*sizeof(Dict_char), + client)) + return 1; break; } move (mc, Rj1, Rj0, ch, dfa, Rj_tmp); @@ -316,16 +321,18 @@ static int dict_grep (Dict dict, Dict_ptr ptr, MatchContext *mc, if (Rj1[mc->range*mc->n + d] & mc->match_mask[d]) { prefix[pos+1] = DICT_EOS; - (*userfunc)(prefix, info+sizeof(Dict_ptr)+ - sizeof(Dict_char), client); + if ((*userfunc)(prefix, info+sizeof(Dict_ptr)+ + sizeof(Dict_char), client)) + return 1; break; } } memcpy (&subptr, info, sizeof(Dict_ptr)); if (subptr) { - dict_grep (dict, subptr, mc, Rj1, pos+1, - client, userfunc, prefix, dfa); + if (dict_grep (dict, subptr, mc, Rj1, pos+1, + client, userfunc, prefix, dfa)) + return 1; dict_bf_readp (dict->dbf, ptr, &p); indxp = (short*) ((char*) p+DICT_pagesize(dict) -sizeof(short)); -- 1.7.10.4