diff options
author | mpp <mpp@FreeBSD.org> | 1997-01-12 18:35:14 +0000 |
---|---|---|
committer | mpp <mpp@FreeBSD.org> | 1997-01-12 18:35:14 +0000 |
commit | 2494654b020ecbb061d468c7416782d65e925769 (patch) | |
tree | 9a62f1289728b8d8078ca406103c4df8f2678336 /usr.bin/calendar/day.c | |
parent | 7d49859c758fa9ed41003ec7a70af300a9966b70 (diff) | |
download | FreeBSD-src-2494654b020ecbb061d468c7416782d65e925769.zip FreeBSD-src-2494654b020ecbb061d468c7416782d65e925769.tar.gz |
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.
Diffstat (limited to 'usr.bin/calendar/day.c')
-rw-r--r-- | usr.bin/calendar/day.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index 210e8d3..14b9a14 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -155,13 +155,19 @@ settime(now) /* convert Day[/Month][/Year] into unix time (since 1970) * Day: two digits, Month: two digits, Year: digits */ -time_t Mktime (date) - char *date; +time_t Mktime (dp) + char *dp; { + char *date; time_t t; int len; struct tm tm; + date = strdup(dp); + if (date == NULL) { + fprintf(stderr, "calendar: strdup failed in Mktime\n"); + exit(1); + } (void)time(&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, asctime(&tm)); #endif + free(date); return(mktime(&tm)); } |