summaryrefslogtreecommitdiffstats
path: root/misc-utils/cal.c
diff options
context:
space:
mode:
authorDeiz2015-10-10 02:35:17 +0200
committerDeiz2015-10-10 02:35:17 +0200
commitd4cb626da245c0d792289f5267eec4b34c281e72 (patch)
tree262ae1a26e920327911bb89e512ec913abedf75d /misc-utils/cal.c
parentinclude/pt-mbr-partnames: remove '|' from partition type name (diff)
downloadkernel-qcow2-util-linux-d4cb626da245c0d792289f5267eec4b34c281e72.tar.gz
kernel-qcow2-util-linux-d4cb626da245c0d792289f5267eec4b34c281e72.tar.xz
kernel-qcow2-util-linux-d4cb626da245c0d792289f5267eec4b34c281e72.zip
cal: Track date span independently from months_in_row
This fixes a minor issue where cal -n 3 would mirror the spanning behaviour of cal -3 with Gregorian calendars, instead of starting with the current month. Signed-off-by: Deiz <silverwraithii@gmail.com>
Diffstat (limited to 'misc-utils/cal.c')
-rw-r--r--misc-utils/cal.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 6faac5ca2..7441ecfc4 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -232,6 +232,7 @@ struct cal_control {
const char *full_month[MONTHS_IN_YEAR]; /* month names */
int colormode; /* day and week number highlight */
int num_months; /* number of requested mounths */
+ int span_months; /* span the date */
int months_in_row; /* number of months horizontally in print out */
int weekstart; /* day the week starts, often Sun or Mon */
int weektype; /* WEEK_TYPE_{NONE,ISO,US} */
@@ -276,6 +277,7 @@ int main(int argc, char **argv)
static struct cal_control ctl = {
.weekstart = SUNDAY,
.num_months = 1, /* default is "cal -1" */
+ .span_months = 0,
.colormode = UL_COLORMODE_UNDEF,
.weektype = WEEK_NUM_DISABLED,
.day_width = DAY_LEN,
@@ -373,6 +375,7 @@ int main(int argc, char **argv)
break;
case '3':
ctl.num_months = 3;
+ ctl.span_months = 1;
ctl.months_in_row = 3;
break;
case 's':
@@ -737,7 +740,7 @@ static void monthly(const struct cal_control *ctl)
int32_t year = ctl->req.year;
/* cal -3 */
- if (ctl->num_months == 3 && ctl->months_in_row == 3) {
+ if (ctl->num_months == 3 && ctl->span_months) {
if (month == 1){
month = MONTHS_IN_YEAR;
year--;