From d07818ca27f4e0efc9683148cb5d9891d34b9495 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 1 Feb 1996 20:39:52 +0000 Subject: [PATCH] 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. --- dict/dicttest.c | 18 ++++++++++++++++-- dict/insert.c | 12 ++++++++++-- include/dict.h | 9 +++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/dict/dicttest.c b/dict/dicttest.c index 07e19f1..5d97bb2 100644 --- a/dict/dicttest.c +++ b/dict/dicttest.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dicttest.c,v $ - * Revision 1.17 1995-12-06 17:48:30 adam + * Revision 1.18 1996-02-01 20:39:52 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.17 1995/12/06 17:48:30 adam * Bug fix: delete didn't work. * * Revision 1.16 1995/10/09 16:18:31 adam @@ -105,8 +110,17 @@ int main (int argc, char **argv) { fprintf (stderr, "usage:\n " " %s [-d] [-r n] [-u] [-g pat] [-s n] [-v n] [-i f] [-w]" - " [-c n] base file\n", + " [-c n] base file\n\n", prog); + fprintf (stderr, " -d delete instead of insert\n"); + fprintf (stderr, " -r n set regular match range\n"); + fprintf (stderr, " -u report if keys change during insert\n"); + fprintf (stderr, " -g p try pattern n (see -r)\n"); + fprintf (stderr, " -s n set info size to n (instead of 4)\n"); + fprintf (stderr, " -v n set logging level\n"); + fprintf (stderr, " -i f read file with words\n"); + fprintf (stderr, " -w insert/delete instead of lookup\n"); + fprintf (stderr, " -c n cache size (number of pages)\n"); exit (1); } while ((ret = options ("dr:ug:s:v:i:wc:", argv, argc, &arg)) != -2) diff --git a/dict/insert.c b/dict/insert.c index 396640a..5ec6d4c 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: insert.c,v $ - * Revision 1.14 1995-12-07 11:48:56 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. * @@ -147,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); diff --git a/include/dict.h b/include/dict.h index 1b86e1f..2b78d2d 100644 --- a/include/dict.h +++ b/include/dict.h @@ -4,7 +4,12 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: dict.h,v $ - * Revision 1.17 1995-12-07 11:47:04 adam + * Revision 1.18 1996-02-01 20:41:06 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.17 1995/12/07 11:47:04 adam * Default pagesize is 4k instead of 8k. * * Revision 1.16 1995/12/06 14:41:13 adam @@ -67,7 +72,7 @@ #include typedef unsigned Dict_ptr; -typedef char Dict_char; +typedef unsigned char Dict_char; struct Dict_head { char magic_str[8]; -- 1.7.10.4