From 65752ce7054586c724bd1e972a290594eeae85d0 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 11 Dec 1995 09:04:48 +0000 Subject: [PATCH] Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary. --- dict/lookgrep.c | 12 +++++++++--- dict/lookup.c | 7 +++++-- dict/scan.c | 7 ++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/dict/lookgrep.c b/dict/lookgrep.c index a3cc6b7..e9623a7 100644 --- a/dict/lookgrep.c +++ b/dict/lookgrep.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lookgrep.c,v $ - * Revision 1.11 1995-12-06 14:43:02 adam + * Revision 1.12 1995-12-11 09:04:48 adam + * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary. + * + * Revision 1.11 1995/12/06 14:43:02 adam * New function: dict_delete. * * Revision 1.10 1995/11/16 17:00:44 adam @@ -403,8 +406,11 @@ int dict_lookup_grep (Dict dict, Dict_char *pattern, int range, void *client, } } *max_pos = 0; - i = dict_grep (dict, 1, mc, Rj, 0, client, userfunc, prefix, dfa, - max_pos); + if (dict->head.last > 1) + i = dict_grep (dict, 1, mc, Rj, 0, client, userfunc, prefix, + dfa, max_pos); + else + i = 0; logf (LOG_DEBUG, "max_pos = %d", *max_pos); dfa_delete (&dfa); xfree (Rj); diff --git a/dict/lookup.c b/dict/lookup.c index 8719af7..46a13c4 100644 --- a/dict/lookup.c +++ b/dict/lookup.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lookup.c,v $ - * Revision 1.5 1995-09-04 09:09:15 adam + * Revision 1.6 1995-12-11 09:04:50 adam + * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary. + * + * Revision 1.5 1995/09/04 09:09:15 adam * String arg in lookup is const. * * Revision 1.4 1994/10/05 12:16:51 adam @@ -99,7 +102,7 @@ static char *dict_look (Dict dict, const Dict_char *str) char *dict_lookup (Dict dict, const Dict_char *p) { - if (dict->head.last == 1) + if (dict->head.last <= 1) return NULL; return dict_look (dict, p); } diff --git a/dict/scan.c b/dict/scan.c index d0bcaf7..01be13e 100644 --- a/dict/scan.c +++ b/dict/scan.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: scan.c,v $ - * Revision 1.6 1995-11-20 11:58:04 adam + * Revision 1.7 1995-12-11 09:04:50 adam + * Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary. + * + * Revision 1.6 1995/11/20 11:58:04 adam * Support for YAZ in standard located directories, such as /usr/local/.. * * Revision 1.5 1995/10/09 16:18:32 adam @@ -196,6 +199,8 @@ int dict_scan (Dict dict, Dict_char *str, int *before, int *after, int (*f)(Dict_char *name, const char *info, int pos, void *client)) { + if (dict->head.last <= 1) + return 0; return dict_scan_r (dict, 1, 0, str, before, after, client, f); } -- 1.7.10.4