aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2002-03-10 14:54:59 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2002-03-10 14:54:59 +0000
commitdfe8796660bc689de3b25dad247d0a25b39b10fb (patch)
tree5a37935417a263b3a342664ffc141862e800ea05 /usr.bin
parent8277f29174110d1e724f5b72921f7e2ac9cb3bb8 (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/calendar/day.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c
index 2216b56d84c8..3f8ab25a3ab5 100644
--- a/usr.bin/calendar/day.c
+++ b/usr.bin/calendar/day.c
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <string.h>
#include <time.h>
#include "pathnames.h"
@@ -140,7 +139,7 @@ void
settime(now)
time_t now;
{
- char *oldl;
+ char *oldl, *lbufp;
tp = localtime(&now);
if ( isleap(tp->tm_year + 1900) ) {
@@ -154,10 +153,15 @@ settime(now)
offset = tp->tm_wday == 5 ? 3 : 1;
header[5].iov_base = dayname;
- oldl = setlocale(LC_TIME, NULL);
+ oldl = NULL;
+ lbufp = setlocale(LC_TIME, NULL);
+ if (lbufp != NULL && (oldl = strdup(lbufp)) == NULL)
+ errx(1, "cannot allocate memory");
(void) setlocale(LC_TIME, "C");
header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", tp);
- (void) setlocale(LC_TIME, oldl);
+ (void) setlocale(LC_TIME, (oldl != NULL ? oldl : ""));
+ if (oldl != NULL)
+ free(oldl);
setnnames();
}