Quiet a compiler warning.

This commit is contained in:
Todd C. Miller
2010-06-14 10:56:01 -04:00
parent 3430618c78
commit 848b636f24
2 changed files with 58 additions and 66 deletions

View File

@@ -918,34 +918,31 @@ time_t
get_date(p) get_date(p)
char *p; char *p;
{ {
struct tm *tm, gmt; struct tm *tm, *gmt, gmtbuf;
time_t Start; time_t Start;
time_t tod; time_t tod;
time_t now; time_t now;
time_t timezone; time_t timezone;
yyInput = p; yyInput = p;
{
struct tm *gmt_ptr;
/* XXX - eliminate timeb */
(void)time (&now); (void)time (&now);
gmt_ptr = gmtime (&now); gmt = gmtime (&now);
if (gmt_ptr != NULL) if (gmt != NULL)
{ {
/* Make a copy, in case localtime modifies *tm (I think /* Make a copy, in case localtime modifies *tm (I think
that comment now applies to *gmt_ptr, but I am too that comment now applies to *gmt, but I am too
lazy to dig into how gmtime and locatime allocate the lazy to dig into how gmtime and locatime allocate the
structures they return pointers to). */ structures they return pointers to). */
gmt = *gmt_ptr; gmtbuf = *gmt;
gmt = &gmtbuf;
} }
if (! (tm = localtime (&now))) if (! (tm = localtime (&now)))
return -1; return -1;
if (gmt_ptr != NULL) if (gmt != NULL)
timezone = difftm (&gmt, tm) / 60; timezone = difftm (gmt, tm) / 60;
else else
/* We are on a system like VMS, where the system clock is /* We are on a system like VMS, where the system clock is
in local time and the system has no concept of timezones. in local time and the system has no concept of timezones.
@@ -956,7 +953,6 @@ get_date(p)
if(tm->tm_isdst) if(tm->tm_isdst)
timezone += 60; timezone += 60;
}
tm = localtime(&now); tm = localtime(&now);
yyYear = tm->tm_year + 1900; yyYear = tm->tm_year + 1900;
@@ -1020,7 +1016,7 @@ main(ac, av)
(void)printf("Enter date, or blank line to exit.\n\t> "); (void)printf("Enter date, or blank line to exit.\n\t> ");
(void)fflush(stdout); (void)fflush(stdout);
while (gets(buff) && buff[0]) { while (gets(buff) && buff[0]) {
d = get_date(buff, (struct timeb *)NULL); d = get_date(buff);
if (d == -1) if (d == -1)
(void)printf("Bad format - couldn't convert.\n"); (void)printf("Bad format - couldn't convert.\n");
else else
@@ -1032,7 +1028,7 @@ main(ac, av)
/* NOTREACHED */ /* NOTREACHED */
} }
#endif /* defined(TEST) */ #endif /* defined(TEST) */
#line 984 "y.tab.c" #line 980 "y.tab.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) || defined(__STDC__)
static int yygrowstack(void) static int yygrowstack(void)
@@ -1527,7 +1523,7 @@ case 41:
yyval.Meridian = yyvsp[0].Meridian; yyval.Meridian = yyvsp[0].Meridian;
} }
break; break;
#line 1479 "y.tab.c" #line 1475 "y.tab.c"
} }
yyssp -= yym; yyssp -= yym;
yystate = *yyssp; yystate = *yyssp;

View File

@@ -851,34 +851,31 @@ time_t
get_date(p) get_date(p)
char *p; char *p;
{ {
struct tm *tm, gmt; struct tm *tm, *gmt, gmtbuf;
time_t Start; time_t Start;
time_t tod; time_t tod;
time_t now; time_t now;
time_t timezone; time_t timezone;
yyInput = p; yyInput = p;
{
struct tm *gmt_ptr;
/* XXX - eliminate timeb */
(void)time (&now); (void)time (&now);
gmt_ptr = gmtime (&now); gmt = gmtime (&now);
if (gmt_ptr != NULL) if (gmt != NULL)
{ {
/* Make a copy, in case localtime modifies *tm (I think /* Make a copy, in case localtime modifies *tm (I think
that comment now applies to *gmt_ptr, but I am too that comment now applies to *gmt, but I am too
lazy to dig into how gmtime and locatime allocate the lazy to dig into how gmtime and locatime allocate the
structures they return pointers to). */ structures they return pointers to). */
gmt = *gmt_ptr; gmtbuf = *gmt;
gmt = &gmtbuf;
} }
if (! (tm = localtime (&now))) if (! (tm = localtime (&now)))
return -1; return -1;
if (gmt_ptr != NULL) if (gmt != NULL)
timezone = difftm (&gmt, tm) / 60; timezone = difftm (gmt, tm) / 60;
else else
/* We are on a system like VMS, where the system clock is /* We are on a system like VMS, where the system clock is
in local time and the system has no concept of timezones. in local time and the system has no concept of timezones.
@@ -889,7 +886,6 @@ get_date(p)
if(tm->tm_isdst) if(tm->tm_isdst)
timezone += 60; timezone += 60;
}
tm = localtime(&now); tm = localtime(&now);
yyYear = tm->tm_year + 1900; yyYear = tm->tm_year + 1900;
@@ -953,7 +949,7 @@ main(ac, av)
(void)printf("Enter date, or blank line to exit.\n\t> "); (void)printf("Enter date, or blank line to exit.\n\t> ");
(void)fflush(stdout); (void)fflush(stdout);
while (gets(buff) && buff[0]) { while (gets(buff) && buff[0]) {
d = get_date(buff, (struct timeb *)NULL); d = get_date(buff);
if (d == -1) if (d == -1)
(void)printf("Bad format - couldn't convert.\n"); (void)printf("Bad format - couldn't convert.\n");
else else