projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New file to override autoconf's AC_SEARCH_LIBS.
[gnulib.git]
/
lib
/
getdate.y
diff --git
a/lib/getdate.y
b/lib/getdate.y
index
9f8f95f
..
3807e2f
100644
(file)
--- a/
lib/getdate.y
+++ b/
lib/getdate.y
@@
-28,6
+28,10
@@
#include <stdio.h>
#include <ctype.h>
#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
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
@@
-706,7
+710,7
@@
LookupWord (buff)
/* Make it lowercase. */
for (p = buff; *p; p++)
/* 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)
*p = tolower (*p);
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0)
@@
-787,7
+791,7
@@
LookupWord (buff)
}
/* Military timezones. */
}
/* 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)
{
for (tp = MilitaryTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0)
@@
-818,7
+822,7
@@
LookupWord (buff)
static int
yylex ()
{
static int
yylex ()
{
- register char c;
+ register
unsigned
char c;
register char *p;
char buff[20];
int Count;
register char *p;
char buff[20];
int Count;
@@
-826,7
+830,7
@@
yylex ()
for (;;)
{
for (;;)
{
- while (ISSPACE (*yyInput))
+ while (ISSPACE (
(unsigned char)
*yyInput))
yyInput++;
if (ISDIGIT (c = *yyInput) || c == '-' || c == '+')
yyInput++;
if (ISDIGIT (c = *yyInput) || c == '-' || c == '+')
@@
-877,8
+881,7
@@
yylex ()
/* Yield A - B, measured in seconds. */
static long
/* 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);
{
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
@@
-906,12
+909,15
@@
get_date (const char *p, const time_t *now)
yyInput = p;
Start = now ? *now : time ((time_t *) NULL);
tmp = localtime (&Start);
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;
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;
yyMeridian = MER24;
yyRelSeconds = 0;
yyRelMinutes = 0;
@@
-947,7
+953,6
@@
get_date (const char *p, const time_t *now)
tm.tm_hour += yyRelHour;
tm.tm_min += yyRelMinutes;
tm.tm_sec += yyRelSeconds;
tm.tm_hour += yyRelHour;
tm.tm_min += yyRelMinutes;
tm.tm_sec += yyRelSeconds;
- tm.tm_isdst = -1;
tm0 = tm;
Start = mktime (&tm);
tm0 = tm;
Start = mktime (&tm);
@@
-994,7
+999,11
@@
get_date (const char *p, const time_t *now)
if (yyHaveZone)
{
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;
if ((Start + delta < Start) != (delta < 0))
return -1; /* time_t overflow */
Start += delta;