X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetdate.y;h=78d3a75dad338ac673161bf034abcaab9e50a17c;hb=63f4e38fff9d2458d63ead4a769cfd3dd3e99490;hp=1861c9c73c042eb7e79e77660699813d4c3823c2;hpb=70317255148827cb00dee77a1afe42e4ee6703fb;p=gnulib.git diff --git a/lib/getdate.y b/lib/getdate.y index 1861c9c73..78d3a75da 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -14,11 +14,7 @@ /* SUPPRESS 288 on yyerrlab *//* Label unused */ #ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) #include -#else -#include "config.h" -#endif #endif /* Since the code of getdate.y is not included in the Emacs executable @@ -34,20 +30,11 @@ #include #include -/* The code at the top of get_date which figures out the offset of the - current time zone checks various CPP symbols to see if special - tricks are need, but defaults to using the gettimeofday system call. - Include if that will be used. */ - #if defined (vms) - #include #include - #else - #include - #ifdef TIME_WITH_SYS_TIME #include #include @@ -66,12 +53,12 @@ #if defined (HAVE_SYS_TIMEB_H) #include #else -/* -** We use the obsolete `struct timeb' as part of our interface! -** Since the system doesn't have it, we define it here; -** our callers must do likewise. -*/ -struct timeb { + +/* get_date uses the obsolete `struct timeb' in its interface! FIXME. + Since some systems don't have it, we define it here; + callers must do likewise. */ +struct timeb + { time_t time; /* Seconds since the epoch */ unsigned short millitm; /* Field not used */ short timezone; /* Minutes west of GMT */ @@ -112,7 +99,7 @@ static int yyerror (); ** An entry in the lexical lookup table. */ typedef struct _TABLE { - char *name; + const char *name; int type; time_t value; } TABLE; @@ -589,10 +576,14 @@ ToSeconds (Hours, Minutes, Seconds, Meridian) case MERam: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return (Hours * 60L + Minutes) * 60L + Seconds; case MERpm: if (Hours < 1 || Hours > 12) return -1; + if (Hours == 12) + Hours = 0; return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; default: abort (); @@ -966,11 +957,13 @@ main (ac, av) int ac; char *av[]; { - char buff[128]; - time_t d; + char buff[MAX_BUFF_LEN + 1]; + time_t d; (void)printf ("Enter date, or blank line to exit.\n\t> "); (void)fflush (stdout); + + buff[MAX_BUFF_LEN] = 0; while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) { d = get_date (buff, (struct timeb *)NULL); if (d == -1)