libncurses: Import https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz changes

Change-Id: I3433d30ca01359fd2e3623ede96b531f0b39cbfa
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c
index 06b6f88..b817f49 100644
--- a/ncurses/tinfo/lib_data.c
+++ b/ncurses/tinfo/lib_data.c
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc.              *
+ * Copyright 2018-2022,2024 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 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            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.66 2013/08/24 17:28:24 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.89 2024/02/24 18:11:38 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
@@ -94,7 +95,9 @@
 NCURSES_EXPORT(int)
 _nc_alloc_screen(void)
 {
-    return ((my_screen = _nc_alloc_screen_sp()) != 0);
+    my_screen = _nc_alloc_screen_sp();
+    T(("_nc_alloc_screen_sp %p", my_screen));
+    return (my_screen != 0);
 }
 
 NCURSES_EXPORT(void)
@@ -137,12 +140,15 @@
 
     0,				/* slk_format */
 
+    2048,			/* getstr_limit */
+
     NULL,			/* safeprint_buf */
     0,				/* safeprint_used */
 
     TGETENT_0s,			/* tgetent_cache */
     0,				/* tgetent_index */
     0,				/* tgetent_sequence */
+    0,				/* terminal_count */
 
     0,				/* dbd_blob */
     0,				/* dbd_list */
@@ -150,6 +156,15 @@
     0,				/* dbd_time */
     { { 0, 0 } },		/* dbd_vars */
 
+#if HAVE_TSEARCH
+    NULL,			/* cached_tparm */
+    0,				/* count_tparm */
+#endif /* HAVE_TSEARCH */
+
+#ifdef USE_TERM_DRIVER
+    0,				/* term_driver */
+#endif
+
 #ifndef USE_SP_WINDOWLIST
     0,				/* _nc_windowlist */
 #endif
@@ -163,15 +178,27 @@
     0,				/* safeprint_rows */
 #endif
 
-#ifdef USE_TERM_DRIVER
-    0,				/* term_driver */
+#ifdef USE_PTHREADS
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_curses */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_prescreen */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_screen */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_update */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tst_tracef */
+    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tracef */
+    0,				/* nested_tracef */
+    0,				/* use_pthreads */
+#if USE_PTHREADS_EINTR
+    0,				/* read_thread */
 #endif
-
+#endif
+#if USE_WIDEC_SUPPORT
+    CHARS_0s,			/* key_name */
+#endif
 #ifdef TRACE
-    FALSE,			/* init_trace */
-    CHARS_0s,			/* trace_fname */
+    FALSE,			/* trace_opened */
     0,				/* trace_level */
     NULL,			/* trace_fp */
+    -1,				/* trace_fd */
 
     NULL,			/* tracearg_buf */
     0,				/* tracearg_used */
@@ -194,15 +221,8 @@
     0,				/* nested_tracef */
 #endif
 #endif /* TRACE */
-#ifdef USE_PTHREADS
-    PTHREAD_MUTEX_INITIALIZER,	/* mutex_curses */
-    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tst_tracef */
-    PTHREAD_MUTEX_INITIALIZER,	/* mutex_tracef */
-    0,				/* nested_tracef */
-    0,				/* use_pthreads */
-#endif
-#if USE_PTHREADS_EINTR
-    0,				/* read_thread */
+#if NO_LEAKS
+    FALSE,			/* leak_checking */
 #endif
 };
 
@@ -214,17 +234,11 @@
 #define RIPOFF_0s	{ RIPOFF_0 }
 
 NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
+    NULL,			/* allocated */
     TRUE,			/* use_env */
     FALSE,			/* filter_mode */
     A_NORMAL,			/* previous_attr */
-#ifndef USE_SP_RIPOFF
-    RIPOFF_0s,			/* ripoff */
-    NULL,			/* rsp */
-#endif
     {				/* tparm_state */
-#ifdef TRACE
-	NULL,			/* tname */
-#endif
 	NULL,			/* tparam_base */
 
 	STACK_FRAME_0s,		/* stack */
@@ -237,14 +251,21 @@
 	NULL,			/* fmt_buff */
 	0,			/* fmt_size */
 
-	NUM_VARS_0s,		/* dynamic_var */
 	NUM_VARS_0s,		/* static_vars */
+#ifdef TRACE
+	NULL,			/* tname */
+#endif
     },
     NULL,			/* saved_tty */
+    FALSE,			/* use_tioctl */
+    0,				/* _outch */
+#ifndef USE_SP_RIPOFF
+    RIPOFF_0s,			/* ripoff */
+    NULL,			/* rsp */
+#endif
 #if NCURSES_NO_PADDING
     FALSE,			/* flag to set if padding disabled  */
 #endif
-    0,				/* _outch */
 #if BROKEN_LINKER || USE_REENTRANT
     NULL,			/* real_acs_map */
     0,				/* LINES */
@@ -252,12 +273,13 @@
     8,				/* TABSIZE */
     1000,			/* ESCDELAY */
     0,				/* cur_term */
+#endif
 #ifdef TRACE
+#if BROKEN_LINKER || USE_REENTRANT
     0L,				/* _outchars */
     NULL,			/* _tputs_trace */
 #endif
 #endif
-    FALSE,			/* use_tioctl */
 };
 /* *INDENT-ON* */
 
@@ -287,6 +309,9 @@
     if (!initialized) {
 	initialized = TRUE;
 	_nc_mutex_init(&_nc_globals.mutex_curses);
+	_nc_mutex_init(&_nc_globals.mutex_prescreen);
+	_nc_mutex_init(&_nc_globals.mutex_screen);
+	_nc_mutex_init(&_nc_globals.mutex_update);
 	_nc_mutex_init(&_nc_globals.mutex_tst_tracef);
 	_nc_mutex_init(&_nc_globals.mutex_tracef);
     }
@@ -337,25 +362,28 @@
 NCURSES_EXPORT(int)
 _nc_mutex_lock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_lock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_lock(obj);
+    return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_mutex_trylock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_trylock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_trylock(obj);
+    return rc;
 }
 
 NCURSES_EXPORT(int)
 _nc_mutex_unlock(pthread_mutex_t * obj)
 {
-    if (_nc_use_pthreads == 0)
-	return 0;
-    return pthread_mutex_unlock(obj);
+    int rc = 0;
+    if (_nc_use_pthreads != 0)
+	rc = pthread_mutex_unlock(obj);
+    return rc;
 }
 #endif /* USE_PTHREADS */
 
@@ -371,7 +399,7 @@
     if ((pthread_sigmask))
 	return pthread_sigmask(how, newmask, oldmask);
     else
-	return sigprocmask(how, newmask, oldmask);
+	return (sigprocmask) (how, newmask, oldmask);
 }
 #endif
 #endif /* USE_PTHREADS */