From owner-svn-src-user@FreeBSD.ORG Sun Mar 7 21:50:41 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0517C1065670; Sun, 7 Mar 2010 21:50:41 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CDF928FC08; Sun, 7 Mar 2010 21:50:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o27Loepj074605; Sun, 7 Mar 2010 21:50:40 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o27Loe3B074603; Sun, 7 Mar 2010 21:50:40 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201003072150.o27Loe3B074603@svn.freebsd.org> From: Edwin Groothuis Date: Sun, 7 Mar 2010 21:50:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204848 - user/edwin/ncal X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Mar 2010 21:50:41 -0000 Author: edwin Date: Sun Mar 7 21:50:40 2010 New Revision: 204848 URL: http://svn.freebsd.org/changeset/base/204848 Log: Cleanup duplicate code into a single path. Modified: user/edwin/ncal/ncal.c Modified: user/edwin/ncal/ncal.c ============================================================================== --- user/edwin/ncal/ncal.c Sun Mar 7 21:39:47 2010 (r204847) +++ user/edwin/ncal/ncal.c Sun Mar 7 21:50:40 2010 (r204848) @@ -718,20 +718,17 @@ mkmonthr(int y, int m, int jd_flag, stru for (i = 0; i != 7; i++) { l = 0; for (j = firstm + i, k = 0; j < last; j += 7, k += dw) { - if (j == today && !flag_nohighlight) { + if (j >= first) { if (jd_flag) dt.d = j - jan1 + 1; else sdater(j, &dt); - highlight(mlines->lines[i] + k, ds + dt.d * dw, - dw, &l); - } else if (j >= first) { - if (jd_flag) - dt.d = j - jan1 + 1; + if (j == today && !flag_nohighlight) + highlight(mlines->lines[i] + k, + ds + dt.d * dw, dw, &l); else - sdater(j, &dt); - memcpy(mlines->lines[i] + k + l, - ds + dt.d * dw, dw); + memcpy(mlines->lines[i] + k + l, + ds + dt.d * dw, dw); } else memcpy(mlines->lines[i] + k + l, " ", dw); } @@ -825,20 +822,17 @@ mkmonthb(int y, int m, int jd_flag, stru l = 0; for (j = firsts + 7 * i, k = 0; j < last && k != dw * 7; j++, k += dw) { - if (j == today && !flag_nohighlight) { + if (j >= first) { if (jd_flag) dt.d = j - jan1 + 1; else sdateb(j, &dt); - highlight(mlines->lines[i] + k, ds + dt.d * dw, - dw, &l); - } else if (j >= first) { - if (jd_flag) - dt.d = j - jan1 + 1; + if (j == today && !flag_nohighlight) + highlight(mlines->lines[i] + k, + ds + dt.d * dw, dw, &l); else - sdateb(j, &dt); - memcpy(mlines->lines[i] + k + l, - ds + dt.d * dw, dw); + memcpy(mlines->lines[i] + k + l, + ds + dt.d * dw, dw); } else memcpy(mlines->lines[i] + k + l, " ", dw); } @@ -1018,7 +1012,7 @@ highlight(char *dst, char *src, int len, term_se = term_so = NULL; - /* On how to highlight on this terminal */ + /* On how to highlight on this type of terminal (if any) */ if (isatty(STDOUT_FILENO) && tgetent(tbuf, NULL) == 1) { b = cbuf; term_so = tgetstr("so", &b); @@ -1028,7 +1022,10 @@ highlight(char *dst, char *src, int len, first = 0; } - /* This check is not necessary */ + /* + * This check is not necessary, should have been handled before calling + * this function. + */ if (flag_nohighlight) { memcpy(dst, src, len); return;