public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: kerolasa@gmail.com
Cc: Tommi Kyntola <tommi.kyntola@gmail.com>, util-linux-ng@vger.kernel.org
Subject: Re: [RFC/PATCH] week numbers for cal
Date: Tue, 22 Oct 2013 17:55:35 +0200	[thread overview]
Message-ID: <20131022155535.GI15115@x2.net.home> (raw)
In-Reply-To: <CAG27Bk3+XOmDrSumdaqWn_tTH1OxYQjwfeoaZ0pM8jN6OJuNQA@mail.gmail.com>

On Tue, Oct 22, 2013 at 04:23:22PM +0100, Sami Kerola wrote:
> On 22 October 2013 11:32, Karel Zak <kzak@redhat.com> 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@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2013-10-22 15:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-05 20:59 [RFC/PATCH] week numbers for cal Tommi Kyntola
2013-10-06 15:29 ` Sami Kerola
2013-10-06 17:23   ` Tommi Kyntola
2013-10-06 18:38     ` Benno Schulenberg
2013-10-07  3:10     ` Pádraig Brady
2013-10-07 11:39       ` Tommi Kyntola
2013-10-07 17:06         ` Pádraig Brady
2013-10-07 17:59           ` Tommi Kyntola
2013-10-07 23:33             ` Pádraig Brady
2013-10-09  9:43 ` Karel Zak
2013-10-22 10:32 ` Karel Zak
2013-10-22 15:23   ` Sami Kerola
2013-10-22 15:55     ` Karel Zak [this message]
2013-10-23  6:56   ` Tommi Kyntola

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131022155535.GI15115@x2.net.home \
    --to=kzak@redhat.com \
    --cc=kerolasa@gmail.com \
    --cc=tommi.kyntola@gmail.com \
    --cc=util-linux-ng@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox