summaryrefslogtreecommitdiffstats
path: root/usr.bin/ncal/ncal.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-03-22 00:38:46 +0000
committerache <ache@FreeBSD.org>2001-03-22 00:38:46 +0000
commit1cd25e11017f22836e28d0853d69dada03cba615 (patch)
tree04ecb580f123a1c21ff7f9dc32286a1144b0a00e /usr.bin/ncal/ncal.c
parentd993b34b6d31778f0b7462c224f7c5405979b7c7 (diff)
downloadFreeBSD-src-1cd25e11017f22836e28d0853d69dada03cba615.zip
FreeBSD-src-1cd25e11017f22836e28d0853d69dada03cba615.tar.gz
Properly deal with one char weekdays
Diffstat (limited to 'usr.bin/ncal/ncal.c')
-rw-r--r--usr.bin/ncal/ncal.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/ncal/ncal.c b/usr.bin/ncal/ncal.c
index 0ff3576..3bf1095 100644
--- a/usr.bin/ncal/ncal.c
+++ b/usr.bin/ncal/ncal.c
@@ -740,16 +740,20 @@ mkmonthb(int y, int m, int jd_flag, struct monthlines *mlines)
void
mkweekdays(struct weekdays *wds)
{
- int i;
+ int i, len;
struct tm tm;
+ char buf[20];
memset(&tm, 0, sizeof(tm));
for (i = 0; i != 7; i++) {
tm.tm_wday = (i+1) % 7;
- strftime(wds->names[i], 4, "%a", &tm);
- wds->names[i][2] = ' ';
- wds->names[i][3] = '\0';
+ strftime(buf, sizeof(buf), "%a", &tm);
+ len = strlen(buf);
+ if (len > 2)
+ len = 2;
+ strcpy(wds->names[i], " ");
+ strncpy(wds->names[i] + 2 - len, buf, len);
}
}
OpenPOWER on IntegriCloud