[hackers] [sbase] If only the year operand is given, cal shall produce a calendar for all twelve months in the given calendar year. || Greg Reagle
commit efac15726bcd43ed7cef96676a75672be6fb4a0e
Author: Greg Reagle <greg.reagle_AT_umbc.edu>
Date: Thu Jan 8 14:21:37 2015 -0500
If only the year operand is given, cal shall produce a calendar for all twelve months in the given calendar year.
diff --git a/cal.1 b/cal.1
index 8619460..da9c102 100644
--- a/cal.1
+++ b/cal.1
_AT_@ -28,7 +28,13 @@ of calendars side by side. Each row of calendars contains at most
.IR columns
number of calendars. The defaults are obtained using
.IR localtime (3).
-The Julian calendar is used through Sep 2, 1752, and the Gregorian calendar is used starting the next day with Sep 14, 1752.
+If
+.IR year
+is given without
+.IR month
+print the whole year, unless overridden by options. The Julian calendar is used
+through Sep 2, 1752, and the Gregorian calendar is used starting the next day
+with Sep 14, 1752.
.SH OPTIONS
.TP
.B \-1
diff --git a/cal.c b/cal.c
index 8d6dda0..52c2f6d 100644
--- a/cal.c
+++ b/cal.c
_AT_@ -146,7 +146,7 @@ main(int argc, char *argv[])
fday = 0;
ncols = 3;
- nmons = 1;
+ nmons = 0;
ARGBEGIN {
case '1':
_AT_@ -183,6 +183,15 @@ main(int argc, char *argv[])
usage();
} ARGEND;
+ if (nmons == 0) {
+ if (argc == 1) {
+ month = 1;
+ nmons = 12;
+ } else {
+ nmons = 1;
+ }
+ }
+
switch (argc) {
case 2:
month = estrtol(argv[0], 0);
Received on Fri Jan 16 2015 - 17:26:51 CET
This archive was generated by hypermail 2.3.0
: Fri Jan 16 2015 - 17:36:22 CET