X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=dict%2Finsert.c;h=5ec6d4c992f4456ed8c7dc4a3242e7404a348dd4;hb=d07818ca27f4e0efc9683148cb5d9891d34b9495;hp=4a0007f531bbb87bf5a4239bdfdfb9408ba981d1;hpb=400055a9f298ff9d5689dcf292c84f8cafff4697;p=idzebra-moved-to-github.git diff --git a/dict/insert.c b/dict/insert.c index 4a0007f..5ec6d4c 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -4,7 +4,16 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: insert.c,v $ - * Revision 1.13 1995-11-28 09:06:37 adam + * Revision 1.15 1996-02-01 20:39:59 adam + * Bug fix: insert didn't work on 8-bit characters due to unsigned char + * compares in dict_strcmp (strcmp) and signed Dict_char. Dict_char is + * unsigned now. + * + * Revision 1.14 1995/12/07 11:48:56 adam + * Insert operation obeys DICT_type = 1 (slack in page). + * Function dict_open exists if page size or magic aren't right. + * + * Revision 1.13 1995/11/28 09:06:37 adam * Fixed potential dangling pointer. * * Revision 1.12 1995/09/06 10:34:44 adam @@ -143,10 +152,13 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p) { char *info, *info1; int slen; + Dict_char dc; + info = (char*) p + ((short*) p)[j]; /* entry start */ - assert (*info == best_char); + memcpy (&dc, info, sizeof(dc)); + assert (dc == best_char); slen = dict_strlen(info); assert (slen > 0); @@ -411,6 +423,11 @@ static int dict_ins (Dict dict, const Dict_char *str, if (DICT_size(p)+slen+userlen >= DICT_pagesize(dict) - (1+DICT_nodir(p))*sizeof(short)) /* overflow? */ { + if (DICT_type(p)) + { + clean_page (dict, ptr, p, NULL, 0, NULL); + return dict_ins (dict, str, ptr, userlen, userinfo); + } split_page (dict, ptr, p); return dict_ins (dict, str, ptr, userlen, userinfo); }