ncurses 6.1 - patch 20181215
[ncurses.git] / ncurses / tinfo / lib_setup.c
index b7937da2291ccd2c2583e9f6e540337fc14b4fca..b43aa9528a1e8bee44f93a7c46801506eaa8a716 100644 (file)
@@ -48,7 +48,7 @@
 #include <locale.h>
 #endif
 
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.193 2018/06/23 21:35:06 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.197 2018/11/24 22:13:16 tom Exp $")
 
 /****************************************************************************
  *
 
 /****************************************************************************
  *
@@ -543,9 +543,9 @@ _nc_get_locale(void)
      */
     env = setlocale(LC_CTYPE, 0);
 #else
      */
     env = setlocale(LC_CTYPE, 0);
 #else
-    if (((env = getenv("LC_ALL")) != 0 && *env != '\0')
+    if (((env = getenv("LANG")) != 0 && *env != '\0')
        || ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
        || ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
-       || ((env = getenv("LANG")) != 0 && *env != '\0')) {
+       || ((env = getenv("LC_ALL")) != 0 && *env != '\0')) {
        ;
     }
 #endif
        ;
     }
 #endif
@@ -714,6 +714,24 @@ TINFO_SETUP_TERM(TERMINAL **tp,
            ret_error0(TGETENT_ERR,
                       "Not enough memory to create terminal structure.\n");
        }
            ret_error0(TGETENT_ERR,
                       "Not enough memory to create terminal structure.\n");
        }
+#if HAVE_SYSCONF
+       {
+           long limit;
+#ifdef LINE_MAX
+           limit = LINE_MAX;
+#else
+           limit = _nc_globals.getstr_limit;
+#endif
+#ifdef _SC_LINE_MAX
+           if (limit < sysconf(_SC_LINE_MAX))
+               limit = sysconf(_SC_LINE_MAX);
+#endif
+           if (_nc_globals.getstr_limit < (int) limit)
+               _nc_globals.getstr_limit = (int) limit;
+       }
+#endif /* HAVE_SYSCONF */
+       T(("using %d for getstr limit", _nc_globals.getstr_limit));
+
 #ifdef USE_TERM_DRIVER
        INIT_TERM_DRIVER();
        TCB = (TERMINAL_CONTROL_BLOCK *) termp;
 #ifdef USE_TERM_DRIVER
        INIT_TERM_DRIVER();
        TCB = (TERMINAL_CONTROL_BLOCK *) termp;
@@ -728,7 +746,9 @@ TINFO_SETUP_TERM(TERMINAL **tp,
 #else
 #if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP
        status = _nc_setup_tinfo(tname, &TerminalType(termp));
 #else
 #if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP
        status = _nc_setup_tinfo(tname, &TerminalType(termp));
+       T(("_nc_setup_tinfo returns %d", status));
 #else
 #else
+       T(("no database available"));
        status = TGETENT_NO;
 #endif
 
        status = TGETENT_NO;
 #endif
 
@@ -737,6 +757,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
            const TERMTYPE2 *fallback = _nc_fallback2(tname);
 
            if (fallback) {
            const TERMTYPE2 *fallback = _nc_fallback2(tname);
 
            if (fallback) {
+               T(("found fallback entry"));
                TerminalType(termp) = *fallback;
                status = TGETENT_YES;
            }
                TerminalType(termp) = *fallback;
                status = TGETENT_YES;
            }