File: calendar_weekend.diff

package info (click to toggle)
bsdmainutils 12.1.8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,108 kB
  • sloc: ansic: 2,356; sh: 131; python: 105; makefile: 50; perl: 39
file content (195 lines) | stat: -rw-r--r-- 5,940 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Description: Add options '-l' and '-w'.
Author: Michael Meskes <meskes@debian.org>

diff -ru bsdmainutils/usr.bin/calendar.orig/calendar.1 bsdmainutils/usr.bin/calendar/calendar.1
--- bsdmainutils/usr.bin/calendar.orig/calendar.1	2016-03-08 16:25:58.340534841 +0100
+++ bsdmainutils/usr.bin/calendar/calendar.1	2016-03-08 16:26:02.236572294 +0100
@@ -40,6 +40,8 @@
 .Op Fl abw
 .Op Fl A Ar num
 .Op Fl B Ar num
+.Op Fl l Ar num
+.Op Fl e Ar num
 .Op Fl f Ar calendarfile
 .Op Fl t Oo Oo Oo Ar cc Oc Ns Ar yy Oc Ns Ar mm Oc Ns Ar dd
 .Sh DESCRIPTION
@@ -59,6 +61,7 @@
 Print lines from today and next
 .Ar num
 days (forward, future).
+Defaults to one (same as \-l).
 .It Fl a
 Process the
 .Dq calendar
@@ -71,6 +74,18 @@
 days (backward, past).
 .It Fl b
 Enforce special date calculation mode for Cyrillic calendars.
+.It Fl l Ar num
+Print lines from today and next
+.Ar num
+days (forward, future).
+Defaults to one (same as \-A).
+.It Fl e Ar num
+Print lines from today and next
+.Ar num
+days, only if today is Friday (forward, future).
+Defaults to two, which causes
+.Nm
+to print entries through the weekend on Fridays.
 .It Fl f Ar calendarfile
 Use
 .Ar calendarfile
@@ -95,6 +108,13 @@
 .Dq Paskha=<national_name>
 (for Orthodox Easter) can be used.
 .Pp
+A special locale name exists:
+.Sq utf-8 .
+Specifying
+.Dq LANG=utf-8
+indicates that the dates will be read using the C locale, and the descriptions
+will be encoded in UTF-8.  This is usually used for the distributed calendar
+files.
 The
 .Dq CALENDAR
 variable can be used to specify the style.
@@ -114,6 +134,11 @@
 .Dq BODUN=<bodun_prefix>
 where <local_name> can be ru_RU.UTF-8, uk_UA.UTF-8 or by_BY.UTF-8.
 .Pp
+Note that the locale is reset to the user's default for each new file that is
+read.
+This is so that locales from one file do not accidentally carry over into
+another file.
+.Pp
 Other lines should begin with a month and day.
 They may be entered in almost any format, either numeric or as character
 strings.
@@ -155,6 +179,8 @@
 .Xr cpp 1
 searches in the current (or home) directory first, and then in the
 directory
+.Pa /etc/calendar ,
+and finally in
 .Pa /usr/share/calendar .
 Empty lines and lines protected by the C commenting syntax
 .Pq Li /* ... */
@@ -261,6 +287,40 @@
 in the line.
 This is no longer true: the date is only recognized when it occurs
 at the beginning of a line.
+.Sh COMPATIBILITY
+The
+.Nm
+command will only display lines that use a <tab> character to separate the date
+and description, or that begin with a <tab>.
+This is different than in previous releases.
+.Pp
+The
+Fl t
+flag argument syntax is from the original FreeBSD
+.Nm
+program.
+.Pp
+The
+.Fl l
+and
+.Fl e
+flags are Debian-specific enhancements.
+Option
+.Fl e
+used to be called
+.Fl w
+in Debian, but this option is now used differently by upstream.
+Also, the original
+.Nm
+program did not accept
+.Li 0
+as an argument to the
+.Fl A
+flag.
+.Pp
+Using
+.Sq utf-8
+as a locale name is a Debian-specific enhancement.
 .Sh HISTORY
 A
 .Nm
diff -ru bsdmainutils/usr.bin/calendar.orig/calendar.c bsdmainutils/usr.bin/calendar/calendar.c
--- bsdmainutils/usr.bin/calendar.orig/calendar.c	2016-03-08 16:25:58.352534957 +0100
+++ bsdmainutils/usr.bin/calendar/calendar.c	2016-03-08 16:32:52.468490287 +0100
@@ -58,6 +58,7 @@
 time_t f_time = 0;
 int bodun_always = 0;
 
+int weekend = 2;
 int f_dayAfter = 0;	/* days after current date */
 int f_dayBefore = 0;	/* days before current date */
 int f_Setday = 0;	/* calendar invoked with -A */
@@ -75,7 +76,7 @@
 
 	(void)setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "abwf:t:A:B:-")) != -1)
+	while ((ch = getopt(argc, argv, "abwf:l:t:e:A:B:-")) != -1)
 		switch (ch) {
 		case '-':		/* backward contemptible */
 		case 'a':
@@ -97,6 +98,7 @@
 				errx(1, "specified date is outside allowed range");
 			break;
 
+		case 'l':
 		case 'A': /* days after current date */
 			f_dayAfter = strtonum(optarg, 0, INT_MAX, &errstr);
 			if (errstr)
@@ -104,6 +106,12 @@
 			f_SetdayAfter = 1;
 			break;
 
+		case 'e':
+			weekend = strtonum(optarg, 0, INT_MAX, &errstr);
+ 			if (errstr)
+ 				errx(1, "-A %s: %s", optarg, errstr);
+			break;
+
 		case 'B': /* days before current date */
 			f_dayBefore = strtonum(optarg, 0, INT_MAX, &errstr);
 			if (errstr)
@@ -255,7 +263,7 @@
 usage(void)
 {
 	(void)fprintf(stderr,
-	    "usage: calendar [-abw] [-A num] [-B num] [-f calendarfile] "
+	    "usage: calendar [-abw] [-A num] [-B num] [-l num] [-e num] [-f calendarfile] "
 	    "[-t [[[cc]yy]mm]dd]\n");
 	exit(1);
 }
Nur in bsdmainutils/usr.bin/calendar: calendar.c.orig.
diff -ru bsdmainutils/usr.bin/calendar.orig/calendar.h bsdmainutils/usr.bin/calendar/calendar.h
--- bsdmainutils/usr.bin/calendar.orig/calendar.h	2016-03-08 16:25:58.340534841 +0100
+++ bsdmainutils/usr.bin/calendar/calendar.h	2016-03-08 16:26:02.236572294 +0100
@@ -103,6 +103,7 @@
 #define	SECSPERDAY	(24 * 60 * 60)
 #define	isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
 
+extern int weekend;    /* how many days to look ahead if today is Friday */
 extern int f_dayAfter;	/* days after current date */
 extern int f_dayBefore;	/* days before current date */
 extern int f_SetdayAfter; /* calendar invoked with -A */
Nur in bsdmainutils/usr.bin/calendar: calendar.h.orig.
diff -ru bsdmainutils/usr.bin/calendar.orig/day.c bsdmainutils/usr.bin/calendar/day.c
--- bsdmainutils/usr.bin/calendar.orig/day.c	2016-03-08 16:25:58.340534841 +0100
+++ bsdmainutils/usr.bin/calendar/day.c	2016-03-08 16:26:02.236572294 +0100
@@ -164,8 +164,8 @@
 		cumdays = daytab[1];
 	else
 		cumdays = daytab[0];
-	/* Friday displays Monday's events */
-	offset = tp->tm_wday == 5 ? 3 : 1;
+	/* Friday displays Monday's events if not configured otherwise */
+	offset = tp->tm_wday == 5 ? 1 + weekend : 1;
 	if (f_Setday)
 		offset = 0;	/* Except not when range is set explicitly */
 	header[5].iov_base = dayname;