Re: [RFC/PATCH] week numbers for cal

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

 



On Tue, Oct 22, 2013 at 04:23:22PM +0100, Sami Kerola wrote:
> On 22 October 2013 11:32, Karel Zak <kzak@xxxxxxxxxx> wrote:
> > On Sat, Oct 05, 2013 at 11:59:54PM +0300, Tommi Kyntola wrote:
> >> I keep trying -w with cal from time to time and I finally decided it's
> >> about time to do something about it. I'm not sure if this is something
> >> you'd be interested in incorporating into util-linux cal, but it's
> >> something I wanted, so here it is. There's gcal of course, but I only
> >> wanted a toothpick not the whole forest.
> >
> > Applied, thanks.
> 
> FYI
> 
> I started think, and play with the cal code, in order to make the source a
> little bit more maintainable.  My plan is to add run time configuration
> and parameters structures. With bit of luck changing data structures
> allows less strange functions.

 That's also my wish. The current source is based on code rather data
 structures. That's alway bad thing, the result is mess of for/if()
 machinery.
 
 It would be nice to describe the problem by structs and split code 
 to two sets of the functions 

        1/ generate calendar(s), 
        2/ print calendar. 
        
  Something like:

  struct cal_week {
        int week_number;
        int days[7];
        ...
  };

  struct cal_month {
        struct cal_week weeks[5];
        ...
  }

  struct cal_control {
        int week_start;
        ...
        struct cal_month cals[12];
  }
 
  cal_new_month();
  cal_add_month();
  cal_get_month();
  cal_month_get_week();
  ...
  cal_print_calendar()

  ... or better.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
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