X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_setup.c;h=ed93378c6f29a854130ecc94cfd83db75119b99e;hb=d1a029866f6d84087781eaa81de19949d8533426;hp=5ed47409bb0abb39fa29fa8255af77c238f93143;hpb=3f57ad09dfcb62c8ad444e13fa4d450c05e878ba;p=ncurses.git diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index 5ed47409..ed93378c 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -49,7 +49,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.216 2022/07/09 18:58:58 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.221 2023/07/22 20:13:04 tom Exp $") /**************************************************************************** * @@ -679,10 +679,9 @@ TINFO_SETUP_TERM(TERMINAL **tp, #endif } myname = strdup(tname); - - if (strlen(myname) > MAX_NAME_SIZE) { + if (myname == NULL || strlen(myname) > MAX_NAME_SIZE) { ret_error(TGETENT_ERR, - "TERM environment must be <= %d characters.\n", + "TERM environment must be 1..%d characters.\n", MAX_NAME_SIZE, free(myname)); } @@ -764,10 +763,14 @@ TINFO_SETUP_TERM(TERMINAL **tp, #ifdef USE_TERM_DRIVER INIT_TERM_DRIVER(); + /* + * _nc_get_driver() will call td_CanHandle() for each driver, and win_driver + * needs file descriptor to do the test, so set it before calling. + */ + termp->Filedes = (short) Filedes; TCB = (TERMINAL_CONTROL_BLOCK *) termp; code = _nc_globals.term_driver(TCB, myname, errret); if (code == OK) { - termp->Filedes = (short) Filedes; termp->_termname = strdup(myname); } else { ret_error1(errret ? *errret : TGETENT_ERR, @@ -831,7 +834,7 @@ TINFO_SETUP_TERM(TERMINAL **tp, if (NC_ISATTY(Filedes)) { NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_ARG); NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_ARG); - baudrate(); + NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); } code = OK; #endif @@ -908,6 +911,7 @@ _nc_forget_prescr(void) { PRESCREEN_LIST *p, *q; pthread_t id = GetThreadID(); + _nc_lock_global(screen); for (p = _nc_prescreen.allocated, q = 0; p != 0; q = p, p = p->next) { if (p->id == id) { if (q) { @@ -919,6 +923,7 @@ _nc_forget_prescr(void) break; } } + _nc_unlock_global(screen); } #endif /* USE_PTHREADS */