Bug fix: the lookup/scan/lookgrep didn't handle empty dictionary.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 11 Dec 1995 09:04:48 +0000 (09:04 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 11 Dec 1995 09:04:48 +0000 (09:04 +0000)
dict/lookgrep.c
dict/lookup.c
dict/scan.c

index a3cc6b7..e9623a7 100644 (file)
@@ -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);
index 8719af7..46a13c4 100644 (file)
@@ -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);
 }
index d0bcaf7..01be13e 100644 (file)
@@ -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);
 }