summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2019-01-29 20:08:57 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2019-01-29 20:08:57 +0000
commitefb37e7a5764baf8201f10e19e71303463e8d896 (patch)
tree7dfe09f31edf6b6921f109dd832fa557e73bb552 /usr.bin
parent72321dba32090e2724bb7b9722a03d8e81e04fb3 (diff)
Fix a bug with -flag where later events may be shown when they should not be.
The problem is caused by the special handling of Friday, where calendar will show the upcoming events for the weeked as well. This change disables the special handling of Friday for the -B option, as was already done for -A. From Andy Bradford.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/calendar/calendar.c4
-rw-r--r--usr.bin/calendar/calendar.h3
-rw-r--r--usr.bin/calendar/day.c4
3 files changed, 4 insertions, 7 deletions
diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c
index cc20f596bbc..25687e7e50d 100644
--- a/usr.bin/calendar/calendar.c
+++ b/usr.bin/calendar/calendar.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: calendar.c,v 1.35 2015/12/07 18:46:35 espie Exp $ */
+/* $OpenBSD: calendar.c,v 1.36 2019/01/29 20:08:56 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -60,7 +60,6 @@ int bodun_always = 0;
int f_dayAfter = 0; /* days after current date */
int f_dayBefore = 0; /* days before current date */
-int f_SetdayAfter = 0; /* calendar invoked with -A */
struct specialev spev[NUMEV];
@@ -101,7 +100,6 @@ main(int argc, char *argv[])
f_dayAfter = strtonum(optarg, 0, INT_MAX, &errstr);
if (errstr)
errx(1, "-A %s: %s", optarg, errstr);
- f_SetdayAfter = 1;
break;
case 'B': /* days before current date */
diff --git a/usr.bin/calendar/calendar.h b/usr.bin/calendar/calendar.h
index 2fc2e649e65..b6e27d0a592 100644
--- a/usr.bin/calendar/calendar.h
+++ b/usr.bin/calendar/calendar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: calendar.h,v 1.15 2015/12/07 18:46:35 espie Exp $ */
+/* $OpenBSD: calendar.h,v 1.16 2019/01/29 20:08:56 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -103,7 +103,6 @@ void setnnames(void);
extern int f_dayAfter; /* days after current date */
extern int f_dayBefore; /* days before current date */
-extern int f_SetdayAfter; /* calendar invoked with -A */
/* Special events; see also setnnames() in day.c */
/* '=' is not a valid character in a special event name */
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c
index a34e7852f63..5103566576a 100644
--- a/usr.bin/calendar/day.c
+++ b/usr.bin/calendar/day.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: day.c,v 1.34 2016/09/14 15:09:46 millert Exp $ */
+/* $OpenBSD: day.c,v 1.35 2019/01/29 20:08:56 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -166,7 +166,7 @@ settime(time_t *now)
cumdays = daytab[0];
/* Friday displays Monday's events */
offset = tp->tm_wday == 5 ? 3 : 1;
- if (f_SetdayAfter)
+ if (f_dayAfter || f_dayBefore)
offset = 0; /* Except not when range is set explicitly */
header[5].iov_base = dayname;