X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_setup.c;h=b43aa9528a1e8bee44f93a7c46801506eaa8a716;hp=33cf2f96195f3ee06010e66b7abbadcf7d4a6346;hb=45291421bee33c79ffb4c8f0e1b67ca5cc262114;hpb=b22573b1ba4b51da883fa5f805b52f153fa5fae9 diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 33cf2f96..b43aa952 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * + * Copyright (c) 1998-2017,2018 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 * @@ -48,7 +48,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.188 2017/07/01 18:24:50 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 - if (((env = getenv("LC_ALL")) != 0 && *env != '\0') + if (((env = getenv("LANG")) != 0 && *env != '\0') || ((env = getenv("LC_CTYPE")) != 0 && *env != '\0') - || ((env = getenv("LANG")) != 0 && *env != '\0')) { + || ((env = getenv("LC_ALL")) != 0 && *env != '\0')) { ; } #endif @@ -560,7 +560,7 @@ NCURSES_EXPORT(int) _nc_unicode_locale(void) { int result = 0; -#if defined(__MINGW32__) && USE_WIDEC_SUPPORT +#if defined(_WIN32) && USE_WIDEC_SUPPORT result = 1; #elif HAVE_LANGINFO_CODESET char *env = nl_langinfo(CODESET); @@ -618,7 +618,7 @@ _nc_locale_breaks_acs(TERMINAL *termp) NCURSES_EXPORT(int) TINFO_SETUP_TERM(TERMINAL **tp, - NCURSES_CONST char *tname, + const char *tname, int Filedes, int *errret, int reuse) @@ -714,6 +714,24 @@ TINFO_SETUP_TERM(TERMINAL **tp, 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; @@ -722,15 +740,15 @@ TINFO_SETUP_TERM(TERMINAL **tp, termp->Filedes = (short) Filedes; termp->_termname = strdup(tname); } else { - _nc_free_termtype2(&TerminalType(termp)); - free(my_tcb); ret_error0(errret ? *errret : TGETENT_ERR, "Could not find any driver to handle this terminal.\n"); } #else #if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP status = _nc_setup_tinfo(tname, &TerminalType(termp)); + T(("_nc_setup_tinfo returns %d", status)); #else + T(("no database available")); status = TGETENT_NO; #endif @@ -739,6 +757,7 @@ TINFO_SETUP_TERM(TERMINAL **tp, const TERMTYPE2 *fallback = _nc_fallback2(tname); if (fallback) { + T(("found fallback entry")); TerminalType(termp) = *fallback; status = TGETENT_YES; } @@ -829,8 +848,9 @@ _nc_find_prescr(void) { SCREEN *result = 0; PRESCREEN_LIST *p; + pthread_t id = GetThreadID(); for (p = _nc_prescreen.allocated; p != 0; p = p->next) { - if (p->id == pthread_self()) { + if (p->id == id) { result = p->sp; break; } @@ -847,8 +867,9 @@ NCURSES_EXPORT(void) _nc_forget_prescr(void) { PRESCREEN_LIST *p, *q; + pthread_t id = GetThreadID(); for (p = _nc_prescreen.allocated, q = 0; p != 0; q = p, p = p->next) { - if (p->id == pthread_self()) { + if (p->id == id) { if (q) { q->next = p->next; } else { @@ -884,7 +905,7 @@ new_prescr(void) #ifdef USE_PTHREADS PRESCREEN_LIST *p = typeCalloc(PRESCREEN_LIST, 1); if (p != 0) { - p->id = pthread_self(); + p->id = GetThreadID(); p->sp = sp; p->next = _nc_prescreen.allocated; _nc_prescreen.allocated = p; @@ -921,7 +942,7 @@ new_prescr(void) * the same TERMINAL data (see comment). */ NCURSES_EXPORT(int) -_nc_setupterm(NCURSES_CONST char *tname, +_nc_setupterm(const char *tname, int Filedes, int *errret, int reuse) @@ -949,7 +970,7 @@ _nc_setupterm(NCURSES_CONST char *tname, * Make cur_term point to the structure. */ NCURSES_EXPORT(int) -setupterm(NCURSES_CONST char *tname, int Filedes, int *errret) +setupterm(const char *tname, int Filedes, int *errret) { START_TRACE(); return _nc_setupterm(tname, Filedes, errret, FALSE);