util-linux/util-linux-2.13-cal-3.patch

110 lines
3.1 KiB
Diff

--- util-linux-2.13-pre7/misc-utils/cal.c.kzak 2007-07-09 14:54:39.000000000 +0200
+++ util-linux-2.13-pre7/misc-utils/cal.c 2007-07-09 14:54:39.000000000 +0200
@@ -87,9 +87,13 @@
putp(s);
}
-static char *
+static const char *
my_tgetstr(char *s, char *ss) {
- return tigetstr(ss);
+ const char* ret = tigetstr(ss);
+ if (!ret || ret==(char*)-1)
+ return "";
+ else
+ return ret;
}
#elif defined(HAVE_LIBTERMCAP)
@@ -110,14 +114,20 @@
tputs (s, 1, putchar);
}
-static char *
+static const char *
my_tgetstr(char *s, char *ss) {
- return tgetstr(s, &strbuf);
+ const char* ret = tgetstr(s, &strbuf);
+ if (!ret)
+ return "";
+ else
+ return ret;
}
#endif
const char *term="";
const char *Senter="", *Sexit="";/* enter and exit standout mode */
+int Slen; /* strlen of Senter+Sexit */
+char *Hrow; /* pointer to highlighted row in month */
#ifdef HAVE_LANGINFO_H
# include <langinfo.h>
@@ -262,6 +272,7 @@
if (ret > 0) {
Senter = my_tgetstr("so","smso");
Sexit = my_tgetstr("se","rmso");
+ Slen = strlen(Senter) + strlen(Sexit);
}
}
#endif
@@ -437,11 +448,18 @@
sprintf(out->s[1],"%s",
julian ? j_day_headings : day_headings);
for (row = 0; row < 6; row++) {
- for (col = 0, p = lineout; col < 7; col++)
- p = ascii_day(p, days[row * 7 + col]);
+ int has_hl = 0;
+ for (col = 0, p = lineout; col < 7; col++) {
+ int xd = days[row * 7 + col];
+ if (xd != SPACE && (xd & TODAY_FLAG))
+ has_hl = 1;
+ p = ascii_day(p, xd);
+ }
*p = '\0';
trim_trailing_spaces(lineout);
sprintf(out->s[row+2], "%s", lineout);
+ if (has_hl)
+ Hrow = out->s[row+2];
}
}
@@ -489,14 +507,25 @@
do_monthly(day, prev_month, prev_year, &out_prev);
do_monthly(day, month, year, &out_curm);
do_monthly(day, next_month, next_year, &out_next);
+
width = (julian ? J_WEEK_LEN : WEEK_LEN) -1;
for (i = 0; i < 2; i++)
printf("%s %s %s\n", out_prev.s[i], out_curm.s[i], out_next.s[i]);
for (i = 2; i < FMT_ST_LINES; i++) {
+ int w1, w2, w3;
+ w1 = w2 = w3 = width;
+
+#if defined(HAVE_NCURSES) || defined(HAVE_LIBTERMCAP)
+ /* adjust width to allow for non printable characters */
+ w1 += (out_prev.s[i] == Hrow ? Slen : 0);
+ w2 += (out_curm.s[i] == Hrow ? Slen : 0);
+ w3 += (out_next.s[i] == Hrow ? Slen : 0);
+#endif
snprintf(lineout, SIZE(lineout), "%-*s %-*s %-*s\n",
- width, out_prev.s[i],
- width, out_curm.s[i],
- width, out_next.s[i]);
+ w1, out_prev.s[i],
+ w2, out_curm.s[i],
+ w3, out_next.s[i]);
+
#if defined(HAVE_NCURSES) || defined(HAVE_LIBTERMCAP)
my_putstring(lineout);
#else
--- util-linux-2.13-pre7/configure.ac.kzak 2007-07-09 14:54:48.000000000 +0200
+++ util-linux-2.13-pre7/configure.ac 2007-07-09 14:55:11.000000000 +0200
@@ -71,6 +71,7 @@
if test x$ac_cv_header_ncurses_h = xyes || test x$ac_cv_header_ncurses_ncurses_h = xyes; then
have_ncurses=yes
AC_MSG_NOTICE([you have ncurses])
+ AC_DEFINE(HAVE_NCURSES, 1, [Do we have -lncurses?])
else
AC_MSG_NOTICE([you do not have ncurses])
fi