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

Don't allow texts to be comments/footnotes to themselves (since that

triggers a bug).
parent 436e02ff
Sat May 23 19:57:17 1992 Per Cederqvist (ceder@robin)
* text.c (add_comment, add_footnote): Disallow texts to be
comments/footnotes to themselves, since that would trigger a bug
(the misc-list that is created would be erronous. A proper
misc-info-list handling package should be written instead.
Tue May 19 01:06:50 1992 Per Cederqvist (ceder@lysator)
* Makefile (tags): Search libraries/libisc-new.
......
/*
* $Id: text.c,v 0.16 1992/02/26 18:44:55 ceder Exp $
* $Id: text.c,v 0.17 1992/05/23 18:03:35 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* All atomic calls that deals with texts.
*/
static char *rcsid = "$Id: text.c,v 0.16 1992/02/26 18:44:55 ceder Exp $";
static char *rcsid = "$Id: text.c,v 0.17 1992/05/23 18:03:35 ceder Exp $";
#include <time.h>
#include <stdlib.h>
......@@ -2120,19 +2120,30 @@ sub_recipient( Text_no text_no,
* Add a comment-link between two existing texts.
*/
extern Success
add_comment( Text_no comment,
Text_no comment_to )
add_comment(Text_no comment,
Text_no comment_to)
{
Text_stat *text_s, *parent_s;
Text_stat *child_s, *parent_s;
CHK_LOGIN(FAILURE);
GET_T_STAT(text_s, comment, FAILURE);
/* The following code can not cope with a text that is a comment
to itself. That is considered to be a bug. Work around it for
now, until a proper misc-info-list handling package is written.
FIXME +++ /// */
if (comment == comment_to)
{
kom_errno = KOM_INDEX_OUT_OF_RANGE;
return FAILURE;
}
GET_T_STAT(child_s, comment, FAILURE);
GET_T_STAT(parent_s, comment_to, FAILURE);
if ( check_comm(parent_s) != OK )
return FAILURE;
if ( !text_read_access(comment, text_s) )
if ( !text_read_access(comment, child_s) )
{
kom_errno = KOM_NO_SUCH_TEXT;
return FAILURE;
......@@ -2148,12 +2159,12 @@ add_comment( Text_no comment,
if ( do_add_comment(comment, comment_to) != OK)
return FAILURE;
if ( text_s->author != ACTPERS )
ADD_MISC(text_s, sent_by, sender, ACTPERS);
if ( child_s->author != ACTPERS )
ADD_MISC(child_s, sent_by, sender, ACTPERS);
ADD_MISC(text_s, sent_at, sent_at, time(NULL));
ADD_MISC(child_s, sent_at, sent_at, time(NULL));
mark_text_as_changed( comment );
mark_text_as_changed (comment);
return OK;
}
......@@ -2222,6 +2233,16 @@ add_footnote( Text_no footnote,
GET_T_STAT(text_s, footnote, FAILURE);
GET_T_STAT(parent_s, footnote_to, FAILURE);
/* The following code can not cope with a text that is a footnote
to itself. That is considered to be a bug. Work around it for
now, until a proper misc-info-list handling package is written.
FIXME /// +++ */
if (footnote == footnote_to)
{
kom_errno = KOM_INDEX_OUT_OF_RANGE;
return FAILURE;
}
if ( !text_read_access(footnote, text_s)
|| !text_read_access(footnote_to, parent_s) )
{
......
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