Fix calendar so that you can run it like:

calendar -t 0101 -f file

Previously calendar's time processing routine directly
modified the "0101" argument" which confused getopt.
The time routines now make a copy of the argument
to mess with.
This commit is contained in:
Mike Pritchard 1997-01-12 18:35:14 +00:00
parent 225e93b66d
commit b82b4e07ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=21615

View file

@ -155,13 +155,19 @@ settime(now)
/* convert Day[/Month][/Year] into unix time (since 1970) /* convert Day[/Month][/Year] into unix time (since 1970)
* Day: two digits, Month: two digits, Year: digits * Day: two digits, Month: two digits, Year: digits
*/ */
time_t Mktime (date) time_t Mktime (dp)
char *date; char *dp;
{ {
char *date;
time_t t; time_t t;
int len; int len;
struct tm tm; struct tm tm;
date = strdup(dp);
if (date == NULL) {
fprintf(stderr, "calendar: strdup failed in Mktime\n");
exit(1);
}
(void)time(&t); (void)time(&t);
tp = localtime(&t); tp = localtime(&t);
@ -198,6 +204,7 @@ time_t Mktime (date)
printf("Mktime: %d %d %d %s\n", (int)mktime(&tm), (int)t, len, printf("Mktime: %d %d %d %s\n", (int)mktime(&tm), (int)t, len,
asctime(&tm)); asctime(&tm));
#endif #endif
free(date);
return(mktime(&tm)); return(mktime(&tm));
} }