]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cal: simplify ascii_weeknum() function
authorSami Kerola <kerolasa@iki.fi>
Sun, 10 Nov 2013 18:23:32 +0000 (18:23 +0000)
committerKarel Zak <kzak@redhat.com>
Fri, 6 Dec 2013 09:58:54 +0000 (10:58 +0100)
Either the week is or isn't highlighted, there is no need to over
complicate printing of that.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
misc-utils/cal.c

index 748288de32ba59ca4f3c6e803ccfa2a58c46f70e..c1bbdce89dbe26f1963d2040daf5d092969200ab 100644 (file)
@@ -970,12 +970,9 @@ static char *ascii_day(char *p, int day, const struct cal_control *ctl)
 static char *ascii_weeknum(char *p, int weeknum, const struct cal_control *ctl)
 {
        if ((ctl->weektype & WEEK_NUM_MASK) == weeknum)
-               p += sprintf(p,"%s",Senter);
-       p += sprintf(p,"%2d",weeknum);
-       if ((ctl->weektype & WEEK_NUM_MASK) == weeknum)
-               p += sprintf(p,"%s ",Sexit);
+               p += sprintf(p, "%s%2d%s ", Senter, weeknum, Sexit);
        else
-               p += sprintf(p," ");
+               p += sprintf(p, "%2d ", weeknum);
        return p;
 }