Commit 49ca1410 authored by Per Cederqvist's avatar Per Cederqvist

(greater): Added const qualifier.

(find_previous_text_no): Fixed the returned error status.
parent 261258c9
/* /*
* $Id: text.c,v 0.55 1998/08/09 19:06:50 ceder Exp $ * $Id: text.c,v 0.56 1998/10/22 22:08:47 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association. * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
*/ */
static const char * static const char *
rcsid = "$Id: text.c,v 0.55 1998/08/09 19:06:50 ceder Exp $"; rcsid = "$Id: text.c,v 0.56 1998/10/22 22:08:47 ceder Exp $";
#include "rcs.h" #include "rcs.h"
USE(rcsid); USE(rcsid);
...@@ -2439,8 +2439,8 @@ delete_text( Text_no text_no ) ...@@ -2439,8 +2439,8 @@ delete_text( Text_no text_no )
/* Return TRUE if ``a'' is greater than ``b'. */ /* Return TRUE if ``a'' is greater than ``b'. */
static Bool static Bool
greater(struct tm *a, greater(const struct tm *a,
struct tm *b) const struct tm *b)
{ {
if (a->tm_year < b->tm_year) if (a->tm_year < b->tm_year)
return FALSE; return FALSE;
...@@ -2485,7 +2485,6 @@ extern Success ...@@ -2485,7 +2485,6 @@ extern Success
get_last_text(struct tm *wanted_time, get_last_text(struct tm *wanted_time,
Text_no *result) Text_no *result)
{ {
/* FIXME: this looks bogus */
struct tm *texttime; struct tm *texttime;
Text_no lower = 0; Text_no lower = 0;
Text_no higher = query_next_text_num() - 1; Text_no higher = query_next_text_num() - 1;
...@@ -2506,6 +2505,9 @@ get_last_text(struct tm *wanted_time, ...@@ -2506,6 +2505,9 @@ get_last_text(struct tm *wanted_time,
try = middle; try = middle;
text_stat = NULL; text_stat = NULL;
/* FIXME: Once there is a more efficient structure that maps
Text_nos to the internal cache_node this loop could
probably be rewritten in a more efficient way. */
while (text_stat == NULL && try <= higher) while (text_stat == NULL && try <= higher)
text_stat = cached_get_text_stat (try++); text_stat = cached_get_text_stat (try++);
...@@ -2516,7 +2518,7 @@ get_last_text(struct tm *wanted_time, ...@@ -2516,7 +2518,7 @@ get_last_text(struct tm *wanted_time,
texttime = localtime(&text_stat->creation_time); texttime = localtime(&text_stat->creation_time);
if (greater(wanted_time, texttime)) if (greater(wanted_time, texttime))
lower = try - 1; lower = try - 1;
else /* The intervall is "halved" */ else
higher = middle - 1; higher = middle - 1;
} }
} }
...@@ -2564,8 +2566,8 @@ find_previous_text_no (Text_no start, ...@@ -2564,8 +2566,8 @@ find_previous_text_no (Text_no start,
{ {
Text_stat *text_s; Text_stat *text_s;
Text_no next_tno; Text_no next_tno;
const Text_no saved_start = start;
err_stat = start;
if (start > (next_tno = query_next_text_num())) if (start > (next_tno = query_next_text_num()))
start = next_tno; start = next_tno;
...@@ -2580,6 +2582,7 @@ find_previous_text_no (Text_no start, ...@@ -2580,6 +2582,7 @@ find_previous_text_no (Text_no start,
} }
kom_errno = KOM_NO_SUCH_TEXT; kom_errno = KOM_NO_SUCH_TEXT;
err_stat = saved_start;
return FAILURE; return FAILURE;
} }
......
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