#ifdef HAVE_CONFIG_H
# include <config.h>
-# ifdef FORCE_ALLOCA_H
+# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# endif
#endif
#include <stdio.h>
#include <ctype.h>
+#if HAVE_STDLIB_H
+# include <stdlib.h> /* for `free'; used by Bison 1.27 */
+#endif
+
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# include <string.h>
#endif
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __attribute__(x)
+#endif
+
+#ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#endif
+
/* Some old versions of bison generate parsers that use bcopy.
That loses on systems that don't provide the function, so we have
to redefine it here. */
{ "thurs", tDAY, 4 },
{ "friday", tDAY, 5 },
{ "saturday", tDAY, 6 },
- { NULL }
+ { NULL, 0, 0 }
};
/* Time units table. */
{ "min", tMINUTE_UNIT, 1 },
{ "second", tSEC_UNIT, 1 },
{ "sec", tSEC_UNIT, 1 },
- { NULL }
+ { NULL, 0, 0 }
};
/* Assorted relative-time words. */
{ "eleventh", tUNUMBER, 11 },
{ "twelfth", tUNUMBER, 12 },
{ "ago", tAGO, 1 },
- { NULL }
+ { NULL, 0, 0 }
};
/* The timezone table. */
{ "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
{ "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
{ "idle", tZONE, -HOUR (12) }, /* International Date Line East */
- { NULL }
+ { NULL, 0, 0 }
};
/* Military timezone table. */
{ "x", tZONE, HOUR (-11) },
{ "y", tZONE, HOUR (-12) },
{ "z", tZONE, HOUR ( 0) },
- { NULL }
+ { NULL, 0, 0 }
};
\f
/* ARGSUSED */
static int
yyerror (s)
- char *s;
+ char *s ATTRIBUTE_UNUSED;
{
return 0;
}
/* Make it lowercase. */
for (p = buff; *p; p++)
- if (ISUPPER (*p))
+ if (ISUPPER ((unsigned char) *p))
*p = tolower (*p);
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
}
/* Military timezones. */
- if (buff[1] == '\0' && ISALPHA (*buff))
+ if (buff[1] == '\0' && ISALPHA ((unsigned char) *buff))
{
for (tp = MilitaryTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0)
static int
yylex ()
{
- register char c;
+ register unsigned char c;
register char *p;
char buff[20];
int Count;
for (;;)
{
- while (ISSPACE (*yyInput))
+ while (ISSPACE ((unsigned char) *yyInput))
yyInput++;
if (ISDIGIT (c = *yyInput) || c == '-' || c == '+')
/* Yield A - B, measured in seconds. */
static long
-difftm (a, b)
- struct tm *a, *b;
+difftm (struct tm *a, struct tm *b)
{
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
yyInput = p;
Start = now ? *now : time ((time_t *) NULL);
tmp = localtime (&Start);
+ if (!tmp)
+ return -1;
yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
yyMonth = tmp->tm_mon + 1;
yyDay = tmp->tm_mday;
yyHour = tmp->tm_hour;
yyMinutes = tmp->tm_min;
yySeconds = tmp->tm_sec;
+ tm.tm_isdst = tmp->tm_isdst;
yyMeridian = MER24;
yyRelSeconds = 0;
yyRelMinutes = 0;
tm.tm_hour += yyRelHour;
tm.tm_min += yyRelMinutes;
tm.tm_sec += yyRelSeconds;
- tm.tm_isdst = -1;
tm0 = tm;
Start = mktime (&tm);
if (yyHaveZone)
{
- long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
+ long delta;
+ struct tm *gmt = gmtime (&Start);
+ if (!gmt)
+ return -1;
+ delta = yyTimezone * 60L + difftm (&tm, gmt);
if ((Start + delta < Start) != (delta < 0))
return -1; /* time_t overflow */
Start += delta;