Loading ...
Sorry, an error occurred while loading the content.
 

Patch 6.1.362

Expand Messages
  • Bram Moolenaar
    Patch 6.1.362 Problem: tgetent() may return zero for success. tgetflag() may return -1 for an error. Solution: Check tgetflag() for returning a positive
    Message 1 of 1 , Feb 25, 2003
      Patch 6.1.362
      Problem: tgetent() may return zero for success. tgetflag() may return -1
      for an error.
      Solution: Check tgetflag() for returning a positive value. Add an autoconf
      check for the value that tgetent() returns.
      Files: src/auto/configure, src/config.h.in, src/configure.in, src/term.c


      *** ../vim61.361/src/auto/configure Mon Jan 6 21:55:57 2003
      --- src/auto/configure Mon Feb 17 12:00:06 2003
      ***************
      *** 5423,5432 ****
      echo "$ac_t""none found" 1>&6
      fi

      echo $ac_n "checking whether termcap.h contains ospeed""... $ac_c" 1>&6
      ! echo "configure:5381: checking whether termcap.h contains ospeed" >&5
      cat > conftest.$ac_ext <<EOF
      ! #line 5383 "configure"
      #include "confdefs.h"

      #ifdef HAVE_TERMCAP_H
      --- 5501,5543 ----
      echo "$ac_t""none found" 1>&6
      fi

      + if test "x$olibs" != "x$LIBS"; then
      + echo $ac_n "checking what tgetent() returns for an unknown terminal""... $ac_c" 1>&6
      + echo "configure:5507: checking what tgetent() returns for an unknown terminal" >&5
      + if test "$cross_compiling" = yes; then
      + { echo "configure: error: failed to compile test program." 1>&2; exit 1; }
      + else
      + cat > conftest.$ac_ext <<EOF
      + #line 5512 "configure"
      + #include "confdefs.h"
      +
      + #ifdef HAVE_TERMCAP_H
      + # include <termcap.h>
      + #endif
      + main()
      + {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
      + EOF
      + if { (eval echo configure:5521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
      + then
      + echo "$ac_t""zero" 1>&6; cat >> confdefs.h <<\EOF
      + #define TGETENT_ZERO_ERR 0
      + EOF
      +
      + else
      + echo "configure: failed program was:" >&5
      + cat conftest.$ac_ext >&5
      + rm -fr conftest*
      + echo "$ac_t""non-zero" 1>&6
      + fi
      + rm -fr conftest*
      + fi
      +
      + fi
      +
      echo $ac_n "checking whether termcap.h contains ospeed""... $ac_c" 1>&6
      ! echo "configure:5539: checking whether termcap.h contains ospeed" >&5
      cat > conftest.$ac_ext <<EOF
      ! #line 5541 "configure"
      #include "confdefs.h"

      #ifdef HAVE_TERMCAP_H
      *** ../vim61.361/src/config.h.in Mon Jan 6 21:55:57 2003
      --- src/config.h.in Sun Feb 16 18:31:10 2003
      ***************
      *** 135,140 ****
      --- 123,131 ----
      /* Define if tgetstr() has a second argument that is (char *) */
      #undef TGETSTR_CHAR_P

      + /* Define if tgetent() returns zero for an error */
      + #undef TGETENT_ZERO_ERR
      +
      /* Define if the getcwd() function should not be used. */
      #undef BAD_GETCWD

      *** ../vim61.361/src/configure.in Mon Jan 6 21:55:57 2003
      --- src/configure.in Mon Feb 17 11:59:46 2003
      ***************
      *** 1546,1551 ****
      --- 1597,1615 ----
      AC_MSG_ERROR(failed to compile test program.))
      else
      AC_MSG_RESULT(none found)
      + fi
      +
      + if test "x$olibs" != "x$LIBS"; then
      + AC_MSG_CHECKING(what tgetent() returns for an unknown terminal)
      + AC_TRY_RUN([
      + #ifdef HAVE_TERMCAP_H
      + # include <termcap.h>
      + #endif
      + main()
      + {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }],
      + AC_MSG_RESULT(zero); AC_DEFINE(TGETENT_ZERO_ERR, 0),
      + AC_MSG_RESULT(non-zero),
      + AC_MSG_ERROR(failed to compile test program.))
      fi

      AC_MSG_CHECKING(whether termcap.h contains ospeed)
      *** ../vim61.361/src/term.c Thu Feb 20 21:36:44 2003
      --- src/term.c Mon Feb 17 11:51:49 2003
      ***************
      *** 1642,1656 ****
      TGETSTR(string_names[i].name, &tp);
      }

      ! if ((T_MS == NULL || T_MS == empty_option) && tgetflag("ms"))
      T_MS = (char_u *)"y";
      ! if ((T_XS == NULL || T_XS == empty_option) && tgetflag("xs"))
      T_XS = (char_u *)"y";
      ! if ((T_DB == NULL || T_DB == empty_option) && tgetflag("db"))
      T_DB = (char_u *)"y";
      ! if ((T_DA == NULL || T_DA == empty_option) && tgetflag("da"))
      T_DA = (char_u *)"y";
      ! if ((T_UT == NULL || T_UT == empty_option) && tgetflag("ut"))
      T_UT = (char_u *)"y";


      --- 1642,1663 ----
      TGETSTR(string_names[i].name, &tp);
      }

      ! /* tgetflag() returns 1 if the flag is present, 0 if not and
      ! * possibly -1 if the flag doesn't exist. */
      ! if ((T_MS == NULL || T_MS == empty_option)
      ! && tgetflag("ms") > 0)
      T_MS = (char_u *)"y";
      ! if ((T_XS == NULL || T_XS == empty_option)
      ! && tgetflag("xs") > 0)
      T_XS = (char_u *)"y";
      ! if ((T_DB == NULL || T_DB == empty_option)
      ! && tgetflag("db") > 0)
      T_DB = (char_u *)"y";
      ! if ((T_DA == NULL || T_DA == empty_option)
      ! && tgetflag("da") > 0)
      T_DA = (char_u *)"y";
      ! if ((T_UT == NULL || T_UT == empty_option)
      ! && tgetflag("ut") > 0)
      T_UT = (char_u *)"y";


      ***************
      *** 2104,2123 ****
      int i;

      i = TGETENT(tbuf, term);
      ! if (i < 1)
      {
      /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call
      * tgetent() with the always existing "dumb" entry to avoid a crash or
      * hang. */
      (void)TGETENT(tbuf, "dumb");

      ! if (i == -1)
      return (char_u *)_("Cannot open termcap file");
      if (i == 0)
      #ifdef TERMINFO
      return (char_u *)_("Terminal entry not found in terminfo");
      #else
      ! return (char_u *)_("Terminal entry not found in termcap");
      #endif
      }
      return NULL;
      --- 2111,2136 ----
      int i;

      i = TGETENT(tbuf, term);
      ! if (i < 0 /* -1 is always an error */
      ! # ifdef TGETENT_ZERO_ERR
      ! || i == 0 /* sometimes zero is also an error */
      ! # endif
      ! )
      {
      /* On FreeBSD tputs() gets a SEGV after a tgetent() which fails. Call
      * tgetent() with the always existing "dumb" entry to avoid a crash or
      * hang. */
      (void)TGETENT(tbuf, "dumb");

      ! if (i < 0)
      ! # ifdef TGETENT_ZERO_ERR
      return (char_u *)_("Cannot open termcap file");
      if (i == 0)
      + # endif
      #ifdef TERMINFO
      return (char_u *)_("Terminal entry not found in terminfo");
      #else
      ! return (char_u *)_("Terminal entry not found in termcap");
      #endif
      }
      return NULL;
      *** ../vim61.361/src/version.c Tue Feb 25 21:41:42 2003
      --- src/version.c Tue Feb 25 21:46:43 2003
      ***************
      *** 608,609 ****
      --- 612,615 ----
      { /* Add new patch number below this line */
      + /**/
      + 362,
      /**/

      --
      TIM: To the north there lies a cave, the cave of Caerbannog, wherein, carved
      in mystic runes, upon the very living rock, the last words of Olfin
      Bedwere of Rheged make plain the last resting place of the most Holy
      Grail.
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.