]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_setup.c
ncurses 5.9 - patch 20111001
[ncurses.git] / ncurses / tinfo / lib_setup.c
index 992b8c7110a8d70ff6fbc80fe4f92c1d85849040..9bfe17a861a64c078dbb55124328dc8bfc6fece9 100644 (file)
@@ -47,7 +47,7 @@
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.136 2011/04/16 15:32:45 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.141 2011/08/13 16:07:22 tom Exp $")
 
 /****************************************************************************
  *
@@ -221,6 +221,7 @@ NCURSES_SP_NAME(use_env) (NCURSES_SP_DCLx bool f)
 {
     T((T_CALLED("use_env(%p,%d)"), (void *) SP_PARM, (int) f));
 #if NCURSES_SP_FUNCS
+    START_TRACE();
     if (IsPreScreen(SP_PARM)) {
        SP_PARM->_use_env = f;
     }
@@ -235,6 +236,7 @@ NCURSES_EXPORT(void)
 use_env(bool f)
 {
     T((T_CALLED("use_env(%d)"), (int) f));
+    START_TRACE();
     _nc_prescreen.use_env = f;
     returnVoid;
 }
@@ -410,22 +412,6 @@ _nc_update_screensize(SCREEN *sp)
  *
  ****************************************************************************/
 
-#define ret_error(code, fmt, arg)      if (errret) {\
-                                           *errret = code;\
-                                           returnCode(ERR);\
-                                       } else {\
-                                           fprintf(stderr, fmt, arg);\
-                                           exit(EXIT_FAILURE);\
-                                       }
-
-#define ret_error0(code, msg)          if (errret) {\
-                                           *errret = code;\
-                                           returnCode(ERR);\
-                                       } else {\
-                                           fprintf(stderr, msg);\
-                                           exit(EXIT_FAILURE);\
-                                       }
-
 #if USE_DATABASE || USE_TERMCAP
 /*
  * Return 1 if entry found, 0 if not found, -1 if database not accessible,
@@ -477,7 +463,7 @@ _nc_tinfo_cmdch(TERMINAL * termp, char proto)
     if ((tmp = getenv("CC")) != 0 && strlen(tmp) == 1) {
        CC = *tmp;
        for_each_string(i, &(termp->type)) {
-           for (tmp = termp->type.Strings[i]; *tmp; tmp++) {
+           for (tmp = termp->type.Strings[i]; tmp && *tmp; tmp++) {
                if (*tmp == proto)
                    *tmp = CC;
            }
@@ -547,7 +533,7 @@ _nc_locale_breaks_acs(TERMINAL * termp)
     int value;
     int result = 0;
 
-    if ((env = getenv(env_name)) != 0) {
+    if (getenv(env_name) != 0) {
        result = _nc_getenv_num(env_name);
     } else if ((value = tigetnum("U8")) >= 0) {
        result = value;         /* use extension feature */
@@ -690,7 +676,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
            if (status == TGETENT_ERR) {
                ret_error0(status, "terminals database is inaccessible\n");
            } else if (status == TGETENT_NO) {
-               ret_error(status, "'%s': unknown terminal type.\n", tname);
+               ret_error1(status, "unknown terminal type.\n", tname);
            }
        }
 #if !USE_REENTRANT
@@ -738,10 +724,19 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
 
 #ifndef USE_TERM_DRIVER
     if (generic_type) {
-       ret_error(TGETENT_NO, "'%s': I need something more specific.\n", tname);
-    }
-    if (hard_copy) {
-       ret_error(TGETENT_YES, "'%s': I can't handle hardcopy terminals.\n", tname);
+       /*
+        * BSD 4.3's termcap contains mis-typed "gn" for wy99.  Do a sanity
+        * check before giving up.
+        */
+       if ((VALID_STRING(cursor_address)
+            || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home)))
+           && VALID_STRING(clear_screen)) {
+           ret_error1(TGETENT_YES, "terminal is not really generic.\n", tname);
+       } else {
+           ret_error1(TGETENT_NO, "I need something more specific.\n", tname);
+       }
+    } else if (hard_copy) {
+       ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname);
     }
 #endif
     returnCode(code);