Commit 3a025f09 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(greater): New function.

(get_last_text): Use it. Maybe it now finally works?
parent a372004f
/*
* $Id: text.c,v 0.31 1994/06/29 23:28:30 ceder Exp $
* $Id: text.c,v 0.32 1994/06/30 07:06:42 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994 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.31 1994/06/29 23:28:30 ceder Exp $";
static char *rcsid = "$Id: text.c,v 0.32 1994/06/30 07:06:42 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -2021,6 +2021,45 @@ delete_text( Text_no text_no )
return do_delete_text(text_no, text_s);
}
/* Return TRUE if ``a'' is greater than ``b'. */
static Bool
greater(struct tm *a,
struct tm *b)
{
if (a->tm_year < b->tm_year)
return FALSE;
if (a->tm_year > b->tm_year)
return TRUE;
if (a->tm_mon < b->tm_mon)
return FALSE;
if (a->tm_mon > b->tm_mon)
return TRUE;
if (a->tm_mday < b->tm_mday)
return FALSE;
if (a->tm_mday > b->tm_mday)
return TRUE;
if (a->tm_hour < b->tm_hour)
return FALSE;
if (a->tm_hour > b->tm_hour)
return TRUE;
if (a->tm_min < b->tm_min )
return FALSE;
if (a->tm_min > b->tm_min )
return TRUE;
if (a->tm_sec < b->tm_sec)
return FALSE;
if (a->tm_sec > b->tm_sec)
return TRUE;
/* ``a'' is not greater if it is equal to ``b''. */
return FALSE;
}
/*
* Lookup a text according to creation-time.
* The text-no of the text created closest before WANTED_TIME is returned.
......@@ -2058,15 +2097,8 @@ get_last_text(struct tm *wanted_time,
else
{
texttime = localtime(&text_stat->creation_time);
if (wanted_time->tm_year > texttime->tm_year
|| wanted_time->tm_mon > texttime->tm_mon
|| wanted_time->tm_mday > texttime->tm_mday
|| wanted_time->tm_hour > texttime->tm_hour
|| wanted_time->tm_min > texttime->tm_min
|| wanted_time->tm_sec > texttime->tm_sec)
{
if (greater(wanted_time, texttime))
lower = try - 1;
}
else /* The intervall is "halved" */
higher = middle - 1;
}
......
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