From: Bruno Haible Date: Sat, 23 Dec 2006 15:56:55 +0000 (+0000) Subject: Support platforms with neither terminfo nor termcap functions, like mingw. X-Git-Tag: v0.17~533 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e75b14e60adf75950310e12d006f5575fb69137;p=thirdparty%2Fgettext.git Support platforms with neither terminfo nor termcap functions, like mingw. --- diff --git a/DEPENDENCIES b/DEPENDENCIES index 59dc96cdb..72856a1e3 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -15,9 +15,10 @@ The following packages should be installed before GNU gettext is installed: + If it is installed in a nonstandard directory, pass the option --with-libintl-prefix=DIR to 'configure'. -* GNU ncurses (preferred) or libtermcap (discouraged). - + Required. - Needed for the --color option of the various programs. +* GNU ncurses (preferred) + or libtermcap (discouraged) or a curses library (legacy). + + Highly recommended. + Needed for the --color option of the 'msgcat' program. + Homepage: http://www.gnu.org/software/ncurses/ + Download: diff --git a/gnulib-local/ChangeLog b/gnulib-local/ChangeLog index 8dc06ff11..d0f0b17ee 100644 --- a/gnulib-local/ChangeLog +++ b/gnulib-local/ChangeLog @@ -1,3 +1,27 @@ +2006-12-23 Bruno Haible + + Support platforms with neither terminfo nor termcap functions, like + mingw. + * lib/tputs.c: New file. + + * modules/termcap (Files): Add lib/tputs.c. + * m4/termcap.m4 (gl_TERMCAP): Add tputs replacement. + (gl_TERMCAP_BODY): Define HAVE_TERMCAP if tgetent is available. + * lib/termcap.h (tgetent, tgetnum, tgetflag, tgetstr): Declare only + if HAVE_TERMCAP. + (tgoto): Declare only if HAVE_TERMCAP || HAVE_TERMINFO. + + * modules/terminfo (Files): Add lib/tputs.c. + * m4/terminfo.m4 (gl_TERMINFO): Add tputs replacement. + (gl_TERMINFO_BODY): Define HAVE_TERMCAP if tgetent is available. + * lib/terminfo.h (tgetent, tgetnum, tgetflag, tgetstr): Declare only + if HAVE_TERMCAP. + (tgoto): Declare only if HAVE_TERMINFO || HAVE_TERMCAP. + + * lib/term-ostream.oo.c (term_ostream_create): Use ANSI color escape + sequences when neither terminfo nor termcap functions exist. + * Makefile.am (EXTRA_DIST): Add lib/tputs.c. + 2006-12-23 Bruno Haible Improve cross-compilation support. diff --git a/gnulib-local/Makefile.am b/gnulib-local/Makefile.am index 04b04ba57..5e65356ff 100644 --- a/gnulib-local/Makefile.am +++ b/gnulib-local/Makefile.am @@ -243,6 +243,7 @@ lib/term-styled-ostream.oo.h \ lib/termcap.h \ lib/terminfo.h \ lib/tparm.c \ +lib/tputs.c \ lib/vasprintf.c \ lib/xalloc.h \ lib/xerror.c \ diff --git a/gnulib-local/lib/term-ostream.oo.c b/gnulib-local/lib/term-ostream.oo.c index 1a839d79b..65588789c 100644 --- a/gnulib-local/lib/term-ostream.oo.c +++ b/gnulib-local/lib/term-ostream.oo.c @@ -1725,7 +1725,7 @@ term_ostream_create (int fd, const char *filename) stream->exit_underline_mode = xstrdup0 (tigetstr ("rmul")); stream->exit_attribute_mode = xstrdup0 (tigetstr ("sgr0")); } -#else +#elif HAVE_TERMCAP struct { char buf[1024]; char canary[4]; } termcapbuf; int retval; @@ -1791,6 +1791,20 @@ term_ostream_create (int fd, const char *filename) /* Buffer overflow! */ abort (); } +#else + /* Fallback code for platforms with neither the terminfo nor the termcap + functions, such as mingw. + Assume the ANSI escape sequences. Extracted through + "TERM=ansi infocmp", replacing \E with \033. */ + stream->max_colors = 8; + stream->no_color_video = 3; + stream->set_a_foreground = xstrdup ("\033[3%p1%dm"); + stream->set_a_background = xstrdup ("\033[4%p1%dm"); + stream->orig_pair = xstrdup ("\033[39;49m"); + stream->enter_bold_mode = xstrdup ("\033[1m"); + stream->enter_underline_mode = xstrdup ("\033[4m"); + stream->exit_underline_mode = xstrdup ("\033[m"); + stream->exit_attribute_mode = xstrdup ("\033[0;10m"); #endif /* AIX 4.3.2, IRIX 6.5, HP-UX 11, Solaris 7..10 all lack the diff --git a/gnulib-local/lib/termcap.h b/gnulib-local/lib/termcap.h index 5c76898d1..3fc7bebf4 100644 --- a/gnulib-local/lib/termcap.h +++ b/gnulib-local/lib/termcap.h @@ -26,6 +26,8 @@ extern "C" { #endif +#if HAVE_TERMCAP + /* Gets the capability information for terminal type TYPE. Returns 1 if successful, 0 if TYPE is unknown, -1 on other error. */ extern int tgetent (char *bp, const char *type); @@ -43,6 +45,8 @@ extern int tgetflag (const char *id); Also, if AREA != NULL, stores it at *AREA and advances *AREA. */ extern const char * tgetstr (const char *id, char **area); +#endif + #if HAVE_TERMINFO /* Gets the capability information for terminal type TYPE and prepares FD. @@ -87,11 +91,15 @@ extern char * tparm (const char *str, ...); #endif +#if HAVE_TERMCAP || HAVE_TERMINFO + /* Retrieves a string that causes cursor positioning to (column, row). This function is necessary because the string returned by tgetstr ("cm") is in a special format. */ extern const char * tgoto (const char *cm, int column, int row); +#endif + /* Retrieves the value of a string capability. OUTCHARFUN is called in turn for each 'char' of the result. This function is necessary because string capabilities can contain diff --git a/gnulib-local/lib/terminfo.h b/gnulib-local/lib/terminfo.h index 1a10443b0..88ea2baf8 100644 --- a/gnulib-local/lib/terminfo.h +++ b/gnulib-local/lib/terminfo.h @@ -45,7 +45,7 @@ extern int tigetflag (const char *id); Returns NULL if it is not available, (char *)(-1) if ID is invalid. */ extern const char * tigetstr (const char *id); -#else +#elif HAVE_TERMCAP /* Gets the capability information for terminal type TYPE. Returns 1 if successful, 0 if TYPE is unknown, -1 on other error. */ @@ -89,11 +89,15 @@ extern char * tparm (const char *str, ...); #endif +#if HAVE_TERMINFO || HAVE_TERMCAP + /* Retrieves a string that causes cursor positioning to (column, row). This function is necessary because the string returned by tgetstr ("cm") is in a special format. */ extern const char * tgoto (const char *cm, int column, int row); +#endif + /* Retrieves the value of a string capability. OUTCHARFUN is called in turn for each 'char' of the result. This function is necessary because string capabilities can contain diff --git a/gnulib-local/m4/termcap.m4 b/gnulib-local/m4/termcap.m4 index 93792eeeb..a654ee48c 100644 --- a/gnulib-local/m4/termcap.m4 +++ b/gnulib-local/m4/termcap.m4 @@ -1,4 +1,4 @@ -# termcap.m4 serial 5 (gettext-0.16.2) +# termcap.m4 serial 6 (gettext-0.16.2) dnl Copyright (C) 2000-2002, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,6 +12,11 @@ AC_DEFUN([gl_TERMCAP], if test $gl_cv_termcap_tparam = no && test $gl_cv_termcap_tparm = no; then AC_LIBOBJ([tparm]) fi + case "$gl_cv_termcap" in + no*) + AC_LIBOBJ([tputs]) + ;; + esac ]) AC_DEFUN([gl_TERMCAP_BODY], @@ -27,6 +32,7 @@ AC_DEFUN([gl_TERMCAP_BODY], dnl tigetstr(), tigetflag() in the same library. dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of dnl tparm(). + dnl Some systems, like mingw, have nothing at all. dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) @@ -85,6 +91,13 @@ AC_DEFUN([gl_TERMCAP_BODY], libtermcap) ;; esac + case "$gl_cv_termcap" in + libc | libncurses | libtermcap) + AC_DEFINE([HAVE_TERMCAP], 1, + [Define if tgetent(), tgetnum(), tgetstr(), tgetflag() + are among the termcap library functions.]) + ;; + esac AC_SUBST([LIBTERMCAP]) AC_SUBST([LTLIBTERMCAP]) AC_SUBST([INCTERMCAP]) diff --git a/gnulib-local/m4/terminfo.m4 b/gnulib-local/m4/terminfo.m4 index cdf627f4d..76f14cffb 100644 --- a/gnulib-local/m4/terminfo.m4 +++ b/gnulib-local/m4/terminfo.m4 @@ -1,4 +1,4 @@ -# terminfo.m4 serial 1 (gettext-0.16.2) +# terminfo.m4 serial 2 (gettext-0.16.2) dnl Copyright (C) 2000-2002, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,6 +12,15 @@ AC_DEFUN([gl_TERMINFO], if test $gl_cv_terminfo_tparam = no && test $gl_cv_terminfo_tparm = no; then AC_LIBOBJ([tparm]) fi + case "$gl_cv_terminfo" in + no*) + case "$gl_cv_termcap" in + no*) + AC_LIBOBJ([tputs]) + ;; + esac + ;; + esac ]) AC_DEFUN([gl_TERMINFO_BODY], @@ -26,6 +35,7 @@ AC_DEFUN([gl_TERMINFO_BODY], dnl they have only a libtermcap. dnl Some systems, like BeOS, use GNU termcap, which has tparam() instead of dnl tparm(). + dnl Some systems, like mingw, have nothing at all. dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) @@ -278,6 +288,13 @@ AC_DEFUN([gl_TERMINFO_BODY], INCTERMINFO="$INCTERMCAP" ;; esac + case "$gl_cv_termcap" in + libc | libncurses | libtermcap) + AC_DEFINE([HAVE_TERMCAP], 1, + [Define if tgetent(), tgetnum(), tgetstr(), tgetflag() + are among the termcap library functions.]) + ;; + esac ;; esac AC_SUBST([LIBTERMINFO]) diff --git a/gnulib-local/modules/termcap b/gnulib-local/modules/termcap index 9939edee0..dfd4928dd 100644 --- a/gnulib-local/modules/termcap +++ b/gnulib-local/modules/termcap @@ -4,6 +4,7 @@ Information about terminal capabilities. Files: m4/termcap.m4 lib/tparm.c +lib/tputs.c Depends-on: havelib diff --git a/gnulib-local/modules/terminfo b/gnulib-local/modules/terminfo index 25e244a94..32d408795 100644 --- a/gnulib-local/modules/terminfo +++ b/gnulib-local/modules/terminfo @@ -4,6 +4,7 @@ Information about terminal capabilities. Files: m4/terminfo.m4 lib/tparm.c +lib/tputs.c Depends-on: havelib