From f406193831701d4bcb0b34222841dd1deec6296c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 12 Jun 2007 16:45:32 +0200 Subject: [PATCH] cal: ifdef cleanup, non-curses/tempcap code fixes This patche: - removes extra #ifdef-s, - fixes \n usage when compiled without curses/termcap Signed-off-by: Karel Zak --- misc-utils/cal.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/misc-utils/cal.c b/misc-utils/cal.c index eae0c838..5566e312 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -123,7 +123,16 @@ my_tgetstr(char *s, char *ss) { return ret; } +#else /* ! (HAVE_LIBTERMCAP || HAVE_NCURSES) */ + +static void +my_putstring(char *s) { + fputs(s, stdout); +} + #endif + + const char *term=""; const char *Senter="", *Sexit="";/* enter and exit standout mode */ int Slen; /* strlen of Senter+Sexit */ @@ -475,11 +484,8 @@ monthly(int day, int month, int year) { do_monthly(day, month, year, &out); for (i = 0; i < FMT_ST_LINES; i++) { -#if defined(HAVE_NCURSES) || defined(HAVE_LIBTERMCAP) - my_putstring(out.s[i]);putchar('\n'); -#else - puts(out.s[i]); -#endif + my_putstring(out.s[i]); + putchar('\n'); } } @@ -531,11 +537,7 @@ monthly3(int day, int month, int year) { w2, out_curm.s[i], w3, out_next.s[i]); -#if defined(HAVE_NCURSES) || defined(HAVE_LIBTERMCAP) my_putstring(lineout); -#else - fputs(lineout,stdout); -#endif } } @@ -568,11 +570,8 @@ j_yearly(int day, int year) { } *p = '\0'; trim_trailing_spaces(lineout); -#if defined(HAVE_NCURSES) || defined(HAVE_LIBTERMCAP) - my_putstring(lineout);putchar('\n'); -#else - puts(lineout); -#endif + my_putstring(lineout); + putchar('\n'); } } printf("\n"); @@ -608,14 +607,11 @@ yearly(int day, int year) { } *p = '\0'; trim_trailing_spaces(lineout); -#if defined(HAVE_NCURSES) || defined(HAVE_LIBTERMCAP) - my_putstring(lineout);putchar('\n'); -#else - puts(lineout); -#endif + my_putstring(lineout); + putchar('\n'); } } - printf("\n"); + putchar('\n'); } /* -- 2.39.5