=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/calendar/day.c,v retrieving revision 1.20 retrieving revision 1.27 diff -u -r1.20 -r1.27 --- src/usr.bin/calendar/day.c 2005/11/16 16:45:11 1.20 +++ src/usr.bin/calendar/day.c 2013/11/26 13:18:53 1.27 @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.20 2005/11/16 16:45:11 deraadt Exp $ */ +/* $OpenBSD: day.c,v 1.27 2013/11/26 13:18:53 deraadt Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -29,20 +29,6 @@ * SUCH DAMAGE. */ -#ifndef lint -static const char copyright[] = -"@(#) Copyright (c) 1989, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; -#else -static const char rcsid[] = "$OpenBSD: day.c,v 1.20 2005/11/16 16:45:11 deraadt Exp $"; -#endif -#endif /* not lint */ - #include #include @@ -58,6 +44,8 @@ #include "pathnames.h" #include "calendar.h" +extern struct iovec header[]; + #define WEEKLY 1 #define MONTHLY 2 #define YEARLY 3 @@ -90,7 +78,6 @@ static struct fixs fnmonths[13]; /* full national months names */ static struct fixs nmonths[13]; /* short national month names */ - void setnnames(void) { @@ -101,7 +88,7 @@ for (i = 0; i < 7; i++) { tm.tm_wday = i; l = strftime(buf, sizeof(buf), "%a", &tm); - for (; l > 0 && isspace((int)buf[l - 1]); l--) + for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; if (ndays[i].name != NULL) @@ -111,7 +98,7 @@ ndays[i].len = strlen(buf); l = strftime(buf, sizeof(buf), "%A", &tm); - for (; l > 0 && isspace((int)buf[l - 1]); l--) + for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; if (fndays[i].name != NULL) @@ -124,7 +111,7 @@ for (i = 0; i < 12; i++) { tm.tm_mon = i; l = strftime(buf, sizeof(buf), "%b", &tm); - for (; l > 0 && isspace((int)buf[l - 1]); l--) + for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; if (nmonths[i].name != NULL) @@ -134,7 +121,7 @@ nmonths[i].len = strlen(buf); l = strftime(buf, sizeof(buf), "%B", &tm); - for (; l > 0 && isspace((int)buf[l - 1]); l--) + for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; if (fnmonths[i].name != NULL) @@ -203,6 +190,7 @@ len = strlen(date); if (len < 2) return((time_t)-1); + bzero(&tm, sizeof tm); tm.tm_sec = 0; tm.tm_min = 0; /* Avoid getting caught by a timezone shift; set time to noon */ @@ -237,13 +225,13 @@ } #if DEBUG - printf("Mktime: %d %d %d %s\n", (int)mktime(&tm), (int)t, len, + printf("Mktime: %d %lld %d %s\n", (int)mktime(&tm), (long long)t, len, asctime(&tm)); #endif return(mktime(&tm)); } -void +static void adjust_calendar(int *day, int *month) { switch (calendar) { @@ -301,7 +289,7 @@ /* adjust bodun rate */ if (bodun && !bodun_always) - bodun = !(arc4random() % 3); + bodun = !arc4random_uniform(3); /* Easter or Easter depending days */ if (flags & F_SPECIAL)