Updated the CtdlUserGoto() API call to also return the oldest and newest message...
[citadel.git] / citadel / parsedate.y
index e167f59b73ec9d93d9e5f4e60217442a41572474..3166f310698c3140c8b1e9faac3c08ef88903c5c 100644 (file)
@@ -7,7 +7,8 @@
 **  <rsalz@osf.org> and Jim Berets <jberets@bbn.com> in August, 1990.
 **  Further revised (removed obsolete constructs and cleaned up timezone
 **  names) in August, 1991, by Rich.  Paul Eggert <eggert@twinsun.com>
-**  helped in September, 1992.
+**  helped in September, 1992.  Art Cancro <ajc@citadel.org> cleaned
+**  it up for ANSI C in December, 1999.
 **
 **  This grammar has six shift/reduce conflicts.
 **
 /* SUPPRESS 593 on yyerrlab *//* Label was not used */
 /* SUPPRESS 593 on yynewstate *//* Label was not used */
 /* SUPPRESS 595 on yypvt *//* Automatic variable may be used before set */
+
+#include "sysdep.h"
+
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <ctype.h>
-#include <time.h>
 
-int date_lex();
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+
+#include "parsedate.h"
+
+int date_lex(void);
 
 #define yyparse                date_parse
 #define yylex          date_lex
@@ -75,7 +102,7 @@ typedef enum _MERIDIAN {
 **  union, but this is more efficient.  (This routine predates the
 **  yacc %union construct.)
 */
-static char    *yyInput;
+static const char      *yyInput;
 static DSTMODE yyDSTmode;
 static int     yyHaveDate;
 static int     yyHaveRel;
@@ -92,9 +119,7 @@ static time_t        yyRelMonth;
 static time_t  yyRelSeconds;
 
 
-extern struct tm       *localtime();
-
-static void            date_error();
+static void            date_error(char *);
 %}
 
 %union {
@@ -438,19 +463,14 @@ static TABLE      TimezoneTable[] = {
 
 /* ARGSUSED */
 static void
-date_error(s)
-    char       *s;
+date_error(char *s)
 {
     /* NOTREACHED */
 }
 
 
 static time_t
-ToSeconds(Hours, Minutes, Seconds, Meridian)
-    time_t     Hours;
-    time_t     Minutes;
-    time_t     Seconds;
-    MERIDIAN   Meridian;
+ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian)
 {
     if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 61)
        return -1;
@@ -471,15 +491,9 @@ ToSeconds(Hours, Minutes, Seconds, Meridian)
 
 
 static time_t
-Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, dst)
-    time_t     Month;
-    time_t     Day;
-    time_t     Year;
-    time_t     Hours;
-    time_t     Minutes;
-    time_t     Seconds;
-    MERIDIAN   Meridian;
-    DSTMODE    dst;
+Convert(time_t Month, time_t Day, time_t Year,
+       time_t Hours, time_t Minutes, time_t Seconds,
+       MERIDIAN Meridian, DSTMODE dst)
 {
     static int DaysNormal[13] = {
        0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
@@ -533,9 +547,7 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, dst)
 
 
 static time_t
-DSTcorrect(Start, Future)
-    time_t     Start;
-    time_t     Future;
+DSTcorrect(time_t Start, time_t Future)
 {
     time_t     StartDay;
     time_t     FutureDay;
@@ -547,9 +559,7 @@ DSTcorrect(Start, Future)
 
 
 static time_t
-RelativeMonth(Start, RelMonth)
-    time_t     Start;
-    time_t     RelMonth;
+RelativeMonth(time_t Start, time_t RelMonth)
 {
     struct tm  *tm;
     time_t     Month;
@@ -567,9 +577,7 @@ RelativeMonth(Start, RelMonth)
 
 
 static int
-LookupWord(buff, length)
-    char               *buff;
-    register int       length;
+LookupWord(char *buff, register int length)
 {
     register char      *p;
     register char      *q;
@@ -659,7 +667,7 @@ LookupWord(buff, length)
 
 
 int
-date_lex()
+date_lex(void)
 {
     register char      c;
     register char      *p;
@@ -722,13 +730,12 @@ date_lex()
 
 
 time_t
-parsedate(p)
-    char               *p;
+parsedate(const char *p)
 {
-    extern int         date_parse();
+    extern int         date_parse(void);
     time_t             Start;
 
-    yyInput = p;
+    yyInput = p; /* well, its supposed to be const... */
 
     yyYear = 0;
     yyMonth = 0;
@@ -775,9 +782,7 @@ extern int  yydebug;
 
 /* ARGSUSED */
 int
-main(ac, av)
-    int                ac;
-    char       *av[];
+main(int ac, char *av[])
 {
     char       buff[128];
     time_t     d;
@@ -790,7 +795,7 @@ main(ac, av)
     for ( ; ; ) {
        (void)printf("\t> ");
        (void)fflush(stdout);
-       if (gets(buff) == NULL || buff[0] == '\n')
+       if (fgets(buff, sizeof buff, stdin) == NULL || buff[0] == '\n')
            break;
 #if YYDEBUG
        if (strcmp(buff, "yydebug") == 0) {