X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=dict%2Flookup.c;h=f08de3cdd656206f09fb74597bc2f0f4c742ac32;hb=c0a1c79e55f706009113b2de3c11a6f13d4a0e7d;hp=b7dd51c0dbdc1e8bdfba45b992a75ef541a35fbf;hpb=3c5f6226f97612c0d6ac40591f600587c5ffa858;p=idzebra-moved-to-github.git diff --git a/dict/lookup.c b/dict/lookup.c index b7dd51c..f08de3c 100644 --- a/dict/lookup.c +++ b/dict/lookup.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lookup.c,v $ - * Revision 1.9 1999-02-02 14:50:25 adam + * Revision 1.10 1999-05-15 14:36:37 adam + * Updated dictionary. Implemented "compression" of dictionary. + * + * Revision 1.9 1999/02/02 14:50:25 adam * Updated WIN32 code specific sections. Changed header. * * Revision 1.8 1998/03/05 08:17:24 adam @@ -41,9 +44,8 @@ #include -static char *dict_look (Dict dict, const Dict_char *str) +static char *dict_look (Dict dict, const Dict_char *str, Dict_ptr ptr) { - Dict_ptr ptr = 1; int mid, lo, hi; int cmp; void *p; @@ -53,7 +55,7 @@ static char *dict_look (Dict dict, const Dict_char *str) dict_bf_readp (dict->dbf, ptr, &p); mid = lo = 0; hi = DICT_nodir(p)-1; - indxp = (short*) ((char*) p+DICT_pagesize(dict)-sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); while (lo <= hi) { mid = (lo+hi)/2; @@ -97,8 +99,7 @@ static char *dict_look (Dict dict, const Dict_char *str) dict_bf_readp (dict->dbf, ptr, &p); mid = lo = 0; hi = DICT_nodir(p)-1; - indxp = (short*) ((char*) p+DICT_pagesize(dict) - -sizeof(short)); + indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); continue; } } @@ -113,9 +114,7 @@ static char *dict_look (Dict dict, const Dict_char *str) char *dict_lookup (Dict dict, const char *p) { - if (dict->head.last <= 1) + if (!dict->head.root) return NULL; - return dict_look (dict, (const Dict_char *) p); + return dict_look (dict, (const Dict_char *) p, dict->head.root); } - -