003 File Manager
Current Path:
/usr/src/lib/libc/locale
usr
/
src
/
lib
/
libc
/
locale
/
📁
..
📄
DESIGN.xlocale
(7.32 KB)
📄
Makefile.inc
(3.43 KB)
📄
Symbol.map
(2.59 KB)
📄
ascii.c
(5.08 KB)
📄
big5.5
(2.24 KB)
📄
big5.c
(5.2 KB)
📄
btowc.3
(2.48 KB)
📄
btowc.c
(2.14 KB)
📄
c16rtomb.c
(2.59 KB)
📄
c16rtomb_iconv.c
(190 B)
📄
c32rtomb.c
(2.06 KB)
📄
c32rtomb_iconv.c
(190 B)
📄
cXXrtomb_iconv.h
(3.42 KB)
📄
collate.c
(16.18 KB)
📄
collate.h
(4.7 KB)
📄
collcmp.c
(2.02 KB)
📄
ctype.3
(3.55 KB)
📄
ctype.c
(1.58 KB)
📄
ctype_l.3
(3.86 KB)
📄
digittoint.3
(2.51 KB)
📄
duplocale.3
(2.66 KB)
📄
euc.5
(3.76 KB)
📄
euc.c
(11.7 KB)
📄
fix_grouping.c
(2.49 KB)
📄
freelocale.3
(2.09 KB)
📄
gb18030.5
(2.92 KB)
📄
gb18030.c
(6.26 KB)
📄
gb2312.5
(2.11 KB)
📄
gb2312.c
(4.96 KB)
📄
gbk.5
(2.44 KB)
📄
gbk.c
(5.07 KB)
📄
isalnum.3
(4.19 KB)
📄
isalpha.3
(4.02 KB)
📄
isascii.3
(1.99 KB)
📄
isblank.3
(2.94 KB)
📄
iscntrl.3
(3.56 KB)
📄
isctype.c
(3.87 KB)
📄
isdigit.3
(3.49 KB)
📄
isgraph.3
(4.72 KB)
📄
isideogram.3
(1.87 KB)
📄
islower.3
(3.55 KB)
📄
isphonogram.3
(1.88 KB)
📄
isprint.3
(4.43 KB)
📄
ispunct.3
(3.71 KB)
📄
isrune.3
(1.94 KB)
📄
isspace.3
(3.22 KB)
📄
isspecial.3
(1.83 KB)
📄
isupper.3
(3.29 KB)
📄
iswalnum.3
(3.96 KB)
📄
iswalnum_l.3
(4.47 KB)
📄
iswctype.c
(3.73 KB)
📄
isxdigit.3
(3.34 KB)
📄
ldpart.c
(4.19 KB)
📄
ldpart.h
(1.65 KB)
📄
lmessages.c
(3.67 KB)
📄
lmessages.h
(1.91 KB)
📄
lmonetary.c
(6.51 KB)
📄
lmonetary.h
(2.54 KB)
📄
lnumeric.c
(3.74 KB)
📄
lnumeric.h
(2 KB)
📄
localeconv.3
(6.66 KB)
📄
localeconv.c
(3.95 KB)
📄
mblen.3
(3.2 KB)
📄
mblen.c
(2.16 KB)
📄
mblocal.h
(4.86 KB)
📄
mbrlen.3
(3.49 KB)
📄
mbrlen.c
(2.01 KB)
📄
mbrtoc16.c
(2.85 KB)
📄
mbrtoc16_iconv.c
(190 B)
📄
mbrtoc32.c
(1.95 KB)
📄
mbrtoc32_iconv.c
(190 B)
📄
mbrtocXX_iconv.h
(4.62 KB)
📄
mbrtowc.3
(4.09 KB)
📄
mbrtowc.c
(2.07 KB)
📄
mbsinit.3
(2.01 KB)
📄
mbsinit.c
(1.84 KB)
📄
mbsnrtowcs.c
(3.14 KB)
📄
mbsrtowcs.3
(3.71 KB)
📄
mbsrtowcs.c
(2.17 KB)
📄
mbstowcs.3
(2.94 KB)
📄
mbstowcs.c
(2.1 KB)
📄
mbtowc.3
(3.37 KB)
📄
mbtowc.c
(2.32 KB)
📄
mskanji.5
(2.36 KB)
📄
mskanji.c
(5.29 KB)
📄
multibyte.3
(4.88 KB)
📄
newlocale.3
(3.64 KB)
📄
nextwctype.3
(2.09 KB)
📄
nextwctype.c
(3.02 KB)
📄
nl_langinfo.3
(7.85 KB)
📄
nl_langinfo.c
(6.14 KB)
📄
nomacros.c
(474 B)
📄
none.c
(5.69 KB)
📄
querylocale.3
(2.66 KB)
📄
rpmatch.3
(2.04 KB)
📄
rpmatch.c
(1.92 KB)
📄
rune.c
(6.88 KB)
📄
runefile.h
(1.96 KB)
📄
runetype.c
(2.88 KB)
📄
setlocale.3
(5.58 KB)
📄
setlocale.c
(7.81 KB)
📄
setlocale.h
(1.62 KB)
📄
setrunelocale.c
(6.31 KB)
📄
table.c
(9.79 KB)
📄
toascii.3
(2.27 KB)
📄
tolower.3
(2.73 KB)
📄
tolower.c
(2.61 KB)
📄
toupper.3
(2.73 KB)
📄
toupper.c
(2.62 KB)
📄
towlower.3
(2.45 KB)
📄
towupper.3
(2.45 KB)
📄
uselocale.3
(2.14 KB)
📄
utf8.5
(3.66 KB)
📄
utf8.c
(10 KB)
📄
wcrtomb.3
(3.18 KB)
📄
wcrtomb.c
(2 KB)
📄
wcsftime.3
(2.08 KB)
📄
wcsftime.c
(3.99 KB)
📄
wcsnrtombs.c
(3.67 KB)
📄
wcsrtombs.3
(3.39 KB)
📄
wcsrtombs.c
(2.17 KB)
📄
wcstod.3
(2.13 KB)
📄
wcstod.c
(3.73 KB)
📄
wcstof.c
(2.7 KB)
📄
wcstoimax.c
(3.85 KB)
📄
wcstol.3
(2.8 KB)
📄
wcstol.c
(3.56 KB)
📄
wcstold.c
(2.73 KB)
📄
wcstoll.c
(3.85 KB)
📄
wcstombs.3
(3.01 KB)
📄
wcstombs.c
(2.12 KB)
📄
wcstoul.c
(3.53 KB)
📄
wcstoull.c
(3.8 KB)
📄
wcstoumax.c
(3.77 KB)
📄
wctob.c
(2 KB)
📄
wctomb.3
(3.21 KB)
📄
wctomb.c
(2.14 KB)
📄
wctrans.3
(3.01 KB)
📄
wctrans.c
(2.74 KB)
📄
wctype.3
(3 KB)
📄
wctype.c
(3.03 KB)
📄
wcwidth.3
(2.43 KB)
📄
wcwidth.c
(2.44 KB)
📄
xlocale.3
(6.92 KB)
📄
xlocale.c
(8.63 KB)
📄
xlocale_private.h
(7.86 KB)
Editing: setlocale.c
/*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1996 - 2002 FreeBSD Project * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Paul Borman at Krystal Technologies. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #include <limits.h> #include <locale.h> #include <paths.h> /* for _PATH_LOCALE */ #include <stdlib.h> #include <string.h> #include <unistd.h> #include "collate.h" #include "lmonetary.h" /* for __monetary_load_locale() */ #include "lnumeric.h" /* for __numeric_load_locale() */ #include "lmessages.h" /* for __messages_load_locale() */ #include "setlocale.h" #include "ldpart.h" #include "../stdtime/timelocal.h" /* for __time_load_locale() */ /* * Category names for getenv() */ static const char categories[_LC_LAST][12] = { "LC_ALL", "LC_COLLATE", "LC_CTYPE", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LC_MESSAGES", }; /* * Current locales for each category */ static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { "C", "C", "C", "C", "C", "C", "C", }; /* * Path to locale storage directory */ char *_PathLocale; /* * The locales we are going to try and load */ static char new_categories[_LC_LAST][ENCODING_LEN + 1]; static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; static char *currentlocale(void); static char *loadlocale(int); const char *__get_locale_env(int); char * setlocale(int category, const char *locale) { int i, j, len, saverr; const char *env, *r; if (category < LC_ALL || category >= _LC_LAST) { errno = EINVAL; return (NULL); } if (locale == NULL) return (category != LC_ALL ? current_categories[category] : currentlocale()); /* * Default to the current locale for everything. */ for (i = 1; i < _LC_LAST; ++i) (void)strcpy(new_categories[i], current_categories[i]); /* * Now go fill up new_categories from the locale argument */ if (!*locale) { if (category == LC_ALL) { for (i = 1; i < _LC_LAST; ++i) { env = __get_locale_env(i); if (strlen(env) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strcpy(new_categories[i], env); } } else { env = __get_locale_env(category); if (strlen(env) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strcpy(new_categories[category], env); } } else if (category != LC_ALL) { if (strlen(locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strcpy(new_categories[category], locale); } else { if ((r = strchr(locale, '/')) == NULL) { if (strlen(locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } for (i = 1; i < _LC_LAST; ++i) (void)strcpy(new_categories[i], locale); } else { for (i = 1; r[1] == '/'; ++r) ; if (!r[1]) { errno = EINVAL; return (NULL); /* Hmm, just slashes... */ } do { if (i == _LC_LAST) break; /* Too many slashes... */ if ((len = r - locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strlcpy(new_categories[i], locale, len + 1); i++; while (*r == '/') r++; locale = r; while (*r && *r != '/') r++; } while (*locale); while (i < _LC_LAST) { (void)strcpy(new_categories[i], new_categories[i - 1]); i++; } } } if (category != LC_ALL) return (loadlocale(category)); for (i = 1; i < _LC_LAST; ++i) { (void)strcpy(saved_categories[i], current_categories[i]); if (loadlocale(i) == NULL) { saverr = errno; for (j = 1; j < i; j++) { (void)strcpy(new_categories[j], saved_categories[j]); if (loadlocale(j) == NULL) { (void)strcpy(new_categories[j], "C"); (void)loadlocale(j); } } errno = saverr; return (NULL); } } return (currentlocale()); } static char * currentlocale(void) { int i; (void)strcpy(current_locale_string, current_categories[1]); for (i = 2; i < _LC_LAST; ++i) if (strcmp(current_categories[1], current_categories[i])) { for (i = 2; i < _LC_LAST; ++i) { (void)strcat(current_locale_string, "/"); (void)strcat(current_locale_string, current_categories[i]); } break; } return (current_locale_string); } static char * loadlocale(int category) { char *new = new_categories[category]; char *old = current_categories[category]; int (*func) (const char *); int saved_errno; if ((new[0] == '.' && (new[1] == '\0' || (new[1] == '.' && new[2] == '\0'))) || strchr(new, '/') != NULL) { errno = EINVAL; return (NULL); } saved_errno = errno; errno = __detect_path_locale(); if (errno != 0) return (NULL); errno = saved_errno; switch (category) { case LC_CTYPE: func = __wrap_setrunelocale; break; case LC_COLLATE: func = __collate_load_tables; break; case LC_TIME: func = __time_load_locale; break; case LC_NUMERIC: func = __numeric_load_locale; break; case LC_MONETARY: func = __monetary_load_locale; break; case LC_MESSAGES: func = __messages_load_locale; break; default: errno = EINVAL; return (NULL); } if (strcmp(new, old) == 0) return (old); if (func(new) != _LDP_ERROR) { (void)strcpy(old, new); (void)strcpy(__xlocale_global_locale.components[category-1]->locale, new); return (old); } return (NULL); } const char * __get_locale_env(int category) { const char *env; /* 1. check LC_ALL. */ env = getenv(categories[0]); /* 2. check LC_* */ if (env == NULL || !*env) env = getenv(categories[category]); /* 3. check LANG */ if (env == NULL || !*env) env = getenv("LANG"); /* 4. if none is set, fall to "C" */ if (env == NULL || !*env) env = "C"; return (env); } /* * Detect locale storage location and store its value to _PathLocale variable */ int __detect_path_locale(void) { if (_PathLocale == NULL) { char *p = getenv("PATH_LOCALE"); if (p != NULL && !issetugid()) { if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) return (ENAMETOOLONG); _PathLocale = strdup(p); if (_PathLocale == NULL) return (errno == 0 ? ENOMEM : errno); } else _PathLocale = _PATH_LOCALE; } return (0); }
Upload File
Create Folder