]> git.draconx.ca Git - cdecl99.git/blob - lib/local/lib/hard-locale.h
cdecl99: Avoid gnulib setlocale_null bits.
[cdecl99.git] / lib / local / lib / hard-locale.h
1 /* Determine whether a locale is hard.
2  *
3  * Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2022 Free Software
4  * Foundation, Inc.
5  *
6  * Imported from Gnulib hard-locale.[ch] with modifications by Nick Bowler:
7  *
8  *  - Remove all setlocale workarounds, as our use case does not do anything
9  *    fancy with locales and does not require thread safety (2024-01).
10  *
11  * This file is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as
13  * published by the Free Software Foundation; either version 2.1 of the
14  * License, or (at your option) any later version.
15  *
16  * This file is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
23  */
24
25 #ifndef HARD_LOCALE_H_
26 #define HARD_LOCALE_H_
27
28 #include <string.h>
29 #include <locale.h>
30
31 static inline int hard_locale(int locale)
32 {
33         char *name;
34
35         if (!(name = setlocale(locale, NULL)))
36                 return 0;
37
38         return strcmp(name, "C") && strcmp(name, "POSIX");
39 }
40
41 #endif