public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 01/10] cal: use control structure for run time configuration
Date: Thu, 31 Oct 2013 12:29:17 +0100	[thread overview]
Message-ID: <20131031112917.GC1536@x2.net.home> (raw)
In-Reply-To: <1382906556-16442-2-git-send-email-kerolasa@iki.fi>

On Sun, Oct 27, 2013 at 08:42:27PM +0000, Sami Kerola wrote:
> +struct cal_control {
> +	const char *full_month[MONTHS_IN_YEAR];	/* month names */
> +	int colormode;			/* day and week number highlight */
> +	int num_months;			/* number of months horizontally in print out */
> +	int weekstart;			/* day the week starts, often Sun or Mon */
> +	int wflag;			/* uses WEEK_NUM_ enum */
> +	int wnum;			/* requested --week=number */

 hmm... you duplicate information the struct
 
    wnum == wflag & WEEK_NUM_MASK 

 Anyway, I think the whole WEEK_NUM_MASK thing is unnecessary if you
 have the control struct, just use:

    struct cal_control {
      ...
      int weekstart;
      int weektype;     /* WEEK_TYPE_{NONE,ISO,US} */
      int weeknum;      /* --week=<num> */
      ...
    }

 Note more readable "week" rather than "w" prefix :-)

> -	if (wflag) {
> -		wflag = wnum & WEEK_NUM_MASK;
> -		wflag |= (weekstart == MONDAY ? WEEK_NUM_ISO : WEEK_NUM_US);
> +	if (ctl.wflag) {
> +		ctl.wflag = ctl.wnum & WEEK_NUM_MASK;
> +		ctl.wflag |= (ctl.weekstart == MONDAY ? WEEK_NUM_ISO : WEEK_NUM_US);
>  	}

 In the original code is wnum main()-only variable.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2013-10-31 11:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 20:42 [0000/0010] cal: code revisit part I Sami Kerola
2013-10-27 20:42 ` [PATCH 01/10] cal: use control structure for run time configuration Sami Kerola
2013-10-31 11:29   ` Karel Zak [this message]
2013-10-27 20:42 ` [PATCH 02/10] cal: add input variable names to function prototypes Sami Kerola
2013-10-27 20:42 ` [PATCH 03/10] cal: make day_in_week() use same variable names as other functions Sami Kerola
2013-10-27 20:42 ` [PATCH 04/10] cal: simplify ascii_wnum() function Sami Kerola
2013-10-27 20:42 ` [PATCH 05/10] cal: determine output width at beginning of run and reuse result Sami Kerola
2013-10-31 11:34   ` Karel Zak
2013-10-27 20:42 ` [PATCH 06/10] tests: cal: take account week numbers when determing month lenght Sami Kerola
2013-10-27 20:42 ` [PATCH 07/10] cal: make user request to be part of read-only control struct Sami Kerola
2013-10-31 11:49   ` Karel Zak
2013-11-01  9:29     ` Sami Kerola
2013-10-27 20:42 ` [PATCH 08/10] cal: determine how many header lines are needed at initialization Sami Kerola
2013-10-27 20:42 ` [PATCH 09/10] cal: add month contents structure Sami Kerola
2013-10-27 20:42 ` [PATCH 10/10] cal: make cal --three to use content structures Sami Kerola
2013-10-31 12:14 ` [0000/0010] cal: code revisit part I Karel Zak

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=20131031112917.GC1536@x2.net.home \
    --to=kzak@redhat.com \
    --cc=kerolasa@iki.fi \
    --cc=util-linux@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