Date: Sun, 7 Mar 2010 21:50:40 +0000 (UTC) From: Edwin Groothuis <edwin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r204848 - user/edwin/ncal Message-ID: <201003072150.o27Loe3B074603@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003072150.o27Loe3B074603>