From: JadingTsunami Date: Fri, 3 Mar 2023 06:13:45 +0000 (-0800) Subject: cal: fix multi-month printing. X-Git-Tag: v2.39-rc1~13^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=151baa02b9244de6357e82cd4a29084aea8545f6;p=thirdparty%2Futil-linux.git cal: fix multi-month printing. --- diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 3cc5f9d4f2..c5be03d205 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -1016,8 +1016,8 @@ static void monthly(const struct cal_control *ctl) rows = (ctl->num_months - 1) / ctl->months_in_row; for (i = 0; i < rows + 1 ; i++){ - if (i == rows) - for (int n = 0; n < ctl->num_months % ctl->months_in_row; n++) + if (i == rows && ctl->num_months % ctl->months_in_row > 0) + for (int n = (ctl->num_months % ctl->months_in_row) - 1; n < ctl->months_in_row; n++) ms[n].next = NULL; for (m = ms; m; m = m->next){