xref: /Universal-ctags/gnulib/hard-locale.c (revision 820c1a8d46849a90376d8eb15b319ac05439f656)
1*820c1a8dSHiroo HAYASHI /* hard-locale.c -- Determine whether a locale is hard.
2*820c1a8dSHiroo HAYASHI 
3*820c1a8dSHiroo HAYASHI    Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2021 Free Software
4*820c1a8dSHiroo HAYASHI    Foundation, Inc.
5*820c1a8dSHiroo HAYASHI 
6*820c1a8dSHiroo HAYASHI    This file is free software: you can redistribute it and/or modify
7*820c1a8dSHiroo HAYASHI    it under the terms of the GNU Lesser General Public License as
8*820c1a8dSHiroo HAYASHI    published by the Free Software Foundation; either version 2.1 of the
9*820c1a8dSHiroo HAYASHI    License, or (at your option) any later version.
10*820c1a8dSHiroo HAYASHI 
11*820c1a8dSHiroo HAYASHI    This file is distributed in the hope that it will be useful,
12*820c1a8dSHiroo HAYASHI    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*820c1a8dSHiroo HAYASHI    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*820c1a8dSHiroo HAYASHI    GNU Lesser General Public License for more details.
15*820c1a8dSHiroo HAYASHI 
16*820c1a8dSHiroo HAYASHI    You should have received a copy of the GNU Lesser General Public License
17*820c1a8dSHiroo HAYASHI    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
18*820c1a8dSHiroo HAYASHI 
19*820c1a8dSHiroo HAYASHI #include <config.h>
20*820c1a8dSHiroo HAYASHI 
21*820c1a8dSHiroo HAYASHI #include "hard-locale.h"
22*820c1a8dSHiroo HAYASHI 
23*820c1a8dSHiroo HAYASHI #include <locale.h>
24*820c1a8dSHiroo HAYASHI #include <string.h>
25*820c1a8dSHiroo HAYASHI 
26*820c1a8dSHiroo HAYASHI bool
hard_locale(int category)27*820c1a8dSHiroo HAYASHI hard_locale (int category)
28*820c1a8dSHiroo HAYASHI {
29*820c1a8dSHiroo HAYASHI   char locale[SETLOCALE_NULL_MAX];
30*820c1a8dSHiroo HAYASHI 
31*820c1a8dSHiroo HAYASHI   if (setlocale_null_r (category, locale, sizeof (locale)))
32*820c1a8dSHiroo HAYASHI     return false;
33*820c1a8dSHiroo HAYASHI 
34*820c1a8dSHiroo HAYASHI   return !(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0);
35*820c1a8dSHiroo HAYASHI }
36