svn commit: r204625 - user/edwin/ncal
Edwin Groothuis
edwin at FreeBSD.org
Wed Mar 3 07:11:26 UTC 2010
Author: edwin
Date: Wed Mar 3 07:11:25 2010
New Revision: 204625
URL: http://svn.freebsd.org/changeset/base/204625
Log:
style cleanup
double hassling of today variable cleanup.
Modified:
user/edwin/ncal/Makefile
user/edwin/ncal/ncal.c
Modified: user/edwin/ncal/Makefile
==============================================================================
--- user/edwin/ncal/Makefile Wed Mar 3 07:00:08 2010 (r204624)
+++ user/edwin/ncal/Makefile Wed Mar 3 07:11:25 2010 (r204625)
@@ -4,7 +4,7 @@ PROG= ncal
DPADD= ${LIBCALENDAR} ${LIBTERMCAP}
LDADD= -lcalendar -ltermcap
-CFLAGS+= -Wall
+CFLAGS+= -Wall -O0
WARNS?= 1
#LINKS= ${BINDIR}/ncal ${BINDIR}/cal
Modified: user/edwin/ncal/ncal.c
==============================================================================
--- user/edwin/ncal/ncal.c Wed Mar 3 07:00:08 2010 (r204624)
+++ user/edwin/ncal/ncal.c Wed Mar 3 07:11:25 2010 (r204625)
@@ -188,6 +188,7 @@ main(int argc, char *argv[])
struct djswitch *p, *q; /* to search user defined switch date */
date never = {10000, 1, 1}; /* outside valid range of dates */
date ukswitch = {1752, 9, 2};/* switch date for Great Britain */
+ date dt;
int ch; /* holds the option character */
int m = 0; /* month */
int y = 0; /* year */
@@ -200,28 +201,17 @@ main(int argc, char *argv[])
int flag_easter = 0; /* use wants easter date */
char *cp; /* character pointer */
char *flag_month = NULL; /* requested month as string */
- char *flag_date = NULL;
+ char *flag_highlightdate = NULL;
int before, after;
const char *locale; /* locale to get country code */
char tbuf[1024], cbuf[512], *b;
- time_t t;
- struct tm *tm1;
+ /* On how to highlight on this terminal */
term_se = term_so = NULL;
- today = 0;
if (isatty(STDOUT_FILENO) && tgetent(tbuf, NULL) == 1) {
- date dt; /* handy date */
-
b = cbuf;
term_so = tgetstr("so", &b);
term_se = tgetstr("se", &b);
- t = time(NULL);
- tm1 = localtime(&t);
- dt.y = tm1->tm_year + 1900;
- dt.m = tm1->tm_mon + 1;
- dt.d = tm1->tm_mday;
-
- today = sndaysb(&dt);
}
/*
@@ -290,7 +280,7 @@ main(int argc, char *argv[])
flag_backward = 1;
break;
case 'd':
- flag_date = optarg;
+ flag_highlightdate = optarg;
break;
case 'h':
term_so = term_se = NULL;
@@ -387,15 +377,21 @@ main(int argc, char *argv[])
}
}
- if (flag_date != NULL) {
- date dt; /* handy date */
-
- dt.y = strtol(flag_date, NULL, 10);
- dt.m = strtol(flag_date + 5, NULL, 10);
- dt.d = strtol(flag_date + 8, NULL, 10);
+ if (flag_highlightdate != NULL) {
+ dt.y = strtol(flag_highlightdate, NULL, 10);
+ dt.m = strtol(flag_highlightdate + 5, NULL, 10);
+ dt.d = strtol(flag_highlightdate + 8, NULL, 10);
+ } else {
+ time_t t;
+ struct tm *tm1;
- today = sndaysb(&dt);
+ t = time(NULL);
+ tm1 = localtime(&t);
+ dt.y = tm1->tm_year + 1900;
+ dt.m = tm1->tm_mon + 1;
+ dt.d = tm1->tm_mday;
}
+ today = sndaysb(&dt);
if (flag_easter)
printeaster(y, flag_julian_cal, flag_orthodox);
@@ -720,7 +716,8 @@ 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 && (term_so != NULL && term_se != NULL)) {
+ if (j == today &&
+ (term_so != NULL && term_se != NULL)) {
l = strlen(term_so);
if (jd_flag)
dt.d = j - jan1 + 1;
@@ -839,7 +836,8 @@ 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 && (term_so != NULL && term_se != NULL)) {
+ if (j == today &&
+ (term_so != NULL && term_se != NULL)) {
l = strlen(term_so);
if (jd_flag)
dt.d = j - jan1 + 1;
More information about the svn-src-user
mailing list