| 1 |
/* Make the global locale minimally POSIX compliant. |
| 2 |
Copyright (C) 2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This file is free software: you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU Lesser General Public License as |
| 6 |
published by the Free Software Foundation; either version 2.1 of the |
| 7 |
License, or (at your option) any later version. |
| 8 |
|
| 9 |
This file is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
/* Written by Bruno Haible <[email protected]>, 2025. */ |
| 18 |
|
| 19 |
#ifndef _SETLOCALE_FIXES_H |
| 20 |
#define _SETLOCALE_FIXES_H |
| 21 |
|
| 22 |
#ifdef __cplusplus |
| 23 |
extern "C" { |
| 24 |
#endif |
| 25 |
|
| 26 |
|
| 27 |
#if defined _WIN32 && !defined __CYGWIN__ |
| 28 |
|
| 29 |
/* This section is only relevant on platforms that lack LC_MESSAGES, namely |
| 30 |
native Windows. */ |
| 31 |
|
| 32 |
/* setlocale_messages (NAME) is like setlocale (LC_MESSAGES, NAME). */ |
| 33 |
extern const char *setlocale_messages (const char *name); |
| 34 |
|
| 35 |
/* setlocale_messages_null () is like setlocale (LC_MESSAGES, NULL), except that |
| 36 |
it is guaranteed to be multithread-safe. */ |
| 37 |
extern const char *setlocale_messages_null (void); |
| 38 |
|
| 39 |
#endif |
| 40 |
|
| 41 |
|
| 42 |
#if defined __ANDROID__ |
| 43 |
|
| 44 |
/* This section is only relevant on Android. |
| 45 |
While OpenBSD ≥ 6.2 and Android API level >= 21 have a fake locale_t type, |
| 46 |
regarding the global locale, OpenBSD at least stores the name of each |
| 47 |
category of the global locale. Android doesn't do this, and additionally |
| 48 |
has a bug: setting any category != LC_CTYPE of the global locale affects |
| 49 |
the LC_CTYPE category as well. */ |
| 50 |
|
| 51 |
/* Like setlocale (CATEGORY, NAME), but fixes these two Android bugs. */ |
| 52 |
extern const char *setlocale_fixed (int category, const char *name); |
| 53 |
|
| 54 |
/* Like setlocale_null (CATEGORY), but consistent with setlocale_fixed. */ |
| 55 |
extern const char *setlocale_fixed_null (int category); |
| 56 |
|
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
#ifdef __cplusplus |
| 61 |
} |
| 62 |
#endif |
| 63 |
|
| 64 |
#endif /* _SETLOCALE_FIXES_H */ |