X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetdate.y;h=ce119056a1116e8de0837ab9bbe1d57d8cfb1c9f;hb=ad77a609ccd84b0650cbdc0cda015456c28ce5d7;hp=e77cc1f62d6d3adc126639f41e6d7aa7f48ba37b;hpb=8f16c54c8c8a7ba8826daa774c4229fd1c7adb77;p=gnulib.git diff --git a/lib/getdate.y b/lib/getdate.y index e77cc1f62..ce119056a 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -30,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 @@ -62,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 */ @@ -251,7 +242,7 @@ day : tDAY { yyDayOrdinal = 1; yyDayNumber = $1; } - | tUNUMBER tDAY { + | tUNUMBER tDAY { /* FIXME */ yyDayOrdinal = $1; yyDayNumber = $2; } @@ -288,6 +279,7 @@ date : tUNUMBER '/' tUNUMBER { yyYear = $4; } | tUNUMBER tMONTH { + /* FIXME: `date -d 'next october'' is interpreted as 2 october. */ yyMonth = $2; yyDay = $1; } @@ -323,10 +315,10 @@ relunit : tUNUMBER tMINUTE_UNIT { | tSEC_UNIT { yyRelSeconds++; } - | tSNUMBER tMONTH_UNIT { + | tSNUMBER tMONTH_UNIT { /* FIXME */ yyRelMonth += $1 * $2; } - | tUNUMBER tMONTH_UNIT { + | tUNUMBER tMONTH_UNIT { /* FIXME */ yyRelMonth += $1 * $2; } | tMONTH_UNIT { @@ -585,10 +577,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 (); @@ -621,7 +617,7 @@ Convert (Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) Year += 1900; DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 29 : 28; - if (Year < EPOCH || Year > 1999 + if (Year < EPOCH || Year > 2037 || Month < 1 || Month > 12 /* Lint fluff: "conversion from long may lose accuracy" */ || Day < 1 || Day > DaysInMonth[(int)--Month]) @@ -962,11 +958,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)