Re: [PATCH 07/10] cal: make user request to be part of read-only control struct

Karel Zak
2013-10-31T11:50:08Z

On Sun, Oct 27, 2013 at 08:42:33PM +0000, Sami Kerola wrote:
> +struct cal_request {
> + int day;
> + int month;
> + long year;
> + int week;
> +};

It makes more sense than cal_width :-)

> + ctl.req.day = day_in_year(ctl.req.day, ctl.req.month, ctl.req.year);

req.day = calculate_request_day(&req);

> -static void monthly(int day, int month, long year, const struct cal_control *ctl)
> +static void monthly(const struct cal_control *ctl)
...
> - rows = do_monthly(day, month, year, &out, -1, ctl);
> + rows = do_monthly(ctl->req.day, ctl->req.month, ctl->req.year, &out, -1, ctl);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Well, if you have a request struct then use it!

do_monthly(req, &out, -1, ctl);

Maybe you can keep request and control structs independent, so then
one day you can implement something like

cal --date=Dec-2013 --date=Dec-2014

to print more independent calendars :-)

Karel

--
Karel Zak <kzak@redhat.com>