diff --git a/src/server/ChangeLog b/src/server/ChangeLog
index 4124da8c9b5345cfe4575169c9b2ccfb28c25669..39626b54de4d7a9f0e4904cb6db8ee5004bec114 100644
--- a/src/server/ChangeLog
+++ b/src/server/ChangeLog
@@ -1,5 +1,11 @@
 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)
diff --git a/src/server/prot-a-parse-arg-c.awk b/src/server/prot-a-parse-arg-c.awk
index 6136612cbcdc7fc487bf4ac0d619c1fed4c7f3e3..fb3d94877f328f5d324a9c6259c20b8d6cdcb903 100644
--- a/src/server/prot-a-parse-arg-c.awk
+++ b/src/server/prot-a-parse-arg-c.awk
@@ -1,5 +1,5 @@
 #
-# $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");
 
diff --git a/src/server/prot-a-parse.c b/src/server/prot-a-parse.c
index 007f0fc7653cfa93f720108aeba7549587a22086..4ff3d030263be4822cb0134a0d83656d3eb78d7c 100644
--- a/src/server/prot-a-parse.c
+++ b/src/server/prot-a-parse.c
@@ -1,5 +1,5 @@
 /*
- * $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;
+    }
+}
+
diff --git a/src/server/prot-a-parse.h b/src/server/prot-a-parse.h
index f3f6a444d902958e763ec5c35788eaaefdc82897..70f1ae489e664eb1002f542468adcee64dd9a0b1 100644
--- a/src/server/prot-a-parse.h
+++ b/src/server/prot-a-parse.h
@@ -1,5 +1,5 @@
 /*
- * $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);
diff --git a/src/server/text.c b/src/server/text.c
index ef6b3a0b50320f0a242a6735f63f93e8735b2d49..949d19640159eac64058f4885dcbee9857135c50 100644
--- a/src/server/text.c
+++ b/src/server/text.c
@@ -1,5 +1,5 @@
 /*
- * $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,21 +1930,22 @@ get_last_text(time_t   time,
 	try = middle;
 	text_stat = NULL;
 
-        while (text_stat == NULL && try <= higher);
-	text_stat = cached_get_text_stat (try++);
+        while (text_stat == NULL && try <= higher)
+	    text_stat = cached_get_text_stat (try++);
 
 	if ( text_stat == NULL )
 	    higher = middle - 1;
 	else
 	{
 	    if (time > text_stat->creation_time)
-		lower = try;
+		lower = try - 1;
 	    else		/* The intervall is "halved" */
 		higher = middle - 1;
 	}
     }
 
     *result = lower;
+
     return OK;
 }