Commit eb8879bc authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(get_map): Fixed a couple of fence errors.

(local_to_global): Using first_local_no==0 is an error.  Fixed a fence
	error.
parent c4f9e975
/*
* $Id: text.c,v 0.52 1998/08/05 16:14:06 ceder Exp $
* $Id: text.c,v 0.53 1998/08/07 23:17:27 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -29,7 +29,7 @@
*/
static const char *
rcsid = "$Id: text.c,v 0.52 1998/08/05 16:14:06 ceder Exp $";
rcsid = "$Id: text.c,v 0.53 1998/08/07 23:17:27 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -2982,14 +2982,15 @@ sub_footnote( Text_no footnote, /* 'footnote' is no longer a */
* BUG: You should be allowed to get the mapping if it is a letterbox
* which is not unread_is_secret. +++ (Really? I don't think so. /ceder)
*/
extern Success
get_map (Conf_no conf_no,
Local_text_no first_local_no,
unsigned long no_of_texts,
L2g_iterator_as_text_list * result)
extern Success
get_map(Conf_no conf_no,
Local_text_no first_local_no,
unsigned long no_of_texts,
L2g_iterator_as_text_list *result)
{
Conference * conf_c;
Local_text_no highest_wanted_no, highest;
Local_text_no highest;
Local_text_no first_unwanted;
Local_text_no res_first;
int res_nr;
Access acc;
......@@ -2997,9 +2998,9 @@ get_map (Conf_no conf_no,
CHK_LOGIN(FAILURE);
GET_C_STAT(conf_c, conf_no, FAILURE);
acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P);
acc = access_perm(conf_no, conf_c, ACTPERS, ACT_P);
if ( acc <= none )
if (acc <= none)
{
err_stat = conf_no;
kom_errno = KOM_UNDEF_CONF;
......@@ -3015,7 +3016,7 @@ get_map (Conf_no conf_no,
highest = l2g_first_appendable_key(&conf_c->texts) - 1;
if ( first_local_no >= highest )
if (first_local_no > highest)
{
err_stat = first_local_no;
kom_errno = KOM_NO_SUCH_LOCAL_TEXT;
......@@ -3023,54 +3024,59 @@ get_map (Conf_no conf_no,
}
res_first = l2g_next_key(&conf_c->texts, 0);
/* Bug compatibility: accept first_local_no==0 because lyskomd
1.9.0 did so. */
res_first = max(res_first, 1);
res_first = max(res_first, first_local_no);
highest_wanted_no = min(highest, first_local_no + no_of_texts);
first_unwanted = min(highest+1, first_local_no + no_of_texts);
if (highest_wanted_no >= res_first)
res_nr = highest_wanted_no - res_first;
if (first_unwanted >= res_first)
res_nr = first_unwanted - res_first;
else
res_nr = 0;
l2gi_searchsome(result, &conf_c->texts,
res_first, res_first + res_nr - 1);
l2gi_searchsome(result, &conf_c->texts, res_first, res_first + res_nr);
return OK;
}
extern Success
local_to_global (Conf_no conf_no,
Local_text_no first_local_no,
unsigned long no_of_texts,
Text_mapping *result)
extern Success
local_to_global(Conf_no conf_no,
Local_text_no first_local_no,
unsigned long no_of_texts,
Text_mapping *result)
{
Conference * conf_c;
Local_text_no highest_wanted_no, highest;
Local_text_no res_first;
int res_nr;
Access acc;
if (first_local_no == 0)
{
err_stat = first_local_no;
kom_errno = KOM_LOCAL_TEXT_ZERO;
return FAILURE;
}
CHK_LOGIN(FAILURE);
GET_C_STAT(conf_c, conf_no, FAILURE);
acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P);
if ( acc <= none )
if (acc <= none)
{
err_stat = conf_no;
kom_errno = KOM_UNDEF_CONF;
return FAILURE;
}
if ( acc == read_protected )
if (acc == read_protected)
{
err_stat = conf_no;
kom_errno = KOM_ACCESS;
return FAILURE;
}
highest = l2g_first_appendable_key(&conf_c->texts) - 1;
if ( first_local_no >= highest )
if (first_local_no >= l2g_first_appendable_key(&conf_c->texts))
{
err_stat = first_local_no;
kom_errno = KOM_NO_SUCH_LOCAL_TEXT;
......
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