From: Adam Dickmeiss Date: Fri, 29 Sep 1995 14:01:39 +0000 (+0000) Subject: Bug fixes. X-Git-Tag: ZEBRA.1.0~738 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=eb4e33573a00795f2b1c0dfebb51ab59ffd5a0d9;p=idzebra-moved-to-github.git Bug fixes. --- diff --git a/index/extract.c b/index/extract.c index 3560d13..0d9afd5 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.12 1995-09-28 14:22:56 adam + * Revision 1.13 1995-09-29 14:01:39 adam + * Bug fixes. + * + * Revision 1.12 1995/09/28 14:22:56 adam * Sort uses smaller temporary files. * * Revision 1.11 1995/09/28 12:10:31 adam @@ -67,22 +70,6 @@ static size_t ptr_i; static size_t kused; static int key_file_no; -static int sort_compare (const void *p1, const void *p2) -{ - int r; - size_t l; - char *cp1 = *(char**) p1; - char *cp2 = *(char**) p2; - - if ((r = strcmp (cp1, cp2))) - return r; - l = strlen(cp1); - if ((r = key_compare (cp1+l, cp2+l))) - return r; - return cp1[l+sizeof(struct it_key)] - - cp2[l+sizeof(struct it_key)]; -} - void key_open (int mem) { void *file_key; @@ -123,10 +110,9 @@ void key_flush (void) key_file_no++; logf (LOG_LOG, "sorting section %d", key_file_no); - qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), sort_compare); + qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare); sprintf (out_fname, TEMP_FNAME, key_file_no); - if (!(outf = fopen (out_fname, "w"))) { logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname); @@ -211,12 +197,11 @@ static void wordAdd (const RecWord *p) default: return ; } + ((char*) key_buf)[kused++] = ((key_cmd == 'a') ? 1 : 0); key.sysno = key_sysno; key.seqno = p->seqno; memcpy ((char*)key_buf + kused, &key, sizeof(key)); kused += sizeof(key); - - ((char*) key_buf)[kused++] = ((key_cmd == 'a') ? 1 : 0); } void file_extract (int cmd, const char *fname, const char *kname) diff --git a/index/index.h b/index/index.h index 1d8ea48..be0b605 100644 --- a/index/index.h +++ b/index/index.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: index.h,v $ - * Revision 1.13 1995-09-28 14:22:56 adam + * Revision 1.14 1995-09-29 14:01:40 adam + * Bug fixes. + * + * Revision 1.13 1995/09/28 14:22:56 adam * Sort uses smaller temporary files. * * Revision 1.12 1995/09/28 12:10:32 adam @@ -76,6 +79,7 @@ void key_open (int mem); int key_close (void); void key_write (int cmd, struct it_key *k, const char *str); int key_compare (const void *p1, const void *p2); +int key_qsort_compare (const void *p1, const void *p2); void key_logdump (int mask, const void *p); void key_input (const char *dict_fname, const char *isam_fname, const char *key_fname, int cache); diff --git a/index/kcompare.c b/index/kcompare.c index 5ffab21..981a485 100644 --- a/index/kcompare.c +++ b/index/kcompare.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kcompare.c,v $ - * Revision 1.9 1995-09-28 12:10:32 adam + * Revision 1.10 1995-09-29 14:01:41 adam + * Bug fixes. + * + * Revision 1.9 1995/09/28 12:10:32 adam * Bug fixes. Field prefix used in queries. * * Revision 1.8 1995/09/28 09:19:42 adam @@ -86,6 +89,21 @@ int key_compare (const void *p1, const void *p2) return 0; } +int key_qsort_compare (const void *p1, const void *p2) +{ + int r; + size_t l; + char *cp1 = *(char **) p1; + char *cp2 = *(char **) p2; + + if ((r = strcmp (cp1, cp2))) + return r; + l = strlen(cp1)+1; + if ((r = key_compare (cp1+l+1, cp2+l+1))) + return r; + return cp1[l] - cp2[l]; +} + int index_char_cvt (int c) { return tolower (c); diff --git a/index/kdump.c b/index/kdump.c index d13d7a4..899f508 100644 --- a/index/kdump.c +++ b/index/kdump.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kdump.c,v $ - * Revision 1.5 1995-09-11 13:09:35 adam + * Revision 1.6 1995-09-29 14:01:42 adam + * Bug fixes. + * + * Revision 1.5 1995/09/11 13:09:35 adam * More work on relevance feedback. * * Revision 1.4 1995/09/08 14:52:27 adam @@ -35,7 +38,6 @@ static int read_one (FILE *inf, char *name, char *key) { int c; int i = 0; - name[0] = 0; do { if ((c=getc(inf)) == EOF) @@ -86,13 +88,15 @@ int main (int argc, char **argv) while (read_one (inf, key_string, key_info)) { struct it_key k; + int op; - memcpy (&k, key_info+1, sizeof(k)); + op = key_info[0]; + memcpy (&k, 1+key_info, sizeof(k)); #if IT_KEY_HAVE_SEQNO - printf ("%7d op=%d s=%-5d %s\n", k.sysno, *key_info, k.seqno, + printf ("%7d op=%d s=%-5d %s\n", k.sysno, op, k.seqno, key_string); #else - printf ("%7d op=%d f=%-3d %s\n", k.sysno, *key_info, k.freq, + printf ("%7d op=%d f=%-3d %s\n", k.sysno, op, k.freq, key_string); #endif diff --git a/index/kinput.c b/index/kinput.c index 889a641..7db3a01 100644 --- a/index/kinput.c +++ b/index/kinput.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: kinput.c,v $ - * Revision 1.4 1995-09-28 14:22:57 adam + * Revision 1.5 1995-09-29 14:01:43 adam + * Bug fixes. + * + * Revision 1.4 1995/09/28 14:22:57 adam * Sort uses smaller temporary files. * * Revision 1.3 1995/09/06 16:11:17 adam @@ -42,7 +45,6 @@ static int read_one (FILE *inf, char *name, char *key) { int c; int i = 0; - name[0] = 0; do { if ((c=getc(inf)) == EOF) @@ -65,6 +67,7 @@ static int inp (Dict dict, ISAM isam, const char *name) int key_buf_ptr; char *next_key; char *key_buf; + int more; next_key = xmalloc (KEY_SIZE); key_buf = xmalloc (key_buf_size * (KEY_SIZE)); @@ -73,14 +76,14 @@ static int inp (Dict dict, ISAM isam, const char *name) logf (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", name); exit (1); } - read_one (inf, cur_name, key_buf); - while (cur_name[0]) /* EOF ? */ + more = read_one (inf, cur_name, key_buf); + while (more) /* EOF ? */ { int nmemb; key_buf_ptr = KEY_SIZE; while (1) { - if (!read_one (inf, next_name, next_key)) + if (!(more = read_one (inf, next_name, next_key))) break; if (*next_name && strcmp (next_name, cur_name)) break; diff --git a/index/main.c b/index/main.c index 0616499..916f248 100644 --- a/index/main.c +++ b/index/main.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: main.c,v $ - * Revision 1.10 1995-09-28 14:22:57 adam + * Revision 1.11 1995-09-29 14:01:45 adam + * Bug fixes. + * + * Revision 1.10 1995/09/28 14:22:57 adam * Sort uses smaller temporary files. * * Revision 1.9 1995/09/14 07:48:24 adam @@ -45,6 +48,7 @@ #include "index.h" char *prog; +size_t mem_max = 4*1024*1024; int main (int argc, char **argv) { @@ -57,7 +61,7 @@ int main (int argc, char **argv) char **mbuf; prog = *argv; - while ((ret = options ("r:v:", argv, argc, &arg)) != -2) + while ((ret = options ("r:v:m:", argv, argc, &arg)) != -2) { if (ret == 0) { @@ -91,7 +95,7 @@ int main (int argc, char **argv) else { unlink ("keys.tmp"); - key_open (3000000); + key_open (mem_max); repository (cmd, arg, base_path); cmd = 0; } @@ -104,6 +108,10 @@ int main (int argc, char **argv) { base_path = arg; } + else if (ret == 'm') + { + mem_max = 1024*1024*atoi(arg); + } else { logf (LOG_FATAL, "Unknown option '-%s'", arg); @@ -122,6 +130,7 @@ int main (int argc, char **argv) logf (LOG_LOG, "Merge sorting"); mbuf = xmalloc (100000); merge_sort (mbuf, 1, nsections+1); + xfree (mbuf); logf (LOG_LOG, "Input"); key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, "keys1.tmp", 60); exit (0);