X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_setup.c;h=4752ba899d4d884414a4cb17dcaedc46512cf93a;hp=f2d2bb36344ca9f9d0bc18bb9c58fb01f9321887;hb=19c0d4acfed45a13096019aa305a63b657fdb24c;hpb=c5ffd7a7937e457fc772888b61a15544e4244c32 diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index f2d2bb36..4752ba89 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -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 #endif -MODULE_ID("$Id: lib_setup.c,v 1.230 2023/11/04 21:02:27 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.231 2024/02/04 00:09:34 tom Exp $") /**************************************************************************** * @@ -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; }