]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_setup.c
ncurses 5.9 - patch 20110730
[ncurses.git] / ncurses / tinfo / lib_setup.c
index 9101200536b002fb1591153a4995679d814d0219..b23ea97120d4597674e4df5d768672a81026dfd5 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 #include <curses.priv.h>
 #include <tic.h>               /* for MAX_NAME_SIZE */
 
 #include <curses.priv.h>
 #include <tic.h>               /* for MAX_NAME_SIZE */
 
-#if SVR4_TERMIO && !defined(_POSIX_SOURCE)
-#define _POSIX_SOURCE
-#endif
-
 #if HAVE_LOCALE_H
 #include <locale.h>
 #endif
 
 #if HAVE_LOCALE_H
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.130 2010/07/31 22:16:26 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.138 2011/06/14 22:36:29 tom Exp $")
 
 /****************************************************************************
  *
 
 /****************************************************************************
  *
@@ -225,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
 {
     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;
     }
     if (IsPreScreen(SP_PARM)) {
        SP_PARM->_use_env = f;
     }
@@ -239,6 +236,7 @@ NCURSES_EXPORT(void)
 use_env(bool f)
 {
     T((T_CALLED("use_env(%d)"), (int) f));
 use_env(bool f)
 {
     T((T_CALLED("use_env(%d)"), (int) f));
+    START_TRACE();
     _nc_prescreen.use_env = f;
     returnVoid;
 }
     _nc_prescreen.use_env = f;
     returnVoid;
 }
@@ -546,25 +544,31 @@ _nc_unicode_locale(void)
 NCURSES_EXPORT(int)
 _nc_locale_breaks_acs(TERMINAL * termp)
 {
 NCURSES_EXPORT(int)
 _nc_locale_breaks_acs(TERMINAL * termp)
 {
+    const char *env_name = "NCURSES_NO_UTF8_ACS";
     char *env;
     char *env;
+    int value;
+    int result = 0;
 
 
-    if ((env = getenv("NCURSES_NO_UTF8_ACS")) != 0) {
-       return atoi(env);
+    if (getenv(env_name) != 0) {
+       result = _nc_getenv_num(env_name);
+    } else if ((value = tigetnum("U8")) >= 0) {
+       result = value;         /* use extension feature */
     } else if ((env = getenv("TERM")) != 0) {
     } else if ((env = getenv("TERM")) != 0) {
-       if (strstr(env, "linux"))
-           return 1;           /* always broken */
-       if (strstr(env, "screen") != 0
-           && ((env = getenv("TERMCAP")) != 0
-               && strstr(env, "screen") != 0)
-           && strstr(env, "hhII00") != 0) {
+       if (strstr(env, "linux")) {
+           result = 1;         /* always broken */
+       } else if (strstr(env, "screen") != 0
+                  && ((env = getenv("TERMCAP")) != 0
+                      && strstr(env, "screen") != 0)
+                  && strstr(env, "hhII00") != 0) {
            if (CONTROL_N(enter_alt_charset_mode) ||
                CONTROL_O(enter_alt_charset_mode) ||
                CONTROL_N(set_attributes) ||
            if (CONTROL_N(enter_alt_charset_mode) ||
                CONTROL_O(enter_alt_charset_mode) ||
                CONTROL_N(set_attributes) ||
-               CONTROL_O(set_attributes))
-               return 1;
+               CONTROL_O(set_attributes)) {
+               result = 1;
+           }
        }
     }
        }
     }
-    return 0;
+    return result;
 }
 
 NCURSES_EXPORT(int)
 }
 
 NCURSES_EXPORT(int)
@@ -587,7 +591,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
 
 #ifdef USE_TERM_DRIVER
     T((T_CALLED("_nc_setupterm_ex(%p,%s,%d,%p)"),
 
 #ifdef USE_TERM_DRIVER
     T((T_CALLED("_nc_setupterm_ex(%p,%s,%d,%p)"),
-       tp, _nc_visbuf(tname), Filedes, errret));
+       (void *) tp, _nc_visbuf(tname), Filedes, (void *) errret));
 
     if (tp == 0) {
        ret_error0(TGETENT_ERR,
 
     if (tp == 0) {
        ret_error0(TGETENT_ERR,
@@ -660,7 +664,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
        TCB = (TERMINAL_CONTROL_BLOCK *) termp;
        code = _nc_globals.term_driver(TCB, tname, errret);
        if (code == OK) {
        TCB = (TERMINAL_CONTROL_BLOCK *) termp;
        code = _nc_globals.term_driver(TCB, tname, errret);
        if (code == OK) {
-           termp->Filedes = Filedes;
+           termp->Filedes = (short) Filedes;
            termp->_termname = strdup(tname);
        } else {
            ret_error0(TGETENT_ERR,
            termp->_termname = strdup(tname);
        } else {
            ret_error0(TGETENT_ERR,
@@ -696,7 +700,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp,
        ttytype[NAMESIZE - 1] = '\0';
 #endif
 
        ttytype[NAMESIZE - 1] = '\0';
 #endif
 
-       termp->Filedes = Filedes;
+       termp->Filedes = (short) Filedes;
        termp->_termname = strdup(tname);
 
        set_curterm(termp);
        termp->_termname = strdup(tname);
 
        set_curterm(termp);