Commit 953af2ad authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(init_cache): The local loop variable 'i' must be a long, so that a

Text_no fits.  The local variables done, read_text_no and read_conf_no
are now of type Bool (not int).  The local variable c is an int, so
that it can safely be compared against EOF.  Call restart_kom if an
unknown deletion block is found in the data file.
parent cfcbe5e3
/*
* $Id: simple-cache.c,v 0.58 1996/07/28 23:43:42 ceder Exp $
* $Id: simple-cache.c,v 0.59 1996/07/29 00:04:47 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -33,7 +33,7 @@
* New save algorithm by ceder.
*/
static char *rcsid = "$Id: simple-cache.c,v 0.58 1996/07/28 23:43:42 ceder Exp $";
static char *rcsid = "$Id: simple-cache.c,v 0.59 1996/07/29 00:04:47 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -1991,14 +1991,17 @@ setup_small_conf(Conf_no conf_no,
extern Success
init_cache(void)
{
int i;
long i;
Cache_node *node;
Conference tmp_conf;
Person tmp_pers;
Text_stat tmp_text;
long datafile_version;
long pos, num;
char done, read_text_no, read_conf_no, c;
Bool done;
Bool read_text_no;
Bool read_conf_no;
int c;
pers_mcb = create_cache_node_mcb(100, MAX_CONF);
conf_mcb = create_cache_node_mcb(100, MAX_CONF);
......@@ -2079,9 +2082,9 @@ init_cache(void)
* Read conferences
*/
done = 0;
read_text_no = 0;
read_conf_no = 0;
done = FALSE;
read_text_no = FALSE;
read_conf_no = FALSE;
for ( i = 1; !done ; i++ ) /* CONFS */
{
......@@ -2089,7 +2092,7 @@ init_cache(void)
switch(c = getc(file_a))
{
case EOF:
done = 1;
done = TRUE;
break;
case '@':
......@@ -2104,12 +2107,12 @@ init_cache(void)
case 'C':
highest_conf_no = fparse_long(file_a);
next_free_num = highest_conf_no;
read_conf_no = 1;
read_conf_no = TRUE;
break;
case 'T':
highest_text_no = fparse_long(file_a);
next_text_num = highest_text_no;
read_text_no = 1;
read_text_no = TRUE;
break;
default:
restart_kom("init_cache(): Bad number in database\n");
......@@ -2149,6 +2152,9 @@ init_cache(void)
node->pos = -1;
}
break;
default:
restart_kom("init_cache(): bad remove block in data file\n");
}
......@@ -2168,7 +2174,7 @@ init_cache(void)
if (num < 1)
{
restart_kom("ERROR: init_cache(), bad conf_no %ld"
" at record %d\n",
" at record %ld\n",
num, i);
}
......@@ -2183,7 +2189,7 @@ init_cache(void)
node->pos = pos;
if ( fparse_conference(file_a, &tmp_conf) != OK )
restart_kom("init_cache(): fparse_conference(%d) failed.\n",
restart_kom("init_cache(): fparse_conference(%ld) failed.\n",
i);
node->size = ftell(file_a) - node->pos;
......@@ -2207,7 +2213,7 @@ init_cache(void)
node->pos = pos;
if ( fparse_person(file_a, &tmp_pers) != OK )
restart_kom("init_cache: fparse_person failed. i == %d\n", i);
restart_kom("init_cache: fparse_person failed. i==%ld\n", i);
node->size = ftell(file_a) - node->pos;
clear_person(&tmp_pers);
......@@ -2231,7 +2237,7 @@ init_cache(void)
node->pos = pos;
if ( fparse_text_stat(file_a, &tmp_text) != OK )
restart_kom("init_cache(): fparse_text_stat failed. i == %d\n",
restart_kom("init_cache(): fparse_text_stat failed. i==%ld\n",
i);
node->size = ftell(file_a) - node->pos;
......@@ -2239,13 +2245,13 @@ init_cache(void)
break;
default:
restart_kom("init_cache(): Unknown key '%c' in data file\n",
restart_kom("init_cache(): Unknown key chr(%d) in data file\n",
c);
break;
}
}
if (read_conf_no == 0 || read_text_no == 0)
if (read_conf_no == FALSE || read_text_no == FALSE)
{
restart_kom("init_cache(): highest text or conf no not read!\n");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment