svn commit: r204848 - user/edwin/ncal
Edwin Groothuis
edwin at FreeBSD.org
Sun Mar 7 21:50:41 UTC 2010
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;
More information about the svn-src-user
mailing list