Re: [PATCH 01/10] cal: use control structure for run time configuration

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

 



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@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