[PATCH] Fix cal output on TERM=dumb setups.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you try to use cal on a terminal which doesnt support highlighting, Senter and Sexit will be set to NULL instead of "" which will cause the resulting output to be off:

$ env TERM=dumb cal
   December 2005
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
111 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
---
 misc-utils/cal.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index b0cca1d..b7f7c31 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -89,7 +89,8 @@ my_putstring(char *s) {
 
 static char *
 my_tgetstr(char *s, char *ss) {
-     return tigetstr(ss);
+     char *ret = tigetstr(ss);
+     return (ret == NULL ? "" : ret);
 }
 
 #elif defined(HAVE_LIBTERMCAP)
@@ -112,7 +113,8 @@ my_putstring(char *s) {
 
 static char *
 my_tgetstr(char *s, char *ss) {
-     return tgetstr(s, &strbuf);
+     char *ret = tgetstr(s, &strbuf);
+     return (ret == NULL ? "" : ret);
 }
 
 #endif
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux