X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_setup.c;h=5fcf2ae3fc32f48c3229455978471fd6043b1249;hp=0b8aeba5a8cfa9ebc35115d1eed33040bf8d6d2e;hb=687aeec3e382083652c3bb2e94fb6d3bf101a1f9;hpb=cf94c7485f7b40ff7870b5bf9a65e7ab87481a76;ds=sidebyside diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 0b8aeba5..5fcf2ae3 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -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 * @@ -51,7 +51,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.128 2010/04/03 13:54:45 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.135 2011/02/06 01:04:21 tom Exp $") /**************************************************************************** * @@ -430,14 +430,13 @@ _nc_update_screensize(SCREEN *sp) exit(EXIT_FAILURE);\ } -#ifndef USE_TERM_DRIVER #if USE_DATABASE || USE_TERMCAP /* * Return 1 if entry found, 0 if not found, -1 if database not accessible, * just like tgetent(). */ -static int -grab_entry(const char *const tn, TERMTYPE *const tp) +int +_nc_setup_tinfo(const char *const tn, TERMTYPE *const tp) { char filename[PATH_MAX]; int status = _nc_read_entry(tn, filename, tp); @@ -462,7 +461,6 @@ grab_entry(const char *const tn, TERMTYPE *const tp) return (status); } #endif -#endif /* !USE_TERM_DRIVER */ /* ** Take the real command character out of the CC environment variable @@ -548,25 +546,31 @@ _nc_unicode_locale(void) NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL * termp) { + const char *env_name = "NCURSES_NO_UTF8_ACS"; char *env; + int value; + int result = 0; - if ((env = getenv("NCURSES_NO_UTF8_ACS")) != 0) { - return atoi(env); + if ((env = 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) { - 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) || - CONTROL_O(set_attributes)) - return 1; + CONTROL_O(set_attributes)) { + result = 1; + } } } - return 0; + return result; } NCURSES_EXPORT(int) @@ -589,7 +593,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp, #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, @@ -658,10 +662,11 @@ TINFO_SETUP_TERM(TERMINAL ** tp, "Not enough memory to create terminal structure.\n"); } #ifdef USE_TERM_DRIVER + INIT_TERM_DRIVER(); 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, @@ -669,7 +674,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp, } #else #if USE_DATABASE || USE_TERMCAP - status = grab_entry(tname, &termp->type); + status = _nc_setup_tinfo(tname, &termp->type); #else status = TGETENT_NO; #endif @@ -697,7 +702,7 @@ TINFO_SETUP_TERM(TERMINAL ** tp, ttytype[NAMESIZE - 1] = '\0'; #endif - termp->Filedes = Filedes; + termp->Filedes = (short) Filedes; termp->_termname = strdup(tname); set_curterm(termp);