Home | History | Annotate | Line # | Download | only in locale
global_locale.c revision 1.27
      1  1.27  riastrad /* $NetBSD: global_locale.c,v 1.27 2024/06/07 13:53:12 riastradh Exp $ */
      2   1.1   tnozaki 
      3   1.1   tnozaki /*-
      4   1.1   tnozaki  * Copyright (c)2008 Citrus Project,
      5   1.1   tnozaki  * All rights reserved.
      6   1.1   tnozaki  *
      7   1.1   tnozaki  * Redistribution and use in source and binary forms, with or without
      8   1.1   tnozaki  * modification, are permitted provided that the following conditions
      9   1.1   tnozaki  * are met:
     10   1.1   tnozaki  * 1. Redistributions of source code must retain the above copyright
     11   1.1   tnozaki  *    notice, this list of conditions and the following disclaimer.
     12   1.1   tnozaki  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1   tnozaki  *    notice, this list of conditions and the following disclaimer in the
     14   1.1   tnozaki  *    documentation and/or other materials provided with the distribution.
     15   1.1   tnozaki  *
     16   1.1   tnozaki  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17   1.1   tnozaki  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18   1.1   tnozaki  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19   1.1   tnozaki  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20   1.1   tnozaki  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21   1.1   tnozaki  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22   1.1   tnozaki  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23   1.1   tnozaki  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24   1.1   tnozaki  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25   1.1   tnozaki  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26   1.1   tnozaki  * SUCH DAMAGE.
     27   1.1   tnozaki  */
     28   1.1   tnozaki 
     29   1.1   tnozaki #include <sys/cdefs.h>
     30   1.1   tnozaki #if defined(LIBC_SCCS) && !defined(lint)
     31  1.27  riastrad __RCSID("$NetBSD: global_locale.c,v 1.27 2024/06/07 13:53:12 riastradh Exp $");
     32   1.1   tnozaki #endif /* LIBC_SCCS and not lint */
     33   1.1   tnozaki 
     34   1.1   tnozaki #include <sys/types.h>
     35   1.9   tnozaki #include <sys/ctype_bits.h>
     36   1.1   tnozaki #include <sys/localedef.h>
     37   1.1   tnozaki #include <langinfo.h>
     38   1.1   tnozaki #include <limits.h>
     39   1.1   tnozaki #define __SETLOCALE_SOURCE__
     40   1.1   tnozaki #include <locale.h>
     41   1.1   tnozaki #include <stdlib.h>
     42  1.12     joerg 
     43  1.10   tnozaki #include "runetype_local.h"
     44   1.1   tnozaki #include "setlocale_local.h"
     45   1.1   tnozaki 
     46  1.18     joerg static const _MessagesLocale _DefaultMessagesLocale = {
     47  1.18     joerg 	"^[Yy]",
     48  1.18     joerg 	"^[Nn]",
     49  1.18     joerg 	"yes",
     50  1.18     joerg 	"no"
     51  1.18     joerg };
     52  1.18     joerg 
     53  1.18     joerg static const _MonetaryLocale _DefaultMonetaryLocale = {
     54  1.18     joerg 	"",
     55  1.18     joerg 	"",
     56  1.18     joerg 	"",
     57  1.18     joerg 	"",
     58  1.18     joerg 	"",
     59  1.18     joerg 	"",
     60  1.18     joerg 	"",
     61  1.27  riastrad 	CHAR_MAX,
     62  1.27  riastrad 	CHAR_MAX,
     63  1.27  riastrad 	CHAR_MAX,
     64  1.27  riastrad 	CHAR_MAX,
     65  1.27  riastrad 	CHAR_MAX,
     66  1.27  riastrad 	CHAR_MAX,
     67  1.27  riastrad 	CHAR_MAX,
     68  1.27  riastrad 	CHAR_MAX,
     69  1.27  riastrad 	CHAR_MAX,
     70  1.27  riastrad 	CHAR_MAX,
     71  1.27  riastrad 	CHAR_MAX,
     72  1.27  riastrad 	CHAR_MAX,
     73  1.27  riastrad 	CHAR_MAX,
     74  1.27  riastrad 	CHAR_MAX
     75  1.18     joerg };
     76  1.18     joerg 
     77  1.18     joerg static const _NumericLocale _DefaultNumericLocale = {
     78  1.18     joerg 	".",
     79  1.18     joerg 	"",
     80  1.18     joerg 	""
     81  1.18     joerg };
     82  1.18     joerg 
     83  1.18     joerg static const _TimeLocale _DefaultTimeLocale =
     84  1.18     joerg {
     85  1.18     joerg 	{
     86  1.18     joerg 		"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
     87  1.18     joerg 	},
     88  1.18     joerg 	{
     89  1.18     joerg 		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
     90  1.18     joerg 		"Friday", "Saturday"
     91  1.18     joerg 	},
     92  1.18     joerg 	{
     93  1.18     joerg 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
     94  1.18     joerg 		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
     95  1.18     joerg 	},
     96  1.18     joerg 	{
     97  1.18     joerg 		"January", "February", "March", "April", "May", "June", "July",
     98  1.18     joerg 		"August", "September", "October", "November", "December"
     99  1.18     joerg 	},
    100  1.18     joerg 	{
    101  1.18     joerg 		"AM", "PM"
    102  1.18     joerg 	},
    103  1.18     joerg 	"%a %b %e %H:%M:%S %Y",
    104  1.18     joerg 	"%m/%d/%y",
    105  1.18     joerg 	"%H:%M:%S",
    106  1.18     joerg 	"%I:%M:%S %p"
    107  1.18     joerg };
    108  1.18     joerg 
    109  1.21     joerg static const char _lc_C_locale_name[] = _C_LOCALE;
    110  1.21     joerg 
    111  1.21     joerg __dso_hidden const struct _locale_cache_t _C_cache = {
    112  1.21     joerg     .ldata = {
    113   1.4   tnozaki 	.decimal_point		= __UNCONST("."),
    114   1.4   tnozaki 	.thousands_sep		= __UNCONST(""),
    115   1.4   tnozaki 	.grouping		= __UNCONST(""),
    116   1.4   tnozaki 	.int_curr_symbol	= __UNCONST(""),
    117   1.4   tnozaki 	.currency_symbol	= __UNCONST(""),
    118   1.4   tnozaki 	.mon_decimal_point	= __UNCONST(""),
    119   1.4   tnozaki 	.mon_thousands_sep	= __UNCONST(""),
    120   1.4   tnozaki 	.mon_grouping		= __UNCONST(""),
    121   1.4   tnozaki 	.positive_sign		= __UNCONST(""),
    122   1.4   tnozaki 	.negative_sign		= __UNCONST(""),
    123  1.26  riastrad 	.int_frac_digits	= CHAR_MAX,
    124  1.26  riastrad 	.frac_digits		= CHAR_MAX,
    125  1.26  riastrad 	.p_cs_precedes		= CHAR_MAX,
    126  1.26  riastrad 	.p_sep_by_space		= CHAR_MAX,
    127  1.26  riastrad 	.n_cs_precedes		= CHAR_MAX,
    128  1.26  riastrad 	.n_sep_by_space		= CHAR_MAX,
    129  1.26  riastrad 	.p_sign_posn		= CHAR_MAX,
    130  1.26  riastrad 	.n_sign_posn		= CHAR_MAX,
    131  1.26  riastrad 	.int_p_cs_precedes	= CHAR_MAX,
    132  1.26  riastrad 	.int_n_cs_precedes	= CHAR_MAX,
    133  1.26  riastrad 	.int_p_sep_by_space	= CHAR_MAX,
    134  1.26  riastrad 	.int_n_sep_by_space	= CHAR_MAX,
    135  1.26  riastrad 	.int_p_sign_posn	= CHAR_MAX,
    136  1.26  riastrad 	.int_n_sign_posn	= CHAR_MAX,
    137  1.21     joerg     },
    138  1.21     joerg     .monetary_name = _lc_C_locale_name,
    139  1.21     joerg     .numeric_name = _lc_C_locale_name,
    140   1.8   tnozaki };
    141   1.8   tnozaki 
    142  1.24  christos struct _locale _lc_global_locale = {
    143  1.21     joerg     .cache = &_C_cache,
    144   1.3   tnozaki     .query = { _C_LOCALE },
    145   1.1   tnozaki     .part_name = {
    146  1.21     joerg 	[(size_t)LC_ALL     ] = _lc_C_locale_name,
    147  1.21     joerg 	[(size_t)LC_COLLATE ] = _lc_C_locale_name,
    148  1.21     joerg 	[(size_t)LC_CTYPE   ] = _lc_C_locale_name,
    149  1.21     joerg 	[(size_t)LC_MONETARY] = _lc_C_locale_name,
    150  1.21     joerg 	[(size_t)LC_NUMERIC ] = _lc_C_locale_name,
    151  1.21     joerg 	[(size_t)LC_TIME    ] = _lc_C_locale_name,
    152  1.21     joerg 	[(size_t)LC_MESSAGES] = _lc_C_locale_name,
    153   1.1   tnozaki     },
    154   1.1   tnozaki     .part_impl = {
    155   1.1   tnozaki 	[(size_t)LC_ALL     ] = (_locale_part_t)NULL,
    156   1.1   tnozaki 	[(size_t)LC_COLLATE ] = (_locale_part_t)NULL,
    157   1.1   tnozaki 	[(size_t)LC_CTYPE   ] = (_locale_part_t)
    158   1.1   tnozaki 	    __UNCONST(&_DefaultRuneLocale),
    159   1.1   tnozaki 	[(size_t)LC_MONETARY] = (_locale_part_t)
    160   1.1   tnozaki 	    __UNCONST(&_DefaultMonetaryLocale),
    161   1.1   tnozaki 	[(size_t)LC_NUMERIC ] = (_locale_part_t)
    162   1.1   tnozaki 	    __UNCONST(&_DefaultNumericLocale),
    163   1.1   tnozaki 	[(size_t)LC_MESSAGES] = (_locale_part_t)
    164   1.1   tnozaki 	    __UNCONST(&_DefaultMessagesLocale),
    165  1.16     joerg 	[(size_t)LC_TIME] = (_locale_part_t)
    166  1.16     joerg 	    __UNCONST(&_DefaultTimeLocale),
    167   1.1   tnozaki     },
    168   1.1   tnozaki };
    169  1.17     joerg 
    170  1.24  christos const struct _locale _lc_C_locale = {
    171  1.21     joerg     .cache = &_C_cache,
    172  1.17     joerg     .query = { _C_LOCALE },
    173  1.17     joerg     .part_name = {
    174  1.21     joerg 	[(size_t)LC_ALL     ] = _lc_C_locale_name,
    175  1.21     joerg 	[(size_t)LC_COLLATE ] = _lc_C_locale_name,
    176  1.21     joerg 	[(size_t)LC_CTYPE   ] = _lc_C_locale_name,
    177  1.21     joerg 	[(size_t)LC_MONETARY] = _lc_C_locale_name,
    178  1.21     joerg 	[(size_t)LC_NUMERIC ] = _lc_C_locale_name,
    179  1.21     joerg 	[(size_t)LC_TIME    ] = _lc_C_locale_name,
    180  1.21     joerg 	[(size_t)LC_MESSAGES] = _lc_C_locale_name,
    181  1.17     joerg     },
    182  1.17     joerg     .part_impl = {
    183  1.17     joerg 	[(size_t)LC_ALL     ] = (_locale_part_t)NULL,
    184  1.17     joerg 	[(size_t)LC_COLLATE ] = (_locale_part_t)NULL,
    185  1.17     joerg 	[(size_t)LC_CTYPE   ] = (_locale_part_t)
    186  1.17     joerg 	    __UNCONST(&_DefaultRuneLocale),
    187  1.17     joerg 	[(size_t)LC_MONETARY] = (_locale_part_t)
    188  1.17     joerg 	    __UNCONST(&_DefaultMonetaryLocale),
    189  1.17     joerg 	[(size_t)LC_NUMERIC ] = (_locale_part_t)
    190  1.17     joerg 	    __UNCONST(&_DefaultNumericLocale),
    191  1.17     joerg 	[(size_t)LC_MESSAGES] = (_locale_part_t)
    192  1.17     joerg 	    __UNCONST(&_DefaultMessagesLocale),
    193  1.17     joerg 	[(size_t)LC_TIME] = (_locale_part_t)
    194  1.17     joerg 	    __UNCONST(&_DefaultTimeLocale),
    195  1.17     joerg     },
    196  1.17     joerg };
    197