From 2670086905b0721af123670c240e8fbc159c446d Mon Sep 17 00:00:00 2001 From: "Rajeev V. Pillai" Date: Wed, 6 May 2009 12:23:45 +0100 Subject: cal: Highlight today even when month or year specified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * misc-utils/cal.c: Unconditionally call time() and highlight today where possible. Signed-off-by: Rajeev V. Pillai Signed-off-by: Pádraig Brady --- misc-utils/cal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'misc-utils') diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 2417f1b5..f2d52e8c 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -348,6 +348,9 @@ main(int argc, char **argv) { argc -= optind; argv += optind; + time(&now); + local_time = localtime(&now); + day = month = year = 0; switch(argc) { case 3: @@ -366,13 +369,13 @@ main(int argc, char **argv) { if (day > dm) errx(1, _("illegal day value: use 1-%d"), dm); day = day_in_year(day, month, year); + } else if ((local_time->tm_year + 1900) == year) { + day = local_time->tm_yday + 1; } if (!month) yflag=1; break; case 0: - time(&now); - local_time = localtime(&now); day = local_time->tm_yday + 1; year = local_time->tm_year + 1900; month = local_time->tm_mon + 1; -- cgit v1.2.3 From 281a1782f0d7d9b7e6495e6265d25188e925b3a3 Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Thu, 14 May 2009 22:43:02 -0400 Subject: cal: uClibc has langinfo.h but not _NL_TIME_WEEK_1STDAY. Signed-off-by: Tom Prince --- configure.ac | 2 ++ misc-utils/cal.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'misc-utils') diff --git a/configure.ac b/configure.ac index ec41ae60..9ab94a85 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,8 @@ AC_CHECK_HEADERS([linux/raw.h], [AM_CONDITIONAL([HAVE_RAW], [true])], [AM_CONDITIONAL([HAVE_RAW], [false])]) +AC_CHECK_DECLS([_NL_TIME_WEEK_1STDAY],[],[],[[#include ]]) + AC_CHECK_FUNCS( [inet_aton \ fsync \ diff --git a/misc-utils/cal.c b/misc-utils/cal.c index f2d52e8c..a8534b8c 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -291,7 +291,7 @@ main(int argc, char **argv) { * the locale database, which can be overridden with the * -s (Sunday) or -m (Monday) options. */ -#ifdef HAVE_LANGINFO_H +#if HAVE_DECL__NL_TIME_WEEK_1STDAY /* * You need to use 2 locale variables to get the first day of the week. * This is needed to support first_weekday=2 and first_workday=1 for -- cgit v1.2.3