Re: BUG: cal prints bad month headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 27 May 2014, Ruediger Meier wrote:
> This happens only if output is redirected into a file
> $ ./cal -ym > bla ;cat bla
> It looks good in terminal.
>
> Reverting 95f4adde (plus 0c6dc4b9 and 4a7424a5) fixes the problem.

Just another hint. Adding a fflush() like you see below also "fixes" the 
problem. Maybe we are mixing several output methods (printf, puts, 
my_putstring, etc.) like we shouldn't.

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 81375fe..2b61a30 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -760,6 +760,7 @@ static void yearly(const struct cal_control *ctl)
                set_consecutive_months(&m1, month, ctl->req.year);
                for (i = &m1; i; i = i->next)
                        cal_fill_month(i, ctl);
+               fflush(NULL);
                cal_output_header(&m1, ctl);
                cal_output_months(&m1, ctl);
        }
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux