]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cal: fix multi-month printing.
authorJadingTsunami <JadingTsunami@users.noreply.github.com>
Fri, 3 Mar 2023 06:13:45 +0000 (22:13 -0800)
committerJadingTsunami <JadingTsunami@users.noreply.github.com>
Fri, 3 Mar 2023 06:13:45 +0000 (22:13 -0800)
misc-utils/cal.c

index 3cc5f9d4f2e2e0bf8d647acc15aef88cde1b70f3..c5be03d205e087599c95e3df749727314eed7ce0 100644 (file)
@@ -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){