summaryrefslogtreecommitdiffstats
path: root/gl/nl_langinfo.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2026-03-26 12:53:53 +0100
committerGitHub <noreply@github.com>2026-03-26 12:53:53 +0100
commit13e14a6bfd9f29cbfeab0c5161d2a994f97532e7 (patch)
tree3aa7186fe092e42783dc7e981dc39a74ea61c466 /gl/nl_langinfo.c
parent9d8503f90ef25b2cecd324dc118e441f40233ea8 (diff)
downloadmonitoring-plugins-13e14a6bfd9f29cbfeab0c5161d2a994f97532e7.tar.gz
Update/gnulib 2026 03 (#2247)HEADmaster
* Sync with the 202601-stable Gnulib code (4a3650d887) * Ignore more deps stuff in gnulib * Remove autogenerated gnulib files * Ignore more gnulib generated headers
Diffstat (limited to 'gl/nl_langinfo.c')
-rw-r--r--gl/nl_langinfo.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c
index 0180c26a..ff8fd89e 100644
--- a/gl/nl_langinfo.c
+++ b/gl/nl_langinfo.c
@@ -1,6 +1,6 @@
1/* nl_langinfo() replacement: query locale dependent information. 1/* nl_langinfo() replacement: query locale dependent information.
2 2
3 Copyright (C) 2007-2025 Free Software Foundation, Inc. 3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -79,15 +79,13 @@ ctype_codeset (void)
79 /* This function is only used on platforms which don't have uselocale(). 79 /* This function is only used on platforms which don't have uselocale().
80 Therefore we don't need to look at the per-thread locale first, here. */ 80 Therefore we don't need to look at the per-thread locale first, here. */
81 static char result[2 + 10 + 1]; 81 static char result[2 + 10 + 1];
82 char buf[2 + 10 + 1];
83 char locale[SETLOCALE_NULL_MAX];
84 char *codeset;
85 size_t codesetlen;
86 82
83 char locale[SETLOCALE_NULL_MAX];
87 if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale))) 84 if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale)))
88 locale[0] = '\0'; 85 locale[0] = '\0';
89 86
90 codeset = buf; 87 char buf[2 + 10 + 1];
88 char *codeset = buf;
91 codeset[0] = '\0'; 89 codeset[0] = '\0';
92 90
93 if (locale[0]) 91 if (locale[0])
@@ -105,7 +103,7 @@ ctype_codeset (void)
105 codeset = codeset_start; 103 codeset = codeset_start;
106 else 104 else
107 { 105 {
108 codesetlen = modifier - codeset_start; 106 size_t codesetlen = modifier - codeset_start;
109 if (codesetlen < sizeof buf) 107 if (codesetlen < sizeof buf)
110 { 108 {
111 codeset = memcpy (buf, codeset_start, codesetlen); 109 codeset = memcpy (buf, codeset_start, codesetlen);
@@ -121,14 +119,14 @@ ctype_codeset (void)
121 GetACP, which returns the locale's codepage as a number (although 119 GetACP, which returns the locale's codepage as a number (although
122 this doesn't change according to what the 'setlocale' call specified). 120 this doesn't change according to what the 'setlocale' call specified).
123 Either way, prepend "CP" to make it a valid codeset name. */ 121 Either way, prepend "CP" to make it a valid codeset name. */
124 codesetlen = strlen (codeset); 122 size_t codesetlen = strlen (codeset);
125 if (0 < codesetlen && codesetlen < sizeof buf - 2) 123 if (0 < codesetlen && codesetlen < sizeof buf - 2)
126 memmove (buf + 2, codeset, codesetlen + 1); 124 memmove (buf + 2, codeset, codesetlen + 1);
127 else 125 else
128 sprintf (buf + 2, "%u", GetACP ()); 126 sprintf (buf + 2, "%u", GetACP ());
129 /* For a locale name such as "French_France.65001", in Windows 10, 127 /* For a locale name such as "French_France.65001", in Windows 10,
130 setlocale now returns "French_France.utf8" instead. */ 128 setlocale now returns "French_France.utf8" instead. */
131 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0) 129 if (streq (buf + 2, "65001") || streq (buf + 2, "utf8"))
132 return (char *) "UTF-8"; 130 return (char *) "UTF-8";
133 else 131 else
134 { 132 {
@@ -209,10 +207,9 @@ static char *
209nl_langinfo_with_lock (nl_item item) 207nl_langinfo_with_lock (nl_item item)
210{ 208{
211 CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock (); 209 CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock ();
212 char *ret;
213 210
214 EnterCriticalSection (lock); 211 EnterCriticalSection (lock);
215 ret = nl_langinfo_unlocked (item); 212 char *ret = nl_langinfo_unlocked (item);
216 LeaveCriticalSection (lock); 213 LeaveCriticalSection (lock);
217 214
218 return ret; 215 return ret;
@@ -248,11 +245,10 @@ nl_langinfo_with_lock (nl_item item)
248 if (pthread_in_use()) 245 if (pthread_in_use())
249 { 246 {
250 pthread_mutex_t *lock = gl_get_nl_langinfo_lock (); 247 pthread_mutex_t *lock = gl_get_nl_langinfo_lock ();
251 char *ret;
252 248
253 if (pthread_mutex_lock (lock)) 249 if (pthread_mutex_lock (lock))
254 abort (); 250 abort ();
255 ret = nl_langinfo_unlocked (item); 251 char *ret = nl_langinfo_unlocked (item);
256 if (pthread_mutex_unlock (lock)) 252 if (pthread_mutex_unlock (lock))
257 abort (); 253 abort ();
258 254
@@ -270,11 +266,10 @@ static char *
270nl_langinfo_with_lock (nl_item item) 266nl_langinfo_with_lock (nl_item item)
271{ 267{
272 mtx_t *lock = gl_get_nl_langinfo_lock (); 268 mtx_t *lock = gl_get_nl_langinfo_lock ();
273 char *ret;
274 269
275 if (mtx_lock (lock) != thrd_success) 270 if (mtx_lock (lock) != thrd_success)
276 abort (); 271 abort ();
277 ret = nl_langinfo_unlocked (item); 272 char *ret = nl_langinfo_unlocked (item);
278 if (mtx_unlock (lock) != thrd_success) 273 if (mtx_unlock (lock) != thrd_success)
279 abort (); 274 abort ();
280 275
@@ -299,10 +294,6 @@ rpl_nl_langinfo (nl_item item)
299 case CODESET: 294 case CODESET:
300 return ctype_codeset (); 295 return ctype_codeset ();
301# endif 296# endif
302# if GNULIB_defined_T_FMT_AMPM
303 case T_FMT_AMPM:
304 return (char *) "%I:%M:%S %p";
305# endif
306# if GNULIB_defined_ALTMON 297# if GNULIB_defined_ALTMON
307 case ALTMON_1: 298 case ALTMON_1:
308 case ALTMON_2: 299 case ALTMON_2:
@@ -365,12 +356,6 @@ rpl_nl_langinfo (nl_item item)
365 strings, appended in memory. */ 356 strings, appended in memory. */
366 return (char *) "\0\0\0\0\0\0\0\0\0\0"; 357 return (char *) "\0\0\0\0\0\0\0\0\0\0";
367# endif 358# endif
368# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
369 case YESEXPR:
370 return (char *) "^[yY]";
371 case NOEXPR:
372 return (char *) "^[nN]";
373# endif
374 default: 359 default:
375 break; 360 break;
376 } 361 }