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

Fixed get_last_text.

parent c653f173
Tue Dec 17 00:52:11 1991 Per Cederqvist (ceder at lysator)
* prot-a-parse-arg-c.awk: Fixed bogus parsing of argument to
get_last_text.
* prot-a-parse.h, prot-a-parse.c (prot_a_parse_time_date): New
function for get_last_text.
* text.c (get_last_text): Rewrote it.
Mon Dec 16 15:32:57 1991 Per Cederqvist (ceder at ruben)
......
#
# $Id: prot-a-parse-arg-c.awk,v 0.4 1991/11/10 19:02:22 linus Exp $
# $Id: prot-a-parse-arg-c.awk,v 0.5 1991/12/17 22:20:58 ceder Exp $
# Copyright (C) 1991 Lysator Academic Computer Association.
#
# This file is part of the LysKOM server.
......@@ -22,7 +22,7 @@
#
# Please mail bug reports to bug-lyskom@lysator.liu.se.
#
# $Id: prot-a-parse-arg-c.awk,v 0.4 1991/11/10 19:02:22 linus Exp $
# $Id: prot-a-parse-arg-c.awk,v 0.5 1991/12/17 22:20:58 ceder Exp $
BEGIN {
printf("/* Don't edit this file - it is generated automatically");
printf(" from\n prot-a-parse-arg-c.awk and fncdef.txt */\n\n");
......@@ -116,17 +116,7 @@ $1 != "#" {
printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n");
}
else if ( $i == "time_date" )
{
printf("\tclient->time.tm_sec = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_min = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_hour = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_mday = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_mon = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_year = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_wday = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_yday = prot_a_parse_long(client);\n");
printf("\tclient->time.tm_isdst = prot_a_parse_long(client);\n");
}
printf("\tprot_a_parse_time_date(client, &client->time);\n");
else
printf("#error in prot-a-parse-arg-c.awk: not ready yet.\n");
......
/*
* $Id: prot-a-parse.c,v 0.8 1991/10/29 14:52:23 linus Exp $
* $Id: prot-a-parse.c,v 0.9 1991/12/17 22:20:57 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* BUG: Not all functions are used, I think. /ceder
*/
static char *rcsid = "$Id: prot-a-parse.c,v 0.8 1991/10/29 14:52:23 linus Exp $";
static char *rcsid = "$Id: prot-a-parse.c,v 0.9 1991/12/17 22:20:57 ceder Exp $";
#include <setjmp.h>
......@@ -289,3 +289,54 @@ prot_a_get_token(Connection *client)
return result;
}
void
prot_a_parse_time_date(Connection *client,
struct tm *result)
{
/* A time never occur inside a string, and a string never occur
inside a time. Thus I use string_parse_pos here instead of
inventing a new variable. Lacgen will allocate variables as
needed... */
switch( client->string_parse_pos )
{
case 0:
result->tm_sec = prot_a_parse_long(client);
client->string_parse_pos = 1;
/* Fall through */
case 1:
result->tm_min = prot_a_parse_long(client);
client->string_parse_pos = 2;
/* Fall through */
case 2:
result->tm_hour = prot_a_parse_long(client);
client->string_parse_pos = 3;
/* Fall through */
case 3:
result->tm_mday = prot_a_parse_long(client);
client->string_parse_pos = 4;
/* Fall through */
case 4:
result->tm_mon = prot_a_parse_long(client);
client->string_parse_pos = 5;
/* Fall through */
case 5:
result->tm_year = prot_a_parse_long(client);
client->string_parse_pos = 6;
/* Fall through */
case 6:
result->tm_wday = prot_a_parse_long(client);
client->string_parse_pos = 7;
/* Fall through */
case 7:
result->tm_yday = prot_a_parse_long(client);
client->string_parse_pos = 8;
/* Fall through */
case 8:
result->tm_isdst = prot_a_parse_long(client);
/* Fall through */
default:
client->string_parse_pos = 0;
}
}
/*
* $Id: prot-a-parse.h,v 0.3 1991/09/15 10:30:08 linus Exp $
* $Id: prot-a-parse.h,v 0.4 1991/12/17 22:20:55 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* $Id: prot-a-parse.h,v 0.3 1991/09/15 10:30:08 linus Exp $
* $Id: prot-a-parse.h,v 0.4 1991/12/17 22:20:55 ceder Exp $
*
*/
extern long
......@@ -54,3 +54,7 @@ prot_a_parse_misc_info(Connection *client,
*/
extern String
prot_a_get_token(Connection *client);
extern void
prot_a_parse_time_date(Connection *client,
struct tm *result);
/*
* $Id: text.c,v 0.13 1991/12/16 23:57:39 ceder Exp $
* $Id: text.c,v 0.14 1991/12/17 22:20:53 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.13 1991/12/16 23:57:39 ceder Exp $";
static char *rcsid = "$Id: text.c,v 0.14 1991/12/17 22:20:53 ceder Exp $";
#include <time.h>
#include <stdlib.h>
......@@ -1911,16 +1911,16 @@ extern Success
get_last_text(time_t time,
Text_no *result)
{
Text_no lower = 1;
Text_no lower = 0;
Text_no higher = query_next_text_num() - 1;
Text_stat *text_stat;
Text_stat *text_stat = NULL;
Text_no try;
Text_no middle;
/*
* We search for the text in the interval [lower, higher]
* (inclusive). Middle is set to the middle (rounded towards
* zero), and we search from there and upward until we find a
* infinity), and we search from there and upward until we find a
* text.
*/
......@@ -1930,7 +1930,7 @@ get_last_text(time_t time,
try = middle;
text_stat = NULL;
while (text_stat == NULL && try <= higher);
while (text_stat == NULL && try <= higher)
text_stat = cached_get_text_stat (try++);
if ( text_stat == NULL )
......@@ -1938,13 +1938,14 @@ get_last_text(time_t time,
else
{
if (time > text_stat->creation_time)
lower = try;
lower = try - 1;
else /* The intervall is "halved" */
higher = middle - 1;
}
}
*result = lower;
return OK;
}
......
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