Home | History | Annotate | Line # | Download | only in locale
      1  1.29     joerg /* $NetBSD: global_locale.c,v 1.29 2024/06/08 21:35:18 joerg 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.29     joerg __RCSID("$NetBSD: global_locale.c,v 1.29 2024/06/08 21:35:18 joerg Exp $");
     32   1.1   tnozaki #endif /* LIBC_SCCS and not lint */
     33   1.1   tnozaki 
     34  1.29     joerg #include "namespace.h"
     35  1.29     joerg 
     36   1.1   tnozaki #include <sys/types.h>
     37   1.9   tnozaki #include <sys/ctype_bits.h>
     38   1.1   tnozaki #include <sys/localedef.h>
     39  1.29     joerg #include <errno.h>
     40   1.1   tnozaki #include <langinfo.h>
     41   1.1   tnozaki #include <limits.h>
     42   1.1   tnozaki #define __SETLOCALE_SOURCE__
     43   1.1   tnozaki #include <locale.h>
     44   1.1   tnozaki #include <stdlib.h>
     45  1.12     joerg 
     46  1.10   tnozaki #include "runetype_local.h"
     47   1.1   tnozaki #include "setlocale_local.h"
     48   1.1   tnozaki 
     49  1.18     joerg static const _MessagesLocale _DefaultMessagesLocale = {
     50  1.18     joerg 	"^[Yy]",
     51  1.18     joerg 	"^[Nn]",
     52  1.18     joerg 	"yes",
     53  1.18     joerg 	"no"
     54  1.18     joerg };
     55  1.18     joerg 
     56  1.18     joerg static const _MonetaryLocale _DefaultMonetaryLocale = {
     57  1.18     joerg 	"",
     58  1.18     joerg 	"",
     59  1.18     joerg 	"",
     60  1.18     joerg 	"",
     61  1.18     joerg 	"",
     62  1.18     joerg 	"",
     63  1.18     joerg 	"",
     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.27  riastrad 	CHAR_MAX,
     76  1.27  riastrad 	CHAR_MAX,
     77  1.27  riastrad 	CHAR_MAX
     78  1.18     joerg };
     79  1.18     joerg 
     80  1.18     joerg static const _NumericLocale _DefaultNumericLocale = {
     81  1.18     joerg 	".",
     82  1.18     joerg 	"",
     83  1.18     joerg 	""
     84  1.18     joerg };
     85  1.18     joerg 
     86  1.18     joerg static const _TimeLocale _DefaultTimeLocale =
     87  1.18     joerg {
     88  1.18     joerg 	{
     89  1.18     joerg 		"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
     90  1.18     joerg 	},
     91  1.18     joerg 	{
     92  1.18     joerg 		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
     93  1.18     joerg 		"Friday", "Saturday"
     94  1.18     joerg 	},
     95  1.18     joerg 	{
     96  1.18     joerg 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
     97  1.18     joerg 		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
     98  1.18     joerg 	},
     99  1.18     joerg 	{
    100  1.18     joerg 		"January", "February", "March", "April", "May", "June", "July",
    101  1.18     joerg 		"August", "September", "October", "November", "December"
    102  1.18     joerg 	},
    103  1.18     joerg 	{
    104  1.18     joerg 		"AM", "PM"
    105  1.18     joerg 	},
    106  1.18     joerg 	"%a %b %e %H:%M:%S %Y",
    107  1.18     joerg 	"%m/%d/%y",
    108  1.18     joerg 	"%H:%M:%S",
    109  1.18     joerg 	"%I:%M:%S %p"
    110  1.18     joerg };
    111  1.18     joerg 
    112  1.21     joerg static const char _lc_C_locale_name[] = _C_LOCALE;
    113  1.21     joerg 
    114  1.21     joerg __dso_hidden const struct _locale_cache_t _C_cache = {
    115  1.21     joerg     .ldata = {
    116   1.4   tnozaki 	.decimal_point		= __UNCONST("."),
    117   1.4   tnozaki 	.thousands_sep		= __UNCONST(""),
    118   1.4   tnozaki 	.grouping		= __UNCONST(""),
    119   1.4   tnozaki 	.int_curr_symbol	= __UNCONST(""),
    120   1.4   tnozaki 	.currency_symbol	= __UNCONST(""),
    121   1.4   tnozaki 	.mon_decimal_point	= __UNCONST(""),
    122   1.4   tnozaki 	.mon_thousands_sep	= __UNCONST(""),
    123   1.4   tnozaki 	.mon_grouping		= __UNCONST(""),
    124   1.4   tnozaki 	.positive_sign		= __UNCONST(""),
    125   1.4   tnozaki 	.negative_sign		= __UNCONST(""),
    126  1.26  riastrad 	.int_frac_digits	= CHAR_MAX,
    127  1.26  riastrad 	.frac_digits		= CHAR_MAX,
    128  1.26  riastrad 	.p_cs_precedes		= CHAR_MAX,
    129  1.26  riastrad 	.p_sep_by_space		= CHAR_MAX,
    130  1.26  riastrad 	.n_cs_precedes		= CHAR_MAX,
    131  1.26  riastrad 	.n_sep_by_space		= CHAR_MAX,
    132  1.26  riastrad 	.p_sign_posn		= CHAR_MAX,
    133  1.26  riastrad 	.n_sign_posn		= CHAR_MAX,
    134  1.26  riastrad 	.int_p_cs_precedes	= CHAR_MAX,
    135  1.26  riastrad 	.int_n_cs_precedes	= CHAR_MAX,
    136  1.26  riastrad 	.int_p_sep_by_space	= CHAR_MAX,
    137  1.26  riastrad 	.int_n_sep_by_space	= CHAR_MAX,
    138  1.26  riastrad 	.int_p_sign_posn	= CHAR_MAX,
    139  1.26  riastrad 	.int_n_sign_posn	= CHAR_MAX,
    140  1.21     joerg     },
    141  1.21     joerg     .monetary_name = _lc_C_locale_name,
    142  1.21     joerg     .numeric_name = _lc_C_locale_name,
    143  1.29     joerg     .message_name = _lc_C_locale_name,
    144  1.29     joerg     .errlistp = &sys_errlist,
    145  1.29     joerg     .errlist_prefix = "Unknown error: %d",
    146   1.8   tnozaki };
    147   1.8   tnozaki 
    148  1.24  christos struct _locale _lc_global_locale = {
    149  1.21     joerg     .cache = &_C_cache,
    150   1.3   tnozaki     .query = { _C_LOCALE },
    151   1.1   tnozaki     .part_name = {
    152  1.28  riastrad 	[LC_ALL     ] = _lc_C_locale_name,
    153  1.28  riastrad 	[LC_COLLATE ] = _lc_C_locale_name,
    154  1.28  riastrad 	[LC_CTYPE   ] = _lc_C_locale_name,
    155  1.28  riastrad 	[LC_MONETARY] = _lc_C_locale_name,
    156  1.28  riastrad 	[LC_NUMERIC ] = _lc_C_locale_name,
    157  1.28  riastrad 	[LC_TIME    ] = _lc_C_locale_name,
    158  1.28  riastrad 	[LC_MESSAGES] = _lc_C_locale_name,
    159   1.1   tnozaki     },
    160   1.1   tnozaki     .part_impl = {
    161  1.28  riastrad 	[LC_ALL     ] = (_locale_part_t)NULL,
    162  1.28  riastrad 	[LC_COLLATE ] = (_locale_part_t)NULL,
    163  1.28  riastrad 	[LC_CTYPE   ] = (_locale_part_t)
    164   1.1   tnozaki 	    __UNCONST(&_DefaultRuneLocale),
    165  1.28  riastrad 	[LC_MONETARY] = (_locale_part_t)
    166   1.1   tnozaki 	    __UNCONST(&_DefaultMonetaryLocale),
    167  1.28  riastrad 	[LC_NUMERIC ] = (_locale_part_t)
    168   1.1   tnozaki 	    __UNCONST(&_DefaultNumericLocale),
    169  1.28  riastrad 	[LC_MESSAGES] = (_locale_part_t)
    170   1.1   tnozaki 	    __UNCONST(&_DefaultMessagesLocale),
    171  1.28  riastrad 	[LC_TIME] = (_locale_part_t)
    172  1.16     joerg 	    __UNCONST(&_DefaultTimeLocale),
    173   1.1   tnozaki     },
    174   1.1   tnozaki };
    175  1.17     joerg 
    176  1.24  christos const struct _locale _lc_C_locale = {
    177  1.21     joerg     .cache = &_C_cache,
    178  1.17     joerg     .query = { _C_LOCALE },
    179  1.17     joerg     .part_name = {
    180  1.28  riastrad 	[LC_ALL     ] = _lc_C_locale_name,
    181  1.28  riastrad 	[LC_COLLATE ] = _lc_C_locale_name,
    182  1.28  riastrad 	[LC_CTYPE   ] = _lc_C_locale_name,
    183  1.28  riastrad 	[LC_MONETARY] = _lc_C_locale_name,
    184  1.28  riastrad 	[LC_NUMERIC ] = _lc_C_locale_name,
    185  1.28  riastrad 	[LC_TIME    ] = _lc_C_locale_name,
    186  1.28  riastrad 	[LC_MESSAGES] = _lc_C_locale_name,
    187  1.17     joerg     },
    188  1.17     joerg     .part_impl = {
    189  1.28  riastrad 	[LC_ALL     ] = (_locale_part_t)NULL,
    190  1.28  riastrad 	[LC_COLLATE ] = (_locale_part_t)NULL,
    191  1.28  riastrad 	[LC_CTYPE   ] = (_locale_part_t)
    192  1.17     joerg 	    __UNCONST(&_DefaultRuneLocale),
    193  1.28  riastrad 	[LC_MONETARY] = (_locale_part_t)
    194  1.17     joerg 	    __UNCONST(&_DefaultMonetaryLocale),
    195  1.28  riastrad 	[LC_NUMERIC ] = (_locale_part_t)
    196  1.17     joerg 	    __UNCONST(&_DefaultNumericLocale),
    197  1.28  riastrad 	[LC_MESSAGES] = (_locale_part_t)
    198  1.17     joerg 	    __UNCONST(&_DefaultMessagesLocale),
    199  1.28  riastrad 	[LC_TIME] = (_locale_part_t)
    200  1.17     joerg 	    __UNCONST(&_DefaultTimeLocale),
    201  1.17     joerg     },
    202  1.17     joerg };
    203