]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_setup.c
ncurses 6.4 - patch 20240224
[ncurses.git] / ncurses / tinfo / lib_setup.c
index 71db2a8d431043a6479a5e381420233b4ff9b87e..4752ba899d4d884414a4cb17dcaedc46512cf93a 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey                                *
+ * Copyright 2018-2023,2024 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 <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.229 2023/10/16 23:05:28 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.231 2024/02/04 00:09:34 tom Exp $")
 
 /****************************************************************************
  *
@@ -293,7 +293,7 @@ _nc_default_screensize(TERMINAL *termp, int *linep, int *colp)
     }
 }
 
-#ifdef USE_CHECK_SIZE
+#if defined(USE_CHECK_SIZE) && defined(user6) && defined(user7)
 static const char *
 skip_csi(const char *value)
 {
@@ -408,7 +408,7 @@ _nc_check_screensize(TERMINAL *termp, int *linep, int *colp)
     _nc_default_screensize(termp, linep, colp);
 }
 #else /* !USE_CHECK_SIZE */
-#define _nc_check_screensize(termp, linep, colp) /* nothing */
+#define _nc_check_screensize(termp, linep, colp)       /* nothing */
 #endif
 #endif /* !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)) */
 
@@ -707,22 +707,27 @@ _nc_get_locale(void)
 NCURSES_EXPORT(int)
 _nc_unicode_locale(void)
 {
-    int result = 0;
+    static bool initialized = FALSE;
+    static int result = 0;
+
+    if (!initialized) {
 #if defined(_NC_WINDOWS) && USE_WIDEC_SUPPORT
-    result = 1;
+       result = 1;
 #elif HAVE_LANGINFO_CODESET
-    char *env = nl_langinfo(CODESET);
-    result = !strcmp(env, "UTF-8");
-    T(("_nc_unicode_locale(%s) ->%d", env, result));
+       char *env = nl_langinfo(CODESET);
+       result = !strcmp(env, "UTF-8");
+       T(("_nc_unicode_locale(%s) ->%d", env, result));
 #else
-    char *env = _nc_get_locale();
-    if (env != 0) {
-       if (strstr(env, ".UTF-8") != 0) {
-           result = 1;
-           T(("_nc_unicode_locale(%s) ->%d", env, result));
+       char *env = _nc_get_locale();
+       if (env != 0) {
+           if (strstr(env, ".UTF-8") != 0) {
+               result = 1;
+               T(("_nc_unicode_locale(%s) ->%d", env, result));
+           }
        }
-    }
 #endif
+       initialized = TRUE;
+    }
     return result;
 }