]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Support platforms with neither terminfo nor termcap functions, like mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 23 Dec 2006 15:56:55 +0000 (15:56 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:34 +0000 (12:14 +0200)
DEPENDENCIES
gnulib-local/ChangeLog
gnulib-local/Makefile.am
gnulib-local/lib/term-ostream.oo.c
gnulib-local/lib/termcap.h
gnulib-local/lib/terminfo.h
gnulib-local/m4/termcap.m4
gnulib-local/m4/terminfo.m4
gnulib-local/modules/termcap
gnulib-local/modules/terminfo

index 59dc96cdb99bf7a3eb9960fcb704b1e265e2d2b2..72856a1e361def75bcfd9e08cb737006e52fd4cd 100644 (file)
@@ -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:
index 8dc06ff116f42e156960ff7785f44ee6020a4a3d..d0f0b17ee0d7d6ae889ff03548ae563e9cb3e008 100644 (file)
@@ -1,3 +1,27 @@
+2006-12-23  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        Improve cross-compilation support.
index 04b04ba57c017ebc9d026168aa5227b25ea9f2f0..5e65356ff5c9bb6c7a991c3a7060991166655d46 100644 (file)
@@ -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 \
index 1a839d79b197130c706e6de648b1bd4ad2953861..65588789cbdfa21109f14e1fd15690a913877c31 100644 (file)
@@ -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
index 5c76898d1d3cdfd451b053dca6136a467b201bdc..3fc7bebf452db5dddae991efeaac74b97e779fb6 100644 (file)
@@ -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
index 1a10443b046d5cf3abe291c87e2c22ed0cbc948a..88ea2baf8175c624619f2c6cc91ea736ef564186 100644 (file)
@@ -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
index 93792eeebf0952bcd63e8edb87564113d9a924eb..a654ee48c7155cd19f98195bd3924595c798f727 100644 (file)
@@ -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])
index cdf627f4db179103c7b64860154151deb8e8eae1..76f14cffba7c912395a2ba7002f47a50603e5d02 100644 (file)
@@ -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])
index 9939edee0f8ed3091f674cb1b130ee8246ce2f46..dfd4928dd0e8cf1c48314181d76ea891272ba281 100644 (file)
@@ -4,6 +4,7 @@ Information about terminal capabilities.
 Files:
 m4/termcap.m4
 lib/tparm.c
+lib/tputs.c
 
 Depends-on:
 havelib
index 25e244a94463bea024559281a194f17479953cb1..32d408795eaf805b1b01e5bc39aa913cedf76ea4 100644 (file)
@@ -4,6 +4,7 @@ Information about terminal capabilities.
 Files:
 m4/terminfo.m4
 lib/tparm.c
+lib/tputs.c
 
 Depends-on:
 havelib