[PATCH 3/4] cal: follow HAVE_LANGINFO

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

 



Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 misc-utils/Makefile.am |    3 +++
 misc-utils/cal.c       |   23 +++--------------------
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/misc-utils/Makefile.am b/misc-utils/Makefile.am
index 794b881..aed8bac 100644
--- a/misc-utils/Makefile.am
+++ b/misc-utils/Makefile.am
@@ -66,6 +66,9 @@ endif
 endif
 
 cal_SOURCES = cal.c $(top_srcdir)/lib/mbsalign.c
+if !HAVE_LANGINFO
+cal_SOURCES += $(top_srcdir)/lib/langinfo.c
+endif
 if HAVE_TINFO
 cal_LDADD = -ltinfo @NCURSES_LIBS@
 else
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 4d46c1b..896c453 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -141,10 +141,6 @@ 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>
-#endif
-
 #include "widechar.h"
 
 /* allow compile-time define to over-ride default */
@@ -409,12 +405,6 @@ void headers_init(void)
   strcpy(day_headings,"");
   strcpy(j_day_headings,"");
 
-#ifdef HAVE_LANGINFO_H
-# define weekday(wd)	nl_langinfo(ABDAY_1+wd)
-#else
-# define weekday(wd)	_time_info->abbrev_wkday[wd]
-#endif
-
   for(i = 0 ; i < 7 ; i++ ) {
      ssize_t space_left;
      wd = (i + weekstart) % 7;
@@ -424,25 +414,18 @@ void headers_init(void)
      space_left = sizeof(day_headings) - (cur_dh - day_headings);
      if(space_left <= 2)
         break;
-     cur_dh += center_str(weekday(wd), cur_dh, space_left, 2);
+     cur_dh += center_str(nl_langinfo(ABDAY_1+wd), cur_dh, space_left, 2);
 
      if (i)
         strcat(cur_j_dh++, " ");
      space_left = sizeof(j_day_headings) - (cur_j_dh - j_day_headings);
      if(space_left <= 3)
         break;
-     cur_j_dh += center_str(weekday(wd), cur_j_dh, space_left, 3);
+     cur_j_dh += center_str(nl_langinfo(ABDAY_1+wd), cur_j_dh, space_left, 3);
   }
 
-#undef weekday
-
-  for (i = 0; i < 12; i++) {
-#ifdef HAVE_LANGINFO_H
+  for (i = 0; i < 12; i++)
      full_month[i] = nl_langinfo(MON_1+i);
-#else
-     full_month[i] = _time_info->full_month[i];
-#endif
-  }
 }
 
 void
-- 
1.7.3.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