2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1999-05-15 14:36:37 adam
8 * Updated dictionary. Implemented "compression" of dictionary.
10 * Revision 1.5 1999/02/02 14:50:17 adam
11 * Updated WIN32 code specific sections. Changed header.
13 * Revision 1.4 1996/02/02 13:43:50 adam
14 * The public functions simply use char instead of Dict_char to represent
15 * search strings. Dict_char is used internally only.
17 * Revision 1.3 1995/12/07 11:48:55 adam
18 * Insert operation obeys DICT_type = 1 (slack in page).
19 * Function dict_open exists if page size or magic aren't right.
21 * Revision 1.2 1995/12/06 17:48:30 adam
22 * Bug fix: delete didn't work.
24 * Revision 1.1 1995/12/06 14:52:21 adam
25 * New function: dict_delete.
36 static int dict_del (Dict dict, const Dict_char *str, Dict_ptr ptr)
44 dict_bf_readp (dict->dbf, ptr, &p);
47 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
53 /* string (Dict_char *) DICT_EOS terminated */
54 /* unsigned char length of information */
55 /* char * information */
56 info = (char*)p + indxp[-mid];
57 cmp = dict_strcmp((Dict_char*) info, str);
63 indxp[-mid] = indxp[-mid-1];
68 dict_bf_touch (dict->dbf, ptr);
78 /* Dict_char sub char */
79 /* unsigned char length of information */
80 /* char * information */
81 info = (char*)p - indxp[-mid];
82 memcpy (&dc, info+sizeof(Dict_ptr), sizeof(Dict_char));
86 memcpy (&subptr, info, sizeof(Dict_ptr));
87 if (*++str == DICT_EOS)
89 if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
91 info[sizeof(Dict_ptr)+sizeof(Dict_char)] = 0;
93 dict_bf_touch (dict->dbf, ptr);
103 dict_bf_readp (dict->dbf, ptr, &p);
105 hi = DICT_nodir(p)-1;
106 indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
119 int dict_delete (Dict dict, const char *p)
121 if (!dict->head.root)
123 return dict_del (dict, (const Dict_char*) p, dict->head.root);