+2025-02-14 Bruno Haible <bruno@clisp.org>
+
+ localename-environ: New module.
+ * lib/localename-environ.c: New file, extracted from
+ lib/localename-unsafe.c.
+ * lib/localename-unsafe.c (gl_locale_name_environ): Remove function.
+ * m4/localename.m4 (gl_LOCALENAME_ENVIRON): New macro.
+ * modules/localename-environ: New file.
+ * modules/localename-unsafe (Depends-on): Add localename-environ.
+ * modules/setlocale (Depends-on): Likewise.
+
2025-02-13 Bruno Haible <bruno@clisp.org>
locale-h: Ensure locale_t type.
--- /dev/null
+/* Determine name of the currently selected locale.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
+
+#include <config.h>
+
+/* Specification. */
+#include "localename.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+const char *
+gl_locale_name_environ (_GL_UNUSED int category, const char *categoryname)
+{
+ const char *retval;
+
+ /* Setting of LC_ALL overrides all other. */
+ retval = getenv ("LC_ALL");
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+ /* Next comes the name of the desired category. */
+ retval = getenv (categoryname);
+ if (retval != NULL && retval[0] != '\0')
+ return retval;
+ /* Last possibility is the LANG environment variable. */
+ retval = getenv ("LANG");
+ if (retval != NULL && retval[0] != '\0')
+ {
+#if HAVE_CFPREFERENCESCOPYAPPVALUE
+ /* Mac OS X 10.2 or newer.
+ Ignore invalid LANG value set by the Terminal application. */
+ if (strcmp (retval, "UTF-8") != 0)
+#endif
+#if defined __CYGWIN__
+ /* Cygwin.
+ Ignore dummy LANG value set by ~/.profile. */
+ if (strcmp (retval, "C.UTF-8") != 0)
+#endif
+ return retval;
+ }
+
+ return NULL;
+}
}
}
-const char *
-gl_locale_name_environ (_GL_UNUSED int category, const char *categoryname)
-{
- const char *retval;
-
- /* Setting of LC_ALL overrides all other. */
- retval = getenv ("LC_ALL");
- if (retval != NULL && retval[0] != '\0')
- return retval;
- /* Next comes the name of the desired category. */
- retval = getenv (categoryname);
- if (retval != NULL && retval[0] != '\0')
- return retval;
- /* Last possibility is the LANG environment variable. */
- retval = getenv ("LANG");
- if (retval != NULL && retval[0] != '\0')
- {
-#if HAVE_CFPREFERENCESCOPYAPPVALUE
- /* Mac OS X 10.2 or newer.
- Ignore invalid LANG value set by the Terminal application. */
- if (strcmp (retval, "UTF-8") != 0)
-#endif
-#if defined __CYGWIN__
- /* Cygwin.
- Ignore dummy LANG value set by ~/.profile. */
- if (strcmp (retval, "C.UTF-8") != 0)
-#endif
- return retval;
- }
-
- return NULL;
-}
-
const char *
gl_locale_name_default (void)
{
# localename.m4
-# serial 12
+# serial 13
dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_REQUIRE([gt_LC_MESSAGES])
AC_REQUIRE([gt_INTL_THREAD_LOCALE_NAME])
])
+
+AC_DEFUN([gl_LOCALENAME_ENVIRON],
+[
+ AC_REQUIRE([gt_INTL_MACOSX])
+])
--- /dev/null
+Description:
+Return current locale's name, as specified by environment variables.
+
+Files:
+lib/localename.h
+lib/localename-environ.c
+m4/localename.m4
+m4/intlmacosx.m4
+
+Depends-on:
+
+configure.ac:
+gl_LOCALENAME_ENVIRON
+gl_LOCALE_MODULE_INDICATOR([localename-environ])
+
+Makefile.am:
+lib_SOURCES += localename-environ.c
+
+Include:
+"localename.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
Depends-on:
localename-unsafe-limited
+localename-environ
extensions
bool
locale-h
Depends-on:
locale-h
-localename [test $NEED_SETLOCALE_IMPROVED = 1]
-setlocale-null [test $NEED_SETLOCALE_MTSAFE = 1]
+localename [test $NEED_SETLOCALE_IMPROVED = 1]
+localename-environ [test $NEED_SETLOCALE_IMPROVED = 1]
+setlocale-null [test $NEED_SETLOCALE_MTSAFE = 1]
configure.ac:
gl_FUNC_SETLOCALE