diff options
Diffstat (limited to 'lib/libc/locale')
146 files changed, 915 insertions, 709 deletions
diff --git a/lib/libc/locale/DESIGN.xlocale b/lib/libc/locale/DESIGN.xlocale index 5d998d32314d..03e065d82d73 100644 --- a/lib/libc/locale/DESIGN.xlocale +++ b/lib/libc/locale/DESIGN.xlocale @@ -1,4 +1,3 @@ -$FreeBSD$ Design of xlocale ================= diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index a8daa1ff284e..127f8fc67abc 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -1,6 +1,3 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - # locale sources .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/locale ${LIBC_SRCTOP}/locale @@ -49,14 +46,27 @@ MAN+= btowc.3 \ wctrans.3 wctype.3 wcwidth.3 \ duplocale.3 freelocale.3 newlocale.3 querylocale.3 uselocale.3 xlocale.3 -MAN+= big5.5 euc.5 gb18030.5 gb2312.5 gbk.5 mskanji.5 utf8.5 +MANNODEV+= big5.5 euc.5 gb18030.5 gb2312.5 gbk.5 mskanji.5 utf8.5 MLINKS+=btowc.3 wctob.3 -MLINKS+=isdigit.3 isnumber.3 +MLINKS+=digittoint.3 digittoint_l.3 +MLINKS+=isalnum.3 isalnum_l.3 +MLINKS+=isalpha.3 isalpha_l.3 +MLINKS+=isblank.3 isblank_l.3 +MLINKS+=iscntrl.3 iscntrl_l.3 +MLINKS+=isdigit.3 isnumber.3 isdigit.3 isdigit_l.3 isdigit.3 isnumber_l.3 MLINKS+=isgraph.3 isgraph_l.3 +MLINKS+=isideogram.3 isideogram_l.3 MLINKS+=islower.3 islower_l.3 +MLINKS+=isphonogram.3 isphonogram_l.3 +MLINKS+=isprint.3 isprint_l.3 MLINKS+=ispunct.3 ispunct_l.3 +MLINKS+=isrune.3 isrune_l.3 MLINKS+=isspace.3 isspace_l.3 +MLINKS+=isspecial.3 isspecial_l.3 +MLINKS+=isupper.3 isupper_l.3 +MLINKS+=tolower.3 tolower_l.3 +MLINKS+=toupper.3 toupper_l.3 MLINKS+=nl_langinfo.3 nl_langinfo_l.3 MLINKS+=iswalnum.3 iswalpha.3 iswalnum.3 iswascii.3 iswalnum.3 iswblank.3 \ iswalnum.3 iswcntrl.3 iswalnum.3 iswdigit.3 iswalnum.3 iswgraph.3 \ @@ -77,7 +87,8 @@ MLINKS+=iswalnum_l.3 iswalpha_l.3 iswalnum_l.3 iswcntrl_l.3 \ iswalnum_l.3 iswphonogram_l.3 iswalnum_l.3 iswrune_l.3 \ iswalnum_l.3 iswspecial_l.3 iswalnum_l.3 nextwctype_l.3 \ iswalnum_l.3 towctrans_l.3 iswalnum_l.3 wctrans_l.3 -MLINKS+=isxdigit.3 ishexnumber.3 +MLINKS+=isxdigit.3 ishexnumber.3 isxdigit.3 isxdigit_l.3 \ + isxdigit.3 ishexnumber_l.3 MLINKS+=localeconv.3 localeconv_l.3 MLINKS+=mbrtowc.3 mbrtoc16.3 mbrtowc.3 mbrtoc32.3 MLINKS+=mbsrtowcs.3 mbsnrtowcs.3 diff --git a/lib/libc/locale/Symbol.map b/lib/libc/locale/Symbol.map index b2f2a35f2fe4..dc9bb56d7870 100644 --- a/lib/libc/locale/Symbol.map +++ b/lib/libc/locale/Symbol.map @@ -1,7 +1,3 @@ -/* - * $FreeBSD$ - */ - FBSD_1.0 { btowc; digittoint; @@ -212,6 +208,5 @@ FBSD_1.3 { FBSDprivate_1.0 { _PathLocale; __detect_path_locale; - __collate_load_error; __collate_range_cmp; }; diff --git a/lib/libc/locale/ascii.c b/lib/libc/locale/ascii.c index 99bf94108c89..2afbcea9cab9 100644 --- a/lib/libc/locale/ascii.c +++ b/lib/libc/locale/ascii.c @@ -9,7 +9,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -38,9 +38,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <runetype.h> diff --git a/lib/libc/locale/big5.5 b/lib/libc/locale/big5.5 index 8eb1a6a9ddb1..bada6cfbe180 100644 --- a/lib/libc/locale/big5.5 +++ b/lib/libc/locale/big5.5 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd April 1, 2020 .Dt BIG5 5 .Os diff --git a/lib/libc/locale/big5.c b/lib/libc/locale/big5.c index c1f94d39c7da..f67ea97af91c 100644 --- a/lib/libc/locale/big5.c +++ b/lib/libc/locale/big5.c @@ -9,7 +9,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -38,12 +38,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <errno.h> #include <runetype.h> diff --git a/lib/libc/locale/btowc.3 b/lib/libc/locale/btowc.3 index 2d8cb493351b..fc15950f0373 100644 --- a/lib/libc/locale/btowc.3 +++ b/lib/libc/locale/btowc.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd February 13, 2012 .Dt BTOWC 3 .Os diff --git a/lib/libc/locale/btowc.c b/lib/libc/locale/btowc.c index a695da477d58..a5bf7182298d 100644 --- a/lib/libc/locale/btowc.c +++ b/lib/libc/locale/btowc.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002, 2003 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdio.h> #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/c16rtomb.c b/lib/libc/locale/c16rtomb.c index 46b930786592..7814da308fc9 100644 --- a/lib/libc/locale/c16rtomb.c +++ b/lib/libc/locale/c16rtomb.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <uchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/c16rtomb_iconv.c b/lib/libc/locale/c16rtomb_iconv.c index 86bd9dab2a52..df671bd6e320 100644 --- a/lib/libc/locale/c16rtomb_iconv.c +++ b/lib/libc/locale/c16rtomb_iconv.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #define charXX_t char16_t #define cXXrtomb c16rtomb #define cXXrtomb_l c16rtomb_l diff --git a/lib/libc/locale/c32rtomb.c b/lib/libc/locale/c32rtomb.c index ebd671a404cc..1addb222e588 100644 --- a/lib/libc/locale/c32rtomb.c +++ b/lib/libc/locale/c32rtomb.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <uchar.h> #include <wchar.h> diff --git a/lib/libc/locale/c32rtomb_iconv.c b/lib/libc/locale/c32rtomb_iconv.c index dabbfd7f7ab4..5d89baac3f69 100644 --- a/lib/libc/locale/c32rtomb_iconv.c +++ b/lib/libc/locale/c32rtomb_iconv.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #define charXX_t char32_t #define cXXrtomb c32rtomb #define cXXrtomb_l c32rtomb_l diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h index 1f87e353e052..f75126df3c14 100644 --- a/lib/libc/locale/cXXrtomb_iconv.h +++ b/lib/libc/locale/cXXrtomb_iconv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/queue.h> #include <assert.h> @@ -77,8 +74,6 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps, errno = EINVAL; return (-1); } - handle->cv_shared->ci_discard_ilseq = true; - handle->cv_shared->ci_hooks = NULL; cs->srcbuf_len = 0; cs->initialized = true; if (s == NULL) @@ -94,7 +89,7 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps, dst = s; dstleft = MB_CUR_MAX_L(locale); err = _citrus_iconv_convert(handle, &src, &srcleft, &dst, &dstleft, - 0, &invlen); + _CITRUS_ICONV_F_HIDE_INVALID, &invlen); /* Character is part of a surrogate pair. We need more input. */ if (err == EINVAL) diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c index 2f0e2003aa45..c0fc4c91481d 100644 --- a/lib/libc/locale/collate.c +++ b/lib/libc/locale/collate.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2014 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. @@ -8,7 +8,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -36,9 +36,6 @@ * Adapted to xlocale by John Marino <draco@marino.st> */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/types.h> @@ -46,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mman.h> #include <assert.h> +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -68,6 +66,14 @@ struct xlocale_collate __xlocale_C_collate = { {{0}, "C"}, 1, 0, 0, 0 }; +struct xlocale_collate __xlocale_POSIX_collate = { + {{0}, "POSIX"}, 1, 0, 0, 0 +}; + +struct xlocale_collate __xlocale_CUTF8_collate = { + {{0}, "C.UTF-8"}, 1, 0, 0, 0 +}; + static int __collate_load_tables_l(const char *encoding, struct xlocale_collate *table); @@ -84,10 +90,13 @@ destruct_collate(void *t) void * __collate_load(const char *encoding, __unused locale_t unused) { - if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0 || - strncmp(encoding, "C.", 2) == 0) { + if (strcmp(encoding, "C") == 0) return (&__xlocale_C_collate); - } + else if (strcmp(encoding, "POSIX") == 0) + return (&__xlocale_POSIX_collate); + else if (strcmp(encoding, "C.UTF-8") == 0) + return (&__xlocale_CUTF8_collate); + struct xlocale_collate *table = calloc(sizeof(struct xlocale_collate), 1); if (table == NULL) @@ -148,7 +157,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table) } if (sbuf.st_size < (COLLATE_FMT_VERSION_LEN + XLOCALE_DEF_VERSION_LEN + - sizeof (info))) { + sizeof (*info))) { (void) _close(fd); errno = EINVAL; return (_LDP_ERROR); @@ -724,3 +733,261 @@ __collate_equiv_value(locale_t locale, const wchar_t *str, size_t len) } return (0); } + +/* + * __collate_collating_symbol takes the multibyte string specified by + * src and slen, and using ps, converts that to a wide character. Then + * it is checked to verify it is a collating symbol, and then copies + * it to the wide character string specified by dst and dlen (the + * results are not null terminated). The length of the wide characters + * copied to dst is returned if successful. Zero is returned if no such + * collating symbol exists. (size_t)-1 is returned if there are wide-character + * conversion errors, if the length of the converted string is greater that + * COLLATE_STR_LEN or if dlen is too small. It is up to the calling routine to + * preserve the mbstate_t structure as needed. + */ +size_t +__collate_collating_symbol(wchar_t *dst, size_t dlen, const char *src, + size_t slen, mbstate_t *ps) +{ + wchar_t wname[COLLATE_STR_LEN]; + wchar_t w, *wp; + struct xlocale_collate *table; + size_t len, l; + + table = + (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE]; + /* POSIX locale */ + if (table->__collate_load_error) { + if (dlen < 1) + return ((size_t)-1); + if (slen != 1 || !isascii(*src)) + return (0); + *dst = *src; + return (1); + } + for (wp = wname, len = 0; slen > 0; len++) { + l = mbrtowc(&w, src, slen, ps); + if (l == (size_t)-1 || l == (size_t)-2) + return ((size_t)-1); + if (l == 0) + break; + if (len >= COLLATE_STR_LEN) + return ((size_t)-1); + *wp++ = w; + src += l; + slen -= l; + } + if (len == 0 || len > dlen) + return ((size_t)-1); + if (len == 1) { + if (*wname <= UCHAR_MAX) { + if (table->char_pri_table[*wname].pri[0] >= 0) { + if (dlen > 0) + *dst = *wname; + return (1); + } + return (0); + } else if (table->info->large_count > 0) { + collate_large_t *match; + match = largesearch(table, *wname); + if (match && match->pri.pri[0] >= 0) { + if (dlen > 0) + *dst = *wname; + return (1); + } + } + return (0); + } + *wp = 0; + if (table->info->chain_count > 0) { + collate_chain_t *match; + int ll; + match = chainsearch(table, wname, &ll); + if (match) { + if (ll < dlen) + dlen = ll; + wcsncpy(dst, wname, dlen); + return (dlen); + } + } + return (0); +} + +/* + * __collate_equiv_class returns the equivalence class number for the symbol + * specified by src and slen, using ps to convert from multi-byte to wide + * character. Zero is returned if the symbol is not in an equivalence + * class. -1 is returned if there are wide character conversion errors, + * if there are any greater-than-8-bit characters or if a multi-byte symbol + * is greater or equal to COLLATE_STR_LEN in length. It is up to the calling + * routine to preserve the mbstate_t structure as needed. + */ +int +__collate_equiv_class(const char *src, size_t slen, mbstate_t *ps) +{ + wchar_t wname[COLLATE_STR_LEN]; + wchar_t w, *wp; + struct xlocale_collate *table; + size_t len, l; + int e; + + table = + (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE]; + /* POSIX locale */ + if (table->__collate_load_error) + return (0); + for (wp = wname, len = 0; slen > 0; len++) { + l = mbrtowc(&w, src, slen, ps); + if (l == (size_t)-1 || l == (size_t)-2) + return (-1); + if (l == 0) + break; + if (len >= COLLATE_STR_LEN) + return (-1); + *wp++ = w; + src += l; + slen -= l; + } + if (len == 0) + return (-1); + if (len == 1) { + e = -1; + if (*wname <= UCHAR_MAX) + e = table->char_pri_table[*wname].pri[0]; + else if (table->info->large_count > 0) { + collate_large_t *match; + match = largesearch(table, *wname); + if (match) + e = match->pri.pri[0]; + } + if (e == 0) + return (IGNORE_EQUIV_CLASS); + return (e > 0 ? e : 0); + } + *wp = 0; + if (table->info->chain_count > 0) { + collate_chain_t *match; + int ll; + match = chainsearch(table, wname, &ll); + if (match) { + e = match->pri[0]; + if (e == 0) + return (IGNORE_EQUIV_CLASS); + return (e < 0 ? -e : e); + } + } + return (0); +} + + +/* + * __collate_equiv_match tries to match any single or multi-character symbol + * in equivalence class equiv_class in the multi-byte string specified by src + * and slen. If start is non-zero, it is taken to be the first (pre-converted) + * wide character. Subsequence wide characters, if needed, will use ps in + * the conversion. On a successful match, the length of the matched string + * is returned (including the start character). If dst is non-NULL, the + * matched wide-character string is copied to dst, a wide character array of + * length dlen (the results are not zero-terminated). If rlen is non-NULL, + * the number of character in src actually used is returned. Zero is + * returned by __collate_equiv_match if there is no match. (size_t)-1 is + * returned on error: if there were conversion errors or if dlen is too small + * to accept the results. On no match or error, ps is restored to its incoming + * state. + */ +size_t +__collate_equiv_match(int equiv_class, wchar_t *dst, size_t dlen, wchar_t start, + const char *src, size_t slen, mbstate_t *ps, size_t *rlen) +{ + wchar_t w; + size_t len, l, clen; + int i; + wchar_t buf[COLLATE_STR_LEN], *wp; + mbstate_t save; + const char *s = src; + struct xlocale_collate *table; + size_t sl = slen; + collate_chain_t *ch = NULL; + + table = + (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE]; + /* POSIX locale */ + if (table->__collate_load_error) + return ((size_t)-1); + if (equiv_class == IGNORE_EQUIV_CLASS) + equiv_class = 0; + if (ps) + save = *ps; + wp = buf; + len = clen = 0; + if (start) { + *wp++ = start; + len = 1; + } + /* convert up to the max chain length */ + while (sl > 0 && len < table->info->chain_max_len) { + l = mbrtowc(&w, s, sl, ps); + if (l == (size_t)-1 || l == (size_t)-2 || l == 0) + break; + *wp++ = w; + s += l; + clen += l; + sl -= l; + len++; + } + *wp = 0; + if (len > 1 && (ch = chainsearch(table, buf, &i)) != NULL) { + int e = ch->pri[0]; + if (e < 0) + e = -e; + if (e == equiv_class) + goto found; + } + /* try single character */ + i = 1; + if (*buf <= UCHAR_MAX) { + if (equiv_class == table->char_pri_table[*buf].pri[0]) + goto found; + } else if (table->info->large_count > 0) { + collate_large_t *match; + match = largesearch(table, *buf); + if (match && equiv_class == match->pri.pri[0]) + goto found; + } + /* no match */ + if (ps) + *ps = save; + return (0); +found: + /* + * If we converted more than we used, restore to initial + * and reconvert up to what did match. + */ + if (i < len) { + len = i; + if (ps) + *ps = save; + if (start) + i--; + clen = 0; + while (i-- > 0) { + l = mbrtowc(&w, src, slen, ps); + src += l; + clen += l; + slen -= l; + } + } + if (dst) { + if (dlen < len) { + if (ps) + *ps = save; + return ((size_t)-1); + } + for (wp = buf; len > 0; len--) + *dst++ = *wp++; + } + if (rlen) + *rlen = clen; + return (len); +} diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h index 9983cdbd969d..64e0e6f2337d 100644 --- a/lib/libc/locale/collate.h +++ b/lib/libc/locale/collate.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua> @@ -7,7 +7,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,16 +31,14 @@ * 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. - * - * $FreeBSD$ */ #ifndef _COLLATE_H_ #define _COLLATE_H_ -#include <sys/cdefs.h> #include <sys/types.h> #include <limits.h> +#include <wchar.h> #include "xlocale_private.h" /* @@ -68,6 +66,8 @@ #define DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD) +#define IGNORE_EQUIV_CLASS 1 + /* * The collate file format is as follows: * @@ -88,6 +88,7 @@ typedef struct collate_info { uint8_t directive_count; uint8_t directive[COLL_WEIGHTS_MAX]; + uint8_t chain_max_len; /* In padding */ int32_t pri_count[COLL_WEIGHTS_MAX]; int32_t flags; int32_t chain_count; @@ -129,8 +130,13 @@ struct xlocale_collate { }; __BEGIN_DECLS -int __collate_load_tables(const char *); +size_t __collate_collating_symbol(wchar_t *, size_t, const char *, size_t, + mbstate_t *); +int __collate_equiv_class(const char *, size_t, mbstate_t *); int __collate_equiv_value(locale_t, const wchar_t *, size_t); +size_t __collate_equiv_match(int, wchar_t *, size_t, wchar_t, const char *, + size_t, mbstate_t *, size_t *); +int __collate_load_tables(const char *); void _collate_lookup(struct xlocale_collate *,const wchar_t *, int *, int *, int, const int **); int __collate_range_cmp(char, char); diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c index b444ea0652ac..855f84d884da 100644 --- a/lib/libc/locale/collcmp.c +++ b/lib/libc/locale/collcmp.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 1996 by Andrey A. Chernov, Moscow, Russia. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <string.h> #include <wchar.h> #include "collate.h" diff --git a/lib/libc/locale/ctype.3 b/lib/libc/locale/ctype.3 index b7a3b1ccb05a..25568d6f062c 100644 --- a/lib/libc/locale/ctype.3 +++ b/lib/libc/locale/ctype.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)ctype.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd April 3, 2022 .Dt CTYPE 3 .Os diff --git a/lib/libc/locale/ctype.c b/lib/libc/locale/ctype.c index 8a88b8d6512e..a907ac4234fd 100644 --- a/lib/libc/locale/ctype.c +++ b/lib/libc/locale/ctype.c @@ -1,8 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. * * This software was developed by David Chisnall under sponsorship from * the FreeBSD Foundation. @@ -26,8 +25,6 @@ * 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. - * - * $FreeBSD$ */ #define _XLOCALE_INLINE #include <ctype.h> diff --git a/lib/libc/locale/ctype_l.3 b/lib/libc/locale/ctype_l.3 index 5f427de06394..6879ba72706e 100644 --- a/lib/libc/locale/ctype_l.3 +++ b/lib/libc/locale/ctype_l.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -25,16 +24,13 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd March 6, 2012 +.Dd December 19, 2022 .Dt CTYPE_L 3 .Os .Sh NAME .Nm digittoint_l , .Nm isalnum_l , .Nm isalpha_l , -.Nm isascii_l , .Nm isblank_l , .Nm iscntrl_l , .Nm isdigit_l , @@ -65,8 +61,6 @@ .Ft int .Fn isalpha_l "int c" "locale_t loc" .Ft int -.Fn isascii_l "int c" "locale_t loc" -.Ft int .Fn iscntrl_l "int c" "locale_t loc" .Ft int .Fn isdigit_l "int c" "locale_t loc" @@ -111,34 +105,32 @@ specified locale rather than the global or per-thread locale. or as true functions in the C library. See the specific manual pages for more information. .Sh SEE ALSO -.Xr digittoint 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr isideogram 3 , -.Xr islower 3 , -.Xr isphonogram 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isrune 3 , -.Xr isspace 3 , -.Xr isspecial 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr wctype 3 , -.Xr xlocale 3 +.Xr digittoint_l 3 , +.Xr isalnum_l 3 , +.Xr isalpha_l 3 , +.Xr isblank_l 3 , +.Xr iscntrl_l 3 , +.Xr isdigit_l 3 , +.Xr isgraph_l 3 , +.Xr isideogram_l 3 , +.Xr islower_l 3 , +.Xr isphonogram_l 3 , +.Xr isprint_l 3 , +.Xr ispunct_l 3 , +.Xr isrune_l 3 , +.Xr isspace_l 3 , +.Xr isspecial_l 3 , +.Xr isupper_l 3 , +.Xr isxdigit_l 3 , +.Xr tolower_l 3 , +.Xr toupper_l 3 , +.Xr wctype_l 3 , +.Xr xlocale_l 3 .Sh STANDARDS These functions conform to .St -p1003.1-2008 , except for .Fn digittoint_l , -.Fn isascii_l , .Fn ishexnumber_l , .Fn isideogram_l , .Fn isnumber_l , diff --git a/lib/libc/locale/digittoint.3 b/lib/libc/locale/digittoint.3 index 5caef66461e4..363b736bf442 100644 --- a/lib/libc/locale/digittoint.3 +++ b/lib/libc/locale/digittoint.3 @@ -25,14 +25,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)digittoint.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 6, 2001 +.Dd December 19, 2022 .Dt DIGITTOINT 3 .Os .Sh NAME -.Nm digittoint +.Nm digittoint , +.Nm digittoint_l .Nd convert a numeric character to its integer value .Sh LIBRARY .Lb libc @@ -45,7 +43,9 @@ .Sh DESCRIPTION The .Fn digittoint -function converts a numeric character to its corresponding integer value. +and +.Fn digittoint_l +functions convert a numeric character to its corresponding integer value. The character can be any decimal digit or hexadecimal digit. With hexadecimal characters, the case of the values does not matter. .Pp @@ -57,12 +57,19 @@ function use the current global or per-thread locale. .Sh RETURN VALUES The .Fn digittoint -function always returns an integer from the range of 0 to 15. +and +.Fn digittoint_l +functions always return an integer from the range of 0 to 15. If the given character was not a digit as defined by -.Xr isxdigit 3 , +.Xr isxdigit 3 +or +.Xr isxdigit_l 3 , the function will return 0. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr isdigit 3 , +.Xr isdigit_l 3 , .Xr isxdigit 3 , +.Xr isxdigit_l 3 , .Xr xlocale 3 diff --git a/lib/libc/locale/duplocale.3 b/lib/libc/locale/duplocale.3 index bc0c4bced812..2e44df8c63a5 100644 --- a/lib/libc/locale/duplocale.3 +++ b/lib/libc/locale/duplocale.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -25,8 +24,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 17, 2011 .Dt DUPLOCALE 3 .Os diff --git a/lib/libc/locale/euc.5 b/lib/libc/locale/euc.5 index 7d097769f962..23eab67c0737 100644 --- a/lib/libc/locale/euc.5 +++ b/lib/libc/locale/euc.5 @@ -28,9 +28,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)euc.4 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd September 9, 2019 .Dt EUC 5 .Os diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c index 55055965ab4e..c110fc61b375 100644 --- a/lib/libc/locale/euc.c +++ b/lib/libc/locale/euc.c @@ -11,7 +11,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -40,12 +40,7 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ #include <sys/param.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <runetype.h> @@ -431,7 +426,7 @@ _EUC_wcrtomb_impl(char * __restrict s, wchar_t wc, /* This first check excludes CS1, which is implicitly valid. */ if ((wc < 0xa100) || (wc > 0xffff)) { /* Check for valid CS2 or CS3 */ - nm = (wc >> ((len - 1) * 8)); + nm = (wc >> ((len - 1) * 8)) & 0xff; if (nm == cs2) { if (len != cs2width) { errno = EILSEQ; diff --git a/lib/libc/locale/fix_grouping.c b/lib/libc/locale/fix_grouping.c index d15faef80781..2ae165661d84 100644 --- a/lib/libc/locale/fix_grouping.c +++ b/lib/libc/locale/fix_grouping.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <limits.h> #include <stddef.h> diff --git a/lib/libc/locale/freelocale.3 b/lib/libc/locale/freelocale.3 index d3e2d4498226..594720f4dfab 100644 --- a/lib/libc/locale/freelocale.3 +++ b/lib/libc/locale/freelocale.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -24,8 +23,6 @@ .\" 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. -.\" -.\" $FreeBSD$ .Dd July 26, 2016 .Dt FREELOCALE 3 .Os diff --git a/lib/libc/locale/gb18030.5 b/lib/libc/locale/gb18030.5 index 3a296c017844..7b772752187a 100644 --- a/lib/libc/locale/gb18030.5 +++ b/lib/libc/locale/gb18030.5 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 10, 2003 .Dt GB18030 5 .Os diff --git a/lib/libc/locale/gb18030.c b/lib/libc/locale/gb18030.c index b4f80678d840..1ddb3e463872 100644 --- a/lib/libc/locale/gb18030.c +++ b/lib/libc/locale/gb18030.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. @@ -7,7 +7,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -40,8 +40,6 @@ */ #include <sys/param.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <runetype.h> #include <stdlib.h> diff --git a/lib/libc/locale/gb2312.5 b/lib/libc/locale/gb2312.5 index 5f1f712097d5..3da610cdb19a 100644 --- a/lib/libc/locale/gb2312.5 +++ b/lib/libc/locale/gb2312.5 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 7, 2003 .Dt GB2312 5 .Os diff --git a/lib/libc/locale/gb2312.c b/lib/libc/locale/gb2312.c index 07a6c4764bb3..dbcb56435ab6 100644 --- a/lib/libc/locale/gb2312.c +++ b/lib/libc/locale/gb2312.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. @@ -8,7 +8,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -35,8 +35,6 @@ */ #include <sys/param.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <runetype.h> #include <stdlib.h> diff --git a/lib/libc/locale/gbk.5 b/lib/libc/locale/gbk.5 index cec22c639540..ce5680b73cca 100644 --- a/lib/libc/locale/gbk.5 +++ b/lib/libc/locale/gbk.5 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 10, 2003 .Dt GBK 5 .Os diff --git a/lib/libc/locale/gbk.c b/lib/libc/locale/gbk.c index 78ff623be379..c64a9d534701 100644 --- a/lib/libc/locale/gbk.c +++ b/lib/libc/locale/gbk.c @@ -11,7 +11,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -40,9 +40,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <errno.h> #include <runetype.h> diff --git a/lib/libc/locale/isalnum.3 b/lib/libc/locale/isalnum.3 index 85e846332352..ab79ba79fd5b 100644 --- a/lib/libc/locale/isalnum.3 +++ b/lib/libc/locale/isalnum.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isalnum.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISALNUM 3 .Os .Sh NAME -.Nm isalnum +.Nm isalnum , +.Nm isalnum_l .Nd alphanumeric character test .Sh LIBRARY .Lb libc @@ -49,10 +47,14 @@ .Sh DESCRIPTION The .Fn isalnum -function tests for any character for which -.Xr isalpha 3 +and +.Fn isalnum_l +functions test for any character for which +.Xr isalpha 3 , +.Xr isalpha_l 3 or -.Xr isdigit 3 +.Xr isdigit 3 , +.Xr isdigit_l 3 is true. The value of the argument must be representable as an .Vt "unsigned char" @@ -85,8 +87,10 @@ function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isalnum -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isalnum_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -96,12 +100,18 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswalnum +or +.Fn iswalnum_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr isalpha 3 , +.Xr isalpha_l 3 , .Xr isdigit 3 , +.Xr isdigit_l 3 , .Xr iswalnum 3 , +.Xr iswalnum_l 3 , .Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS diff --git a/lib/libc/locale/isalpha.3 b/lib/libc/locale/isalpha.3 index 1a7330f3a0d1..fe695b70f7b6 100644 --- a/lib/libc/locale/isalpha.3 +++ b/lib/libc/locale/isalpha.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isalpha.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd July 17, 2005 +.Dd December 19, 2022 .Dt ISALPHA 3 .Os .Sh NAME -.Nm isalpha +.Nm isalpha , +.Nm isalpha_l .Nd alphabetic character test .Sh LIBRARY .Lb libc @@ -49,10 +47,14 @@ .Sh DESCRIPTION The .Fn isalpha -function tests for any character for which -.Xr isupper 3 +and +.Fn isalpha_l +functions test for any character for which +.Xr isupper 3 , +.Xr isupper_l 3 or -.Xr islower 3 +.Xr islower 3 , +.Xr islower_l 3 is true. The value of the argument must be representable as an .Vt "unsigned char" @@ -83,8 +85,10 @@ function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isalpha -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isalpha_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -94,12 +98,18 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswalpha +or +.Fn iswalpha_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr islower 3 , +.Xr islower_l 3 , .Xr isupper 3 , +.Xr isupper_l 3 , .Xr iswalpha 3 , +.Xr iswalpha_l 3 , .Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS diff --git a/lib/libc/locale/isascii.3 b/lib/libc/locale/isascii.3 index 1d5d282a4fb3..d395dd232d00 100644 --- a/lib/libc/locale/isascii.3 +++ b/lib/libc/locale/isascii.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isascii.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" .Dd April 2, 2022 .Dt ISASCII 3 .Os diff --git a/lib/libc/locale/isblank.3 b/lib/libc/locale/isblank.3 index b3e805ae0085..e28bd8294d43 100644 --- a/lib/libc/locale/isblank.3 +++ b/lib/libc/locale/isblank.3 @@ -25,14 +25,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isblank.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd July 17, 2005 +.Dd December 19, 2022 .Dt ISBLANK 3 .Os .Sh NAME -.Nm isblank +.Nm isblank , +.Nm isblank_l .Nd space or tab character test .Sh LIBRARY .Lb libc @@ -45,7 +43,9 @@ .Sh DESCRIPTION The .Fn isblank -function tests for a space or tab character. +and +.Fn isblank_l +functions test for a space or tab character. For any locale, this includes the following standard characters: .Bl -column XXXX .It Do \et Dc Ta Dq " " @@ -53,6 +53,8 @@ For any locale, this includes the following standard characters: .Pp In the "C" locale, a successful .Fn isblank +or +.Fn isblank_l test is limited to these characters only. The value of the argument must be representable as an .Vt "unsigned char" @@ -67,8 +69,10 @@ function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isblank -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isblank_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -78,10 +82,14 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswblank +or +.Fn iswblank_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswblank 3 , +.Xr iswblank_l 3 , .Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS diff --git a/lib/libc/locale/iscntrl.3 b/lib/libc/locale/iscntrl.3 index b61563735f74..9df266ba9780 100644 --- a/lib/libc/locale/iscntrl.3 +++ b/lib/libc/locale/iscntrl.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISCNTRL 3 .Os .Sh NAME -.Nm iscntrl +.Nm iscntrl , +.Nm iscntrl_l .Nd control character test .Sh LIBRARY .Lb libc @@ -49,7 +47,9 @@ .Sh DESCRIPTION The .Fn iscntrl -function tests for any control character. +and +.Fn iscntrl_l +functions test for any control character. The value of the argument must be representable as an .Vt "unsigned char" or the value of @@ -75,8 +75,10 @@ function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn iscntrl -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn iscntrl_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -86,10 +88,14 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswcntrl +or +.Fn iswcntrl_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswcntrl 3 , +.Xr iswcntrl_l 3 , .Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS diff --git a/lib/libc/locale/isctype.c b/lib/libc/locale/isctype.c index 3731508ba15a..c6bea890d154 100644 --- a/lib/libc/locale/isctype.c +++ b/lib/libc/locale/isctype.c @@ -37,12 +37,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)isctype.c 8.3 (Berkeley) 2/24/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #undef digittoint diff --git a/lib/libc/locale/isdigit.3 b/lib/libc/locale/isdigit.3 index d1a75465e277..eac334ef40d1 100644 --- a/lib/libc/locale/isdigit.3 +++ b/lib/libc/locale/isdigit.3 @@ -29,15 +29,14 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isdigit.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd May 4, 2007 +.Dd December 19, 2022 .Dt ISDIGIT 3 .Os .Sh NAME .Nm isdigit , -.Nm isnumber +.Nm isnumber , +.Nm isdigit_l , +.Nm isnumber_l .Nd decimal-digit character test .Sh LIBRARY .Lb libc @@ -54,7 +53,9 @@ .Sh DESCRIPTION The .Fn isdigit -function tests for a decimal digit character. +and +.Fn isdigit_l +functions test for a decimal digit character. Regardless of locale, this includes the following characters only: .Bl -column \&``0''______ \&``0''______ \&``0''______ \&``0''______ \&``0''______ .It "\&``0''" Ta "``1''" Ta "``2''" Ta "``3''" Ta "``4''" @@ -63,8 +64,12 @@ Regardless of locale, this includes the following characters only: .Pp The .Fn isnumber -function behaves similarly to -.Fn isdigit , +and +.Fn isnumber_l +functions behave similarly to +.Fn isdigit +and +.Fn isdigit_l , but may recognize additional characters, depending on the current locale setting. .Pp @@ -77,9 +82,11 @@ The _l-suffixed versions take an explicit locale argument, whereas the non-suffixed versions use the current global or per-thread locale. .Sh RETURN VALUES The -.Fn isdigit +.Fn isdigit , +.Fn isdigit_l , +.Fn isnumber , and -.Fn isnumber +.Fn isnumber_l functions return zero if the character tests false and return non-zero if the character tests true. .Sh COMPATIBILITY @@ -91,10 +98,14 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswdigit +or +.Fn iswdigit_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswdigit 3 , +.Xr iswdigit_l 3 , .Xr multibyte 3 , .Xr xlocale 3 , .Xr ascii 7 diff --git a/lib/libc/locale/isgraph.3 b/lib/libc/locale/isgraph.3 index b3c078cea079..a9b727987e59 100644 --- a/lib/libc/locale/isgraph.3 +++ b/lib/libc/locale/isgraph.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93 -.\" $FreeBSD$ -.\" -.Dd July 30, 2012 +.Dd December 19, 2022 .Dt ISGRAPH 3 .Os .Sh NAME -.Nm isgraph +.Nm isgraph , +.Nm isgraph_l .Nd printing character test (space character exclusive) .Sh LIBRARY .Lb libc @@ -49,7 +47,9 @@ .Sh DESCRIPTION The .Fn isgraph -function tests for any printing character except space +and +.Fn isgraph_l +functions test for any printing character except space .Pq Ql "\~" and other locale-specific space-like characters. @@ -103,10 +103,15 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswgraph +or +.Fn iswgraph_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswgraph 3 , +.Xr iswgraph_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/isideogram.3 b/lib/libc/locale/isideogram.3 index cbaa625e91df..ba60ade81b32 100644 --- a/lib/libc/locale/isideogram.3 +++ b/lib/libc/locale/isideogram.3 @@ -23,13 +23,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd March 30, 2004 +.Dd December 19, 2022 .Dt ISIDEOGRAM 3 .Os .Sh NAME -.Nm isideogram +.Nm isideogram , +.Nm isideogram_l .Nd ideographic character test .Sh LIBRARY .Lb libc @@ -37,19 +36,47 @@ .In ctype.h .Ft int .Fn isideogram "int c" +.Ft int +.Fn isideogram_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isideogram -function tests for an ideographic character. +and +.Fn isideogram_l +functions test for an ideographic character. +.Pp +The +.Fn isideogram_l +function takes an explicit locale argument, whereas the +.Fn isideogram +function use the current global or per-thread locale. .Sh RETURN VALUES The .Fn isideogram -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isideogram_l +functions return zero if the character tests false and +return non-zero if the character tests true. +.Sh COMPATIBILITY +The +.Bx 4.4 +extension of accepting arguments outside of the range of the +.Vt "unsigned char" +type in locales with large character sets is considered obsolete +and may not be supported in future releases. +The +.Fn iswideogram +or +.Fn iswideogram_l +function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr isphonogram 3 , -.Xr iswideogram 3 +.Xr isphonogram_l 3 , +.Xr iswideogram 3 , +.Xr iswideogram_l 3 , +.Xr xlocale 3 .Sh HISTORY The .Fn isideogram diff --git a/lib/libc/locale/islower.3 b/lib/libc/locale/islower.3 index 2097510acb93..78503eed93b9 100644 --- a/lib/libc/locale/islower.3 +++ b/lib/libc/locale/islower.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)islower.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISLOWER 3 .Os .Sh NAME -.Nm islower +.Nm islower , +.Nm islower_l .Nd lower-case character test .Sh LIBRARY .Lb libc @@ -49,7 +47,9 @@ .Sh DESCRIPTION The .Fn islower -function tests for any lower-case letters. +and +.Fn islower_l +functions test for any lower-case letters. The value of the argument must be representable as an .Vt "unsigned char" or the value of @@ -86,11 +86,17 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswlower +or +.Fn iswlower_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswlower 3 , +.Xr iswlower_l 3 , .Xr tolower 3 , +.Xr tolower_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/isphonogram.3 b/lib/libc/locale/isphonogram.3 index b0d82c428cba..ec7fd9b720d2 100644 --- a/lib/libc/locale/isphonogram.3 +++ b/lib/libc/locale/isphonogram.3 @@ -23,13 +23,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd March 30, 2004 +.Dd December 19, 2022 .Dt ISPHONOGRAM 3 .Os .Sh NAME -.Nm isphonogram +.Nm isphonogram , +.Nm isphonogram_l .Nd phonographic character test .Sh LIBRARY .Lb libc @@ -37,19 +36,35 @@ .In ctype.h .Ft int .Fn isphonogram "int c" +.Ft int +.Fn isphonogram_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isphonogram -function tests for a phonographic character. +and +.Fn isphonogram_l +functions test for a phonographic character. +.Pp +The +.Fn isphonogram_l +function takes an explicit locale argument, whereas the +.Fn isphonogram +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isphonogram -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isphonogram_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr isideogram 3 , -.Xr iswphonogram 3 +.Xr isideogram_l 3 , +.Xr iswphonogram 3 , +.Xr iswphonogram_l 3 , +.Xr xlocale 3 .Sh HISTORY The .Fn isphonogram diff --git a/lib/libc/locale/isprint.3 b/lib/libc/locale/isprint.3 index 6e740d3e850d..c54e122cc621 100644 --- a/lib/libc/locale/isprint.3 +++ b/lib/libc/locale/isprint.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isprint.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISPRINT 3 .Os .Sh NAME -.Nm isprint +.Nm isprint , +.Nm isprint_l .Nd printing character test (space character inclusive) .Sh LIBRARY .Lb libc @@ -44,10 +42,14 @@ .In ctype.h .Ft int .Fn isprint "int c" +.Ft int +.Fn isprint_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isprint -function tests for any printing character, including space +and +.Fn isprint_l +functions test for any printing character, including space .Pq Ql "\ " . The value of the argument must be representable as an .Vt "unsigned char" @@ -77,11 +79,19 @@ In the ASCII character set, this includes the following characters .It "\&165\ ``u''" Ta "166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''" Ta "171\ ``y''" .It "\&172\ ``z''" Ta "173\ ``{''" Ta "174\ ``|''" Ta "175\ ``}''" Ta "176\ ``~''" .El +.Pp +The +.Fn isprint_l +function takes an explicit locale argument, whereas the +.Fn isprint +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isprint -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isprint_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -91,10 +101,15 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswprint +or +.Fn iswprint_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswprint 3 , +.Xr iswprint_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/ispunct.3 b/lib/libc/locale/ispunct.3 index f0c838d069a3..23fec2b17528 100644 --- a/lib/libc/locale/ispunct.3 +++ b/lib/libc/locale/ispunct.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISPUNCT 3 .Os .Sh NAME -.Nm ispunct +.Nm ispunct , +.Nm ispunct_l .Nd punctuation character test .Sh LIBRARY .Lb libc @@ -49,11 +47,15 @@ .Sh DESCRIPTION The .Fn ispunct -function tests for any printing character except for space +and +.Fn ispunct_l +functions test for any printing character except for space .Pq Ql "\ " or a character for which .Xr isalnum 3 +or +.Xr isalnum_l 3 is true. The value of the argument must be representable as an .Vt "unsigned char" @@ -93,10 +95,15 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswpunct +or +.Fn iswpunct_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswpunct 3 , +.Xr iswpunct_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/isrune.3 b/lib/libc/locale/isrune.3 index 424c367d2014..b83b8a26e444 100644 --- a/lib/libc/locale/isrune.3 +++ b/lib/libc/locale/isrune.3 @@ -23,13 +23,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd March 30, 2004 +.Dd December 19, 2022 .Dt ISRUNE 3 .Os .Sh NAME -.Nm isrune +.Nm isrune , +.Nm isrune_l .Nd valid character test .Sh LIBRARY .Lb libc @@ -37,24 +36,51 @@ .In ctype.h .Ft int .Fn isrune "int c" +.Ft int +.Fn isrune_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isrune -function tests for any character that is valid in the current +and +.Fn isrune_l +functions test for any character that is valid in the current character set. In the .Tn ASCII character set, this is equivalent to .Fn isascii . +.Pp +The +.Fn isrune_l +function takes an explicit locale argument, whereas the +.Fn isrune +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isrune -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isrune_l +functions return zero if the character tests false and +return non-zero if the character tests true. +.Sh COMPATIBILITY +The +.Bx 4.4 +extension of accepting arguments outside of the range of the +.Vt "unsigned char" +type in locales with large character sets is considered obsolete +and may not be supported in future releases. +The +.Fn iswrune +or +.Fn iswrune_l +function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr isascii 3 , .Xr iswrune 3 , +.Xr iswrune_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh HISTORY The diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3 index 67eb1b956c83..e52d2bebe76c 100644 --- a/lib/libc/locale/isspace.3 +++ b/lib/libc/locale/isspace.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isspace.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISSPACE 3 .Os .Sh NAME -.Nm isspace +.Nm isspace , +.Nm isspace_l .Nd white-space character test .Sh LIBRARY .Lb libc @@ -49,7 +47,9 @@ .Sh DESCRIPTION The .Fn isspace -function tests for white-space characters. +and +.Fn isspace_l +functions test for white-space characters. For any locale, this includes the following standard characters: .Bl -column \&`\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ .It "\&``\et''" Ta "``\en''" Ta "``\ev''" Ta "``\ef''" Ta "``\er''" Ta "`` ''" @@ -57,7 +57,9 @@ For any locale, this includes the following standard characters: .Pp In the "C" locale, .Fn isspace -returns non-zero for these characters only. +and +.Fn isspace_l +return non-zero for these characters only. The value of the argument must be representable as an .Vt "unsigned char" or the value of @@ -84,11 +86,16 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswspace +or +.Fn iswspace_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswspace 3 , +.Xr iswspace_l 3 , .Xr multibyte 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/isspecial.3 b/lib/libc/locale/isspecial.3 index de361d28f96b..b88d5361ab9f 100644 --- a/lib/libc/locale/isspecial.3 +++ b/lib/libc/locale/isspecial.3 @@ -23,13 +23,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd March 30, 2004 +.Dd December 19, 2022 .Dt ISSPECIAL 3 .Os .Sh NAME -.Nm isspecial +.Nm isspecial , +.Nm isspecial_l .Nd special character test .Sh LIBRARY .Lb libc @@ -37,18 +36,45 @@ .In ctype.h .Ft int .Fn isspecial "int c" +.Ft int +.Fn isspecial_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isspecial -function tests for a special character. +and +.Fn isspecial_l +functions test for a special character. +.Pp +The +.Fn isspecial_l +function takes an explicit locale argument, whereas the +.Fn isspecial +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isspecial -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isspecial_l +functions return zero if the character tests false and +return non-zero if the character tests true. +.Sh COMPATIBILITY +The +.Bx 4.4 +extension of accepting arguments outside of the range of the +.Vt "unsigned char" +type in locales with large character sets is considered obsolete +and may not be supported in future releases. +The +.Fn iswspecial +or +.Fn iswspecial_l +function should be used instead. .Sh SEE ALSO .Xr ctype 3 , -.Xr iswspecial 3 +.Xr ctype_l 3 , +.Xr iswspecial 3 , +.Xr iswspecial_l 3 , +.Xr xlocale 3 .Sh HISTORY The .Fn isspecial diff --git a/lib/libc/locale/isupper.3 b/lib/libc/locale/isupper.3 index a26fc9c610a9..212ab1d93625 100644 --- a/lib/libc/locale/isupper.3 +++ b/lib/libc/locale/isupper.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isupper.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd April 2, 2022 +.Dd December 19, 2022 .Dt ISUPPER 3 .Os .Sh NAME -.Nm isupper +.Nm isupper , +.Nm isupper_l .Nd upper-case character test .Sh LIBRARY .Lb libc @@ -44,10 +42,14 @@ .In ctype.h .Ft int .Fn isupper "int c" +.Ft int +.Fn isupper_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isupper -function tests for any upper-case letter. +and +.Fn isupper_l +functions test for any upper-case letter. The value of the argument must be representable as an .Vt "unsigned char" or the value of @@ -63,11 +65,19 @@ In the ASCII character set, this includes the following characters .It "\&125\ ``U''" Ta "126\ ``V''" Ta "127\ ``W''" Ta "130\ ``X''" Ta "131\ ``Y''" .It "\&132\ ``Z''" Ta \& Ta \& Ta \& Ta \& .El +.Pp +The +.Fn isupper_l +function takes an explicit locale argument, whereas the +.Fn isupper +function uses the current global or per-thread locale. .Sh RETURN VALUES The .Fn isupper -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isupper_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -77,11 +87,17 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswupper +or +.Fn iswupper_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswupper 3 , +.Xr iswupper_l 3 , .Xr toupper 3 , +.Xr toupper_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/iswalnum.3 b/lib/libc/locale/iswalnum.3 index 9004b34ea65e..5425ceeb7e5f 100644 --- a/lib/libc/locale/iswalnum.3 +++ b/lib/libc/locale/iswalnum.3 @@ -31,9 +31,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isalnum.3 5.2 (Berkeley) 6/29/91 -.\" $FreeBSD$ -.\" .Dd October 3, 2002 .Dt ISWALNUM 3 .Os diff --git a/lib/libc/locale/iswalnum_l.3 b/lib/libc/locale/iswalnum_l.3 index 21ee48fa7b5b..69ac921c8208 100644 --- a/lib/libc/locale/iswalnum_l.3 +++ b/lib/libc/locale/iswalnum_l.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd July 25, 2012 .Dt ISWALNUM_L 3 .Os diff --git a/lib/libc/locale/iswctype.c b/lib/libc/locale/iswctype.c index 251e98c2b9c7..0693da602116 100644 --- a/lib/libc/locale/iswctype.c +++ b/lib/libc/locale/iswctype.c @@ -37,9 +37,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <wctype.h> #undef iswalnum diff --git a/lib/libc/locale/isxdigit.3 b/lib/libc/locale/isxdigit.3 index 7e065a4e255a..f6c4a47b4971 100644 --- a/lib/libc/locale/isxdigit.3 +++ b/lib/libc/locale/isxdigit.3 @@ -29,15 +29,14 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)isxdigit.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd July 17, 2005 +.Dd December 19, 2022 .Dt ISXDIGIT 3 .Os .Sh NAME .Nm isxdigit , -.Nm ishexnumber +.Nm ishexnumber , +.Nm isxdigit_l , +.Nm ishexnumber_l .Nd hexadecimal-digit character test .Sh LIBRARY .Lb libc @@ -47,10 +46,16 @@ .Fn isxdigit "int c" .Ft int .Fn ishexnumber "int c" +.Ft int +.Fn isxdigit_l "int c" "locale_t loc" +.Ft int +.Fn ishexnumber_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn isxdigit -function tests for any hexadecimal-digit character. +and +.Fn isxdigit_l +functions test for any hexadecimal-digit character. Regardless of locale, this includes the following characters only: .Bl -column \&``0''______ \&``0''______ \&``0''______ \&``0''______ \&``0''______ .It "\&``0''" Ta "``1''" Ta "``2''" Ta "``3''" Ta "``4''" @@ -62,8 +67,12 @@ Regardless of locale, this includes the following characters only: .Pp The .Fn ishexnumber -function behaves similarly to -.Fn isxdigit , +and +.Fn ishexnumber_l +functions behave similarly to +.Fn isxdigit +and +.Fn isxdigit_l , but may recognize additional characters, depending on the current locale setting. .Pp @@ -71,11 +80,16 @@ The value of the argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . +.Pp +The _l-suffixed versions take an explicit locale argument, whereas the +non-suffixed versions use the current global or per-thread locale. .Sh RETURN VALUES The .Fn isxdigit -function returns zero if the character tests false and -returns non-zero if the character tests true. +and +.Fn isxdigit_l +functions return zero if the character tests false and +return non-zero if the character tests true. .Sh COMPATIBILITY The .Bx 4.4 @@ -85,10 +99,15 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn iswxdigit +or +.Fn iswxdigit_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr iswxdigit 3 , +.Xr iswxdigit_l 3 , +.Xr xlocale 3 , .Xr ascii 7 .Sh STANDARDS The diff --git a/lib/libc/locale/ldpart.c b/lib/libc/locale/ldpart.c index 889291cf3168..77be5404b199 100644 --- a/lib/libc/locale/ldpart.c +++ b/lib/libc/locale/ldpart.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/types.h> #include <sys/stat.h> diff --git a/lib/libc/locale/ldpart.h b/lib/libc/locale/ldpart.h index 8985b324ae03..a784d12f29c0 100644 --- a/lib/libc/locale/ldpart.h +++ b/lib/libc/locale/ldpart.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _LDPART_H_ diff --git a/lib/libc/locale/lmessages.c b/lib/libc/locale/lmessages.c index 70de30650346..716dc1ead6ea 100644 --- a/lib/libc/locale/lmessages.c +++ b/lib/libc/locale/lmessages.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stddef.h> #include "ldpart.h" diff --git a/lib/libc/locale/lmessages.h b/lib/libc/locale/lmessages.h index 0e8278f4a650..a6057caa0ecf 100644 --- a/lib/libc/locale/lmessages.h +++ b/lib/libc/locale/lmessages.h @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -29,8 +29,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _LMESSAGES_H_ diff --git a/lib/libc/locale/lmonetary.c b/lib/libc/locale/lmonetary.c index ff11f26e890b..75ef6b3d53dc 100644 --- a/lib/libc/locale/lmonetary.c +++ b/lib/libc/locale/lmonetary.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include <stddef.h> #include <stdlib.h> diff --git a/lib/libc/locale/lmonetary.h b/lib/libc/locale/lmonetary.h index 69facf9f88dd..11e39545482d 100644 --- a/lib/libc/locale/lmonetary.h +++ b/lib/libc/locale/lmonetary.h @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -29,8 +29,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _LMONETARY_H_ diff --git a/lib/libc/locale/lnumeric.c b/lib/libc/locale/lnumeric.c index 253fb955f485..8f8443668314 100644 --- a/lib/libc/locale/lnumeric.c +++ b/lib/libc/locale/lnumeric.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include "ldpart.h" diff --git a/lib/libc/locale/lnumeric.h b/lib/libc/locale/lnumeric.h index 43ff16127862..eaba6ed0bf54 100644 --- a/lib/libc/locale/lnumeric.h +++ b/lib/libc/locale/lnumeric.h @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -29,8 +29,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _LNUMERIC_H_ diff --git a/lib/libc/locale/localeconv.3 b/lib/libc/locale/localeconv.3 index 6262bf886346..caea8a7529f8 100644 --- a/lib/libc/locale/localeconv.3 +++ b/lib/libc/locale/localeconv.3 @@ -27,10 +27,7 @@ .\" 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. -.\" -.\" From @(#)setlocale.3 8.1 (Berkeley) 6/9/93 .\" From FreeBSD: src/lib/libc/locale/setlocale.3,v 1.28 2003/11/15 02:26:04 tjr Exp -.\" $FreeBSD$ .\" .Dd November 21, 2003 .Dt LOCALECONV 3 diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c index 130f93c178f4..2cd629e8210d 100644 --- a/lib/libc/locale/localeconv.c +++ b/lib/libc/locale/localeconv.c @@ -6,7 +6,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -35,12 +35,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)localeconv.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <locale.h> #include "lmonetary.h" @@ -51,7 +45,7 @@ __FBSDID("$FreeBSD$"); * monetary and numeric locales. * * Because localeconv() may be called many times (especially by library - * routines like printf() & strtod()), the approprate members of the + * routines like printf() & strtod()), the appropriate members of the * lconv structure are computed only when the monetary or numeric * locale has been changed. */ diff --git a/lib/libc/locale/mblen.3 b/lib/libc/locale/mblen.3 index a491096cbbab..10404f51f785 100644 --- a/lib/libc/locale/mblen.3 +++ b/lib/libc/locale/mblen.3 @@ -28,10 +28,7 @@ .\" 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. -.\" -.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93 .\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp -.\" $FreeBSD$ .\" .Dd April 11, 2004 .Dt MBLEN 3 diff --git a/lib/libc/locale/mblen.c b/lib/libc/locale/mblen.c index 77d9745da198..f0723b2c05a9 100644 --- a/lib/libc/locale/mblen.c +++ b/lib/libc/locale/mblen.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdlib.h> #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/mblocal.h b/lib/libc/locale/mblocal.h index 1fb5902a8d11..a39117cc6352 100644 --- a/lib/libc/locale/mblocal.h +++ b/lib/libc/locale/mblocal.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2011 Nexenta Systems, Inc. All rights reserved. @@ -7,7 +7,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,8 +31,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _MBLOCAL_H_ diff --git a/lib/libc/locale/mbrlen.3 b/lib/libc/locale/mbrlen.3 index 524d2c7b4016..5c58ecea495e 100644 --- a/lib/libc/locale/mbrlen.3 +++ b/lib/libc/locale/mbrlen.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd April 7, 2004 .Dt MBRLEN 3 .Os diff --git a/lib/libc/locale/mbrlen.c b/lib/libc/locale/mbrlen.c index 4f687e98628f..e4470070752f 100644 --- a/lib/libc/locale/mbrlen.c +++ b/lib/libc/locale/mbrlen.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/mbrtoc16.c b/lib/libc/locale/mbrtoc16.c index 7f5674d97d3c..0c0d33e944f6 100644 --- a/lib/libc/locale/mbrtoc16.c +++ b/lib/libc/locale/mbrtoc16.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <uchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/mbrtoc16_iconv.c b/lib/libc/locale/mbrtoc16_iconv.c index f1eaf1925496..f4e37a0489eb 100644 --- a/lib/libc/locale/mbrtoc16_iconv.c +++ b/lib/libc/locale/mbrtoc16_iconv.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #define charXX_t char16_t #define mbrtocXX mbrtoc16 #define mbrtocXX_l mbrtoc16_l diff --git a/lib/libc/locale/mbrtoc32.c b/lib/libc/locale/mbrtoc32.c index 1238ca228b20..29b32abcf4fc 100644 --- a/lib/libc/locale/mbrtoc32.c +++ b/lib/libc/locale/mbrtoc32.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <uchar.h> #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/mbrtoc32_iconv.c b/lib/libc/locale/mbrtoc32_iconv.c index ec2c0145d9d6..503d7b378538 100644 --- a/lib/libc/locale/mbrtoc32_iconv.c +++ b/lib/libc/locale/mbrtoc32_iconv.c @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #define charXX_t char32_t #define mbrtocXX mbrtoc32 #define mbrtocXX_l mbrtoc32_l diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h index d753b3523244..35d0fd914b1f 100644 --- a/lib/libc/locale/mbrtocXX_iconv.h +++ b/lib/libc/locale/mbrtocXX_iconv.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ed Schouten <ed@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/queue.h> #include <assert.h> @@ -80,8 +77,6 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n, errno = EINVAL; return (-1); } - handle->cv_shared->ci_discard_ilseq = true; - handle->cv_shared->ci_hooks = NULL; cs->srcbuf_len = cs->dstbuf_len = 0; cs->initialized = true; if (s == NULL) @@ -112,7 +107,7 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n, assert(srcleft <= sizeof(cs->srcbuf) && dstleft <= sizeof(cs->dstbuf.bytes)); err = _citrus_iconv_convert(handle, &src, &srcleft, - &dst, &dstleft, 0, &invlen); + &dst, &dstleft, _CITRUS_ICONV_F_HIDE_INVALID, &invlen); cs->dstbuf_len = (dst - cs->dstbuf.bytes) / sizeof(charXX_t); /* Got new character(s). Return the first. */ diff --git a/lib/libc/locale/mbrtowc.3 b/lib/libc/locale/mbrtowc.3 index 22b26cd2a244..da64e2382629 100644 --- a/lib/libc/locale/mbrtowc.3 +++ b/lib/libc/locale/mbrtowc.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd May 21, 2013 .Dt MBRTOWC 3 .Os diff --git a/lib/libc/locale/mbrtowc.c b/lib/libc/locale/mbrtowc.c index 7585ef16bca2..ac1afc49a94f 100644 --- a/lib/libc/locale/mbrtowc.c +++ b/lib/libc/locale/mbrtowc.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/mbsinit.3 b/lib/libc/locale/mbsinit.3 index afc2500c3a77..6e30c3b8f958 100644 --- a/lib/libc/locale/mbsinit.3 +++ b/lib/libc/locale/mbsinit.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd April 8, 2004 .Dt MBSINIT 3 .Os diff --git a/lib/libc/locale/mbsinit.c b/lib/libc/locale/mbsinit.c index a7df81911b26..5b964c1b3d58 100644 --- a/lib/libc/locale/mbsinit.c +++ b/lib/libc/locale/mbsinit.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/mbsnrtowcs.c b/lib/libc/locale/mbsnrtowcs.c index 69e48eafdc57..9a261a297e73 100644 --- a/lib/libc/locale/mbsnrtowcs.c +++ b/lib/libc/locale/mbsnrtowcs.c @@ -1,15 +1,14 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2002-2004 Tim J. Robbins. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,9 +32,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <stdlib.h> diff --git a/lib/libc/locale/mbsrtowcs.3 b/lib/libc/locale/mbsrtowcs.3 index fb2076f98cdf..b1e2457583ec 100644 --- a/lib/libc/locale/mbsrtowcs.3 +++ b/lib/libc/locale/mbsrtowcs.3 @@ -21,8 +21,6 @@ .\" 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. -.\" -.\" $FreeBSD$ .Dd August 7, 2020 .Dt MBSRTOWCS 3 .Os diff --git a/lib/libc/locale/mbsrtowcs.c b/lib/libc/locale/mbsrtowcs.c index e85b22b492bf..0d7157cdd643 100644 --- a/lib/libc/locale/mbsrtowcs.c +++ b/lib/libc/locale/mbsrtowcs.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <stdlib.h> diff --git a/lib/libc/locale/mbstowcs.3 b/lib/libc/locale/mbstowcs.3 index d74d6a5df748..4d8d9907f3e0 100644 --- a/lib/libc/locale/mbstowcs.3 +++ b/lib/libc/locale/mbstowcs.3 @@ -28,10 +28,7 @@ .\" 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. -.\" -.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93 .\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp -.\" $FreeBSD$ .\" .Dd April 8, 2004 .Dt MBSTOWCS 3 diff --git a/lib/libc/locale/mbstowcs.c b/lib/libc/locale/mbstowcs.c index 3226d22ea254..338db46185ad 100644 --- a/lib/libc/locale/mbstowcs.c +++ b/lib/libc/locale/mbstowcs.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include <stdlib.h> #include <wchar.h> diff --git a/lib/libc/locale/mbtowc.3 b/lib/libc/locale/mbtowc.3 index 859cdf819c40..597c3acd0f63 100644 --- a/lib/libc/locale/mbtowc.3 +++ b/lib/libc/locale/mbtowc.3 @@ -28,10 +28,7 @@ .\" 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. -.\" -.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93 .\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp -.\" $FreeBSD$ .\" .Dd April 11, 2004 .Dt MBTOWC 3 diff --git a/lib/libc/locale/mbtowc.c b/lib/libc/locale/mbtowc.c index ec634807560d..c36d1d46f1c0 100644 --- a/lib/libc/locale/mbtowc.c +++ b/lib/libc/locale/mbtowc.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <stdlib.h> #include <wchar.h> diff --git a/lib/libc/locale/mskanji.5 b/lib/libc/locale/mskanji.5 index 8ebaccdd7af2..75ed206204be 100644 --- a/lib/libc/locale/mskanji.5 +++ b/lib/libc/locale/mskanji.5 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 7, 2003 .Dt MSKANJI 5 .Os diff --git a/lib/libc/locale/mskanji.c b/lib/libc/locale/mskanji.c index 1585886cea31..f0731443c154 100644 --- a/lib/libc/locale/mskanji.c +++ b/lib/libc/locale/mskanji.c @@ -11,7 +11,7 @@ * May 12, 1995 * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -42,12 +42,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <errno.h> #include <runetype.h> diff --git a/lib/libc/locale/multibyte.3 b/lib/libc/locale/multibyte.3 index 71d978458358..e134579512e3 100644 --- a/lib/libc/locale/multibyte.3 +++ b/lib/libc/locale/multibyte.3 @@ -29,9 +29,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)multibyte.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd September 9, 2019 .Dt MULTIBYTE 3 .Os diff --git a/lib/libc/locale/newlocale.3 b/lib/libc/locale/newlocale.3 index cc5043df8eb1..8dbe52e10eb9 100644 --- a/lib/libc/locale/newlocale.3 +++ b/lib/libc/locale/newlocale.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -24,8 +23,6 @@ .\" 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. -.\" -.\" $FreeBSD$ .Dd October 2, 2020 .Dt NEWLOCALE 3 .Os diff --git a/lib/libc/locale/nextwctype.3 b/lib/libc/locale/nextwctype.3 index 0f6f88079f64..b3d0b01930a5 100644 --- a/lib/libc/locale/nextwctype.3 +++ b/lib/libc/locale/nextwctype.3 @@ -23,8 +23,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd July 21, 2005 .Dt NEXTWCTYPE 3 .Os diff --git a/lib/libc/locale/nextwctype.c b/lib/libc/locale/nextwctype.c index 3ef73ddec7b6..b0416a9a1138 100644 --- a/lib/libc/locale/nextwctype.c +++ b/lib/libc/locale/nextwctype.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <runetype.h> #include <wchar.h> #include <wctype.h> diff --git a/lib/libc/locale/nl_langinfo.3 b/lib/libc/locale/nl_langinfo.3 index 73cba4c18084..591b76b6e8e6 100644 --- a/lib/libc/locale/nl_langinfo.3 +++ b/lib/libc/locale/nl_langinfo.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd December 14, 2020 .Dt NL_LANGINFO 3 .Os diff --git a/lib/libc/locale/nl_langinfo.c b/lib/libc/locale/nl_langinfo.c index b51b0425515b..7cdf2856c5bc 100644 --- a/lib/libc/locale/nl_langinfo.c +++ b/lib/libc/locale/nl_langinfo.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001, 2003 Alexey Zelkin <phantom@FreeBSD.org> * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <langinfo.h> #include <limits.h> #include <locale.h> diff --git a/lib/libc/locale/nomacros.c b/lib/libc/locale/nomacros.c index 66cf40e61ec9..680682d4447a 100644 --- a/lib/libc/locale/nomacros.c +++ b/lib/libc/locale/nomacros.c @@ -1,6 +1,3 @@ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * Tell <ctype.h> to generate extern versions of all its inline * functions. The extern versions get called if the system doesn't diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c index d95bb0087c09..8130a2f9b49e 100644 --- a/lib/libc/locale/none.c +++ b/lib/libc/locale/none.c @@ -11,7 +11,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -40,12 +40,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <runetype.h> diff --git a/lib/libc/locale/querylocale.3 b/lib/libc/locale/querylocale.3 index ecafee49a712..6ac317ef42bf 100644 --- a/lib/libc/locale/querylocale.3 +++ b/lib/libc/locale/querylocale.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -25,8 +24,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 8, 2020 .Dt QUERYLOCALE 3 .Os diff --git a/lib/libc/locale/rpmatch.3 b/lib/libc/locale/rpmatch.3 index b34c5bfa199a..1518d3b14be3 100644 --- a/lib/libc/locale/rpmatch.3 +++ b/lib/libc/locale/rpmatch.3 @@ -23,8 +23,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd July 21, 2005 .Dt RPMATCH 3 .Os diff --git a/lib/libc/locale/rpmatch.c b/lib/libc/locale/rpmatch.c index e4c366a00afb..fb778876bc30 100644 --- a/lib/libc/locale/rpmatch.c +++ b/lib/libc/locale/rpmatch.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2005 Tim J. Robbins. * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <langinfo.h> #include <regex.h> #include <stdlib.h> diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c index ce2095763eba..59537c440a39 100644 --- a/lib/libc/locale/rune.c +++ b/lib/libc/locale/rune.c @@ -34,12 +34,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <arpa/inet.h> #include <errno.h> diff --git a/lib/libc/locale/runefile.h b/lib/libc/locale/runefile.h index 18a603c03e31..dfd85bb3d504 100644 --- a/lib/libc/locale/runefile.h +++ b/lib/libc/locale/runefile.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Ruslan Ermilov * All rights reserved. @@ -24,8 +24,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _RUNEFILE_H_ diff --git a/lib/libc/locale/runetype.c b/lib/libc/locale/runetype.c index 8fe656aded05..e26104e97234 100644 --- a/lib/libc/locale/runetype.c +++ b/lib/libc/locale/runetype.c @@ -8,7 +8,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -37,9 +37,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <stdio.h> #include <runetype.h> diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 index acaba2f0a660..df64f3178fbe 100644 --- a/lib/libc/locale/setlocale.3 +++ b/lib/libc/locale/setlocale.3 @@ -28,9 +28,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 -.\" $FreeBSD$ -.\" .Dd August 7, 2020 .Dt SETLOCALE 3 .Os diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index e0ba66e0e35a..00226b2c5f00 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -33,12 +33,6 @@ * 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> @@ -312,9 +306,9 @@ int __detect_path_locale(void) { if (_PathLocale == NULL) { - char *p = getenv("PATH_LOCALE"); + char *p = secure_getenv("PATH_LOCALE"); - if (p != NULL && !issetugid()) { + if (p != NULL) { if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) return (ENAMETOOLONG); diff --git a/lib/libc/locale/setlocale.h b/lib/libc/locale/setlocale.h index c199cdf62daf..c6d6f7b0fac1 100644 --- a/lib/libc/locale/setlocale.h +++ b/lib/libc/locale/setlocale.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia. * All rights reserved. @@ -24,8 +24,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _SETLOCALE_H_ diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index 41c82e637529..bb89812486fa 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -8,7 +8,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -37,9 +37,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #define __RUNETYPE_INTERNAL 1 #include <runetype.h> diff --git a/lib/libc/locale/table.c b/lib/libc/locale/table.c index 2f790afd4dd8..da600f4a44df 100644 --- a/lib/libc/locale/table.c +++ b/lib/libc/locale/table.c @@ -8,7 +8,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -37,12 +37,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <runetype.h> #include <wchar.h> diff --git a/lib/libc/locale/toascii.3 b/lib/libc/locale/toascii.3 index 0a11a017b3ae..960b62b3cb1d 100644 --- a/lib/libc/locale/toascii.3 +++ b/lib/libc/locale/toascii.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd June 4, 1993 .Dt TOASCII 3 .Os diff --git a/lib/libc/locale/tolower.3 b/lib/libc/locale/tolower.3 index 0c6dfd9349fb..dddf1f38f75c 100644 --- a/lib/libc/locale/tolower.3 +++ b/lib/libc/locale/tolower.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)tolower.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd July 25, 2010 +.Dd December 19, 2022 .Dt TOLOWER 3 .Os .Sh NAME -.Nm tolower +.Nm tolower , +.Nm tolower_l .Nd upper case to lower case letter conversion .Sh LIBRARY .Lb libc @@ -44,19 +42,31 @@ .In ctype.h .Ft int .Fn tolower "int c" +.Ft int +.Fn tolower_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn tolower -function converts an upper-case letter to the corresponding lower-case +and +.Fn tolower_l +functions convert an upper-case letter to the corresponding lower-case letter. The argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . +.Pp +The +.Fn tolower_l +function takes an explicit locale argument, whereas the +.Fn tolower +function uses the current global or per-thread locale. .Sh RETURN VALUES If the argument is an upper-case letter, the .Fn tolower -function returns the corresponding lower-case letter if there is +and +.Fn tolower_l +functions return the corresponding lower-case letter if there is one; otherwise, the argument is returned unchanged. .Sh COMPATIBILITY The @@ -67,11 +77,17 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn towlower +or +.Fn towlower_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr islower 3 , -.Xr towlower 3 +.Xr islower_l 3 , +.Xr towlower 3 , +.Xr towlower_l 3 , +.Xr xlocale 3 .Sh STANDARDS The .Fn tolower diff --git a/lib/libc/locale/tolower.c b/lib/libc/locale/tolower.c index 00ac7279fbb4..0401147705c6 100644 --- a/lib/libc/locale/tolower.c +++ b/lib/libc/locale/tolower.c @@ -8,7 +8,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -37,9 +37,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <stdio.h> #include <runetype.h> diff --git a/lib/libc/locale/toupper.3 b/lib/libc/locale/toupper.3 index 5a3cf3fadeff..e0e6b367e8c7 100644 --- a/lib/libc/locale/toupper.3 +++ b/lib/libc/locale/toupper.3 @@ -29,14 +29,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd July 25, 2010 +.Dd December 19, 2022 .Dt TOUPPER 3 .Os .Sh NAME -.Nm toupper +.Nm toupper , +.Nm toupper_l .Nd lower case to upper case letter conversion .Sh LIBRARY .Lb libc @@ -44,19 +42,31 @@ .In ctype.h .Ft int .Fn toupper "int c" +.Ft int +.Fn toupper_l "int c" "locale_t loc" .Sh DESCRIPTION The .Fn toupper -function converts a lower-case letter to the corresponding +and +.Fn toupper_l +functions convert a lower-case letter to the corresponding upper-case letter. The argument must be representable as an .Vt "unsigned char" or the value of .Dv EOF . +.Pp +The +.Fn toupper_l +function takes an explicit locale argument, whereas the +.Fn toupper +function uses the current global or per-thread locale. .Sh RETURN VALUES If the argument is a lower-case letter, the .Fn toupper -function returns the corresponding upper-case letter if there is +and +.Fn toupper_l +functions return the corresponding upper-case letter if there is one; otherwise, the argument is returned unchanged. .Sh COMPATIBILITY The @@ -67,11 +77,17 @@ type in locales with large character sets is considered obsolete and may not be supported in future releases. The .Fn towupper +or +.Fn towupper_l function should be used instead. .Sh SEE ALSO .Xr ctype 3 , +.Xr ctype_l 3 , .Xr isupper 3 , -.Xr towupper 3 +.Xr isupper_l 3 , +.Xr towupper 3 , +.Xr towupper_l 3 , +.Xr xlocale 3 .Sh STANDARDS The .Fn toupper diff --git a/lib/libc/locale/toupper.c b/lib/libc/locale/toupper.c index 26bb93f3f2da..bff6c5bf32e3 100644 --- a/lib/libc/locale/toupper.c +++ b/lib/libc/locale/toupper.c @@ -8,7 +8,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -37,9 +37,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <stdio.h> #include <runetype.h> diff --git a/lib/libc/locale/towlower.3 b/lib/libc/locale/towlower.3 index d8742aba1aac..bcc78da10689 100644 --- a/lib/libc/locale/towlower.3 +++ b/lib/libc/locale/towlower.3 @@ -29,9 +29,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)tolower.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd October 3, 2002 .Dt TOWLOWER 3 .Os diff --git a/lib/libc/locale/towupper.3 b/lib/libc/locale/towupper.3 index f139b94a6ef6..f9e9b115b13e 100644 --- a/lib/libc/locale/towupper.3 +++ b/lib/libc/locale/towupper.3 @@ -29,9 +29,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)toupper.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd October 3, 2002 .Dt TOWUPPER 3 .Os diff --git a/lib/libc/locale/uselocale.3 b/lib/libc/locale/uselocale.3 index 96d0008f7837..269430e40da6 100644 --- a/lib/libc/locale/uselocale.3 +++ b/lib/libc/locale/uselocale.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -25,8 +24,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 17, 2011 .Dt USELOCALE 3 .Os diff --git a/lib/libc/locale/utf8.5 b/lib/libc/locale/utf8.5 index ca7f3f81e2f9..890caee1559c 100644 --- a/lib/libc/locale/utf8.5 +++ b/lib/libc/locale/utf8.5 @@ -28,9 +28,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd April 7, 2004 .Dt UTF8 5 .Os diff --git a/lib/libc/locale/utf8.c b/lib/libc/locale/utf8.c index 13f957989fa2..3eb5f21bc3b3 100644 --- a/lib/libc/locale/utf8.c +++ b/lib/libc/locale/utf8.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2011 Nexenta Systems, Inc. All rights reserved. @@ -7,7 +7,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,8 +34,6 @@ */ #include <sys/param.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <runetype.h> diff --git a/lib/libc/locale/wcrtomb.3 b/lib/libc/locale/wcrtomb.3 index bc741740a249..b1881c390c71 100644 --- a/lib/libc/locale/wcrtomb.3 +++ b/lib/libc/locale/wcrtomb.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd May 21, 2013 .Dt WCRTOMB 3 .Os diff --git a/lib/libc/locale/wcrtomb.c b/lib/libc/locale/wcrtomb.c index fa5c08474475..ef7d502486b8 100644 --- a/lib/libc/locale/wcrtomb.c +++ b/lib/libc/locale/wcrtomb.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/wcsftime.3 b/lib/libc/locale/wcsftime.3 index 92aee9313f59..473eec567d63 100644 --- a/lib/libc/locale/wcsftime.3 +++ b/lib/libc/locale/wcsftime.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 8, 2002 .Dt WCSFTIME 3 .Os diff --git a/lib/libc/locale/wcsftime.c b/lib/libc/locale/wcsftime.c index 772c96c2f9f4..f77b4e9a33f8 100644 --- a/lib/libc/locale/wcsftime.c +++ b/lib/libc/locale/wcsftime.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Tim J. Robbins * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <stdlib.h> diff --git a/lib/libc/locale/wcsnrtombs.c b/lib/libc/locale/wcsnrtombs.c index 7fdbfc75156d..b7c7738bd85f 100644 --- a/lib/libc/locale/wcsnrtombs.c +++ b/lib/libc/locale/wcsnrtombs.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2013 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. @@ -7,7 +7,7 @@ * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -33,9 +33,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include <stdlib.h> #include <string.h> diff --git a/lib/libc/locale/wcsrtombs.3 b/lib/libc/locale/wcsrtombs.3 index ff607c2dad11..2de5bc956f5c 100644 --- a/lib/libc/locale/wcsrtombs.3 +++ b/lib/libc/locale/wcsrtombs.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd July 21, 2004 .Dt WCSRTOMBS 3 .Os diff --git a/lib/libc/locale/wcsrtombs.c b/lib/libc/locale/wcsrtombs.c index 1466eab7046d..f949d9331abb 100644 --- a/lib/libc/locale/wcsrtombs.c +++ b/lib/libc/locale/wcsrtombs.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include <stdlib.h> #include <string.h> diff --git a/lib/libc/locale/wcstod.3 b/lib/libc/locale/wcstod.3 index f8c5135ee86b..15af283fdd06 100644 --- a/lib/libc/locale/wcstod.3 +++ b/lib/libc/locale/wcstod.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd February 22, 2003 .Dt WCSTOD 3 .Os diff --git a/lib/libc/locale/wcstod.c b/lib/libc/locale/wcstod.c index 42d8acdafcdb..94a5ff4612a5 100644 --- a/lib/libc/locale/wcstod.c +++ b/lib/libc/locale/wcstod.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Tim J. Robbins * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdlib.h> #include <wchar.h> #include <wctype.h> diff --git a/lib/libc/locale/wcstof.c b/lib/libc/locale/wcstof.c index 34117557ee0f..0c2c7946e89b 100644 --- a/lib/libc/locale/wcstof.c +++ b/lib/libc/locale/wcstof.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002, 2003 Tim J. Robbins * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdlib.h> #include <wchar.h> #include <wctype.h> diff --git a/lib/libc/locale/wcstoimax.c b/lib/libc/locale/wcstoimax.c index 5e4d9af26a80..29e12f809812 100644 --- a/lib/libc/locale/wcstoimax.c +++ b/lib/libc/locale/wcstoimax.c @@ -5,7 +5,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,15 +34,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoimax.c,v 1.8 2002/09/06 11:23:59 tjr Exp "); -#endif -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <inttypes.h> #include <stdlib.h> @@ -80,11 +71,21 @@ wcstoimax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, c = *s++; } if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) { + c == L'0' && (*s == L'x' || *s == L'X') && + ((s[1] >= L'0' && s[1] <= L'9') || + (s[1] >= L'A' && s[1] <= L'F') || + (s[1] >= L'a' && s[1] <= L'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == L'0' && (*s == L'b' || *s == L'B') && + (s[1] >= L'0' && s[1] <= L'1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = c == L'0' ? 8 : 10; acc = any = 0; diff --git a/lib/libc/locale/wcstol.3 b/lib/libc/locale/wcstol.3 index e69a72672d54..725473cebb66 100644 --- a/lib/libc/locale/wcstol.3 +++ b/lib/libc/locale/wcstol.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 7, 2002 .Dt WCSTOL 3 .Os diff --git a/lib/libc/locale/wcstol.c b/lib/libc/locale/wcstol.c index 98bd5f85a4d1..2b83187347c2 100644 --- a/lib/libc/locale/wcstol.c +++ b/lib/libc/locale/wcstol.c @@ -5,7 +5,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,9 +34,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <errno.h> #include <limits.h> @@ -65,7 +62,7 @@ wcstol_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int do { c = *s++; } while (iswspace_l(c, locale)); - if (c == '-') { + if (c == L'-') { neg = 1; c = *s++; } else { @@ -74,11 +71,21 @@ wcstol_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int c = *s++; } if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) { + c == L'0' && (*s == L'x' || *s == L'X') && + ((s[1] >= L'0' && s[1] <= L'9') || + (s[1] >= L'A' && s[1] <= L'F') || + (s[1] >= L'a' && s[1] <= L'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == L'0' && (*s == L'b' || *s == L'B') && + (s[1] >= L'0' && s[1] <= L'1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = c == L'0' ? 8 : 10; acc = any = 0; diff --git a/lib/libc/locale/wcstold.c b/lib/libc/locale/wcstold.c index c31f84118a2f..1fe7c26ff79a 100644 --- a/lib/libc/locale/wcstold.c +++ b/lib/libc/locale/wcstold.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002, 2003 Tim J. Robbins * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdlib.h> #include <wchar.h> #include <wctype.h> diff --git a/lib/libc/locale/wcstoll.c b/lib/libc/locale/wcstoll.c index 6c3184a0de34..01ee701af016 100644 --- a/lib/libc/locale/wcstoll.c +++ b/lib/libc/locale/wcstoll.c @@ -5,7 +5,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,15 +34,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoll.c,v 1.19 2002/09/06 11:23:59 tjr Exp "); -#endif -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <stdlib.h> @@ -80,11 +71,21 @@ wcstoll_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, c = *s++; } if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) { + c == L'0' && (*s == L'x' || *s == L'X') && + ((s[1] >= L'0' && s[1] <= L'9') || + (s[1] >= L'A' && s[1] <= L'F') || + (s[1] >= L'a' && s[1] <= L'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == L'0' && (*s == L'b' || *s == L'B') && + (s[1] >= L'0' && s[1] <= L'1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = c == L'0' ? 8 : 10; acc = any = 0; diff --git a/lib/libc/locale/wcstombs.3 b/lib/libc/locale/wcstombs.3 index 0f216f62d11a..82476de25427 100644 --- a/lib/libc/locale/wcstombs.3 +++ b/lib/libc/locale/wcstombs.3 @@ -28,10 +28,7 @@ .\" 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. -.\" -.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93 .\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp -.\" $FreeBSD$ .\" .Dd April 8, 2004 .Dt WCSTOMBS 3 diff --git a/lib/libc/locale/wcstombs.c b/lib/libc/locale/wcstombs.c index a34b58ecdb05..962614bf88f3 100644 --- a/lib/libc/locale/wcstombs.c +++ b/lib/libc/locale/wcstombs.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include <stdlib.h> #include <wchar.h> diff --git a/lib/libc/locale/wcstoul.c b/lib/libc/locale/wcstoul.c index b550e869f7c5..b4fa4d439e10 100644 --- a/lib/libc/locale/wcstoul.c +++ b/lib/libc/locale/wcstoul.c @@ -5,7 +5,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,9 +34,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <errno.h> #include <limits.h> @@ -74,11 +71,21 @@ wcstoul_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, c = *s++; } if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) { + c == L'0' && (*s == L'x' || *s == L'X') && + ((s[1] >= L'0' && s[1] <= L'9') || + (s[1] >= L'A' && s[1] <= L'F') || + (s[1] >= L'a' && s[1] <= L'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == L'0' && (*s == L'b' || *s == L'B') && + (s[1] >= L'0' && s[1] <= L'1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = c == L'0' ? 8 : 10; acc = any = 0; diff --git a/lib/libc/locale/wcstoull.c b/lib/libc/locale/wcstoull.c index 6a04d213ff9b..db77acd2a55d 100644 --- a/lib/libc/locale/wcstoull.c +++ b/lib/libc/locale/wcstoull.c @@ -5,7 +5,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,15 +34,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoull.c,v 1.18 2002/09/06 11:23:59 tjr Exp "); -#endif -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <limits.h> #include <stdlib.h> @@ -80,11 +71,21 @@ wcstoull_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, c = *s++; } if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) { + c == L'0' && (*s == L'x' || *s == L'X') && + ((s[1] >= L'0' && s[1] <= L'9') || + (s[1] >= L'A' && s[1] <= L'F') || + (s[1] >= L'a' && s[1] <= L'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == L'0' && (*s == L'b' || *s == L'B') && + (s[1] >= L'0' && s[1] <= L'1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = c == L'0' ? 8 : 10; acc = any = 0; diff --git a/lib/libc/locale/wcstoumax.c b/lib/libc/locale/wcstoumax.c index 0c1cd0b4b8dc..6a3861618e3e 100644 --- a/lib/libc/locale/wcstoumax.c +++ b/lib/libc/locale/wcstoumax.c @@ -5,7 +5,7 @@ * The Regents of the University of California. All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -34,15 +34,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -#if 0 -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoumax.c,v 1.8 2002/09/06 11:23:59 tjr Exp "); -#endif -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <inttypes.h> #include <stdlib.h> @@ -80,11 +71,21 @@ wcstoumax_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, c = *s++; } if ((base == 0 || base == 16) && - c == L'0' && (*s == L'x' || *s == L'X')) { + c == L'0' && (*s == L'x' || *s == L'X') && + ((s[1] >= L'0' && s[1] <= L'9') || + (s[1] >= L'A' && s[1] <= L'F') || + (s[1] >= L'a' && s[1] <= L'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == L'0' && (*s == L'b' || *s == L'B') && + (s[1] >= L'0' && s[1] <= L'1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = c == L'0' ? 8 : 10; acc = any = 0; diff --git a/lib/libc/locale/wctob.c b/lib/libc/locale/wctob.c index b43761c48d45..9ae1aa003331 100644 --- a/lib/libc/locale/wctob.c +++ b/lib/libc/locale/wctob.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <limits.h> #include <stdio.h> #include <wchar.h> diff --git a/lib/libc/locale/wctomb.3 b/lib/libc/locale/wctomb.3 index e70a2bde71d0..bd6ea0f36519 100644 --- a/lib/libc/locale/wctomb.3 +++ b/lib/libc/locale/wctomb.3 @@ -28,10 +28,7 @@ .\" 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. -.\" -.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93 .\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp -.\" $FreeBSD$ .\" .Dd April 8, 2004 .Dt WCTOMB 3 diff --git a/lib/libc/locale/wctomb.c b/lib/libc/locale/wctomb.c index 820021a3e0ab..7138ae7df3a2 100644 --- a/lib/libc/locale/wctomb.c +++ b/lib/libc/locale/wctomb.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002-2004 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdlib.h> #include <wchar.h> #include "mblocal.h" diff --git a/lib/libc/locale/wctrans.3 b/lib/libc/locale/wctrans.3 index ce3e68c9eb34..df0de9c4332d 100644 --- a/lib/libc/locale/wctrans.3 +++ b/lib/libc/locale/wctrans.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd October 3, 2002 .Dt WCTRANS 3 .Os diff --git a/lib/libc/locale/wctrans.c b/lib/libc/locale/wctrans.c index 36cb25e45549..9d2371814560 100644 --- a/lib/libc/locale/wctrans.c +++ b/lib/libc/locale/wctrans.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <string.h> #include <wctype.h> diff --git a/lib/libc/locale/wctype.3 b/lib/libc/locale/wctype.3 index 099631d51790..41ac77d38648 100644 --- a/lib/libc/locale/wctype.3 +++ b/lib/libc/locale/wctype.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd March 27, 2004 .Dt WCTYPE 3 .Os diff --git a/lib/libc/locale/wctype.c b/lib/libc/locale/wctype.c index dd8f218306b2..1b3ac054bc0b 100644 --- a/lib/libc/locale/wctype.c +++ b/lib/libc/locale/wctype.c @@ -1,11 +1,11 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 Tim J. Robbins. * All rights reserved. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <ctype.h> #include <string.h> #include <wctype.h> diff --git a/lib/libc/locale/wcwidth.3 b/lib/libc/locale/wcwidth.3 index 0c7c74fed155..28d39e949ca3 100644 --- a/lib/libc/locale/wcwidth.3 +++ b/lib/libc/locale/wcwidth.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd August 17, 2004 .Dt WCWIDTH 3 .Os diff --git a/lib/libc/locale/wcwidth.c b/lib/libc/locale/wcwidth.c index 53145e9b8254..118680d4f2bd 100644 --- a/lib/libc/locale/wcwidth.c +++ b/lib/libc/locale/wcwidth.c @@ -13,7 +13,7 @@ * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. + * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * @@ -42,9 +42,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <wchar.h> #include <wctype.h> #include <xlocale.h> diff --git a/lib/libc/locale/xlocale.3 b/lib/libc/locale/xlocale.3 index da217c601100..3af7a38a76d1 100644 --- a/lib/libc/locale/xlocale.3 +++ b/lib/libc/locale/xlocale.3 @@ -1,5 +1,4 @@ .\" Copyright (c) 2011 The FreeBSD Foundation -.\" All rights reserved. .\" .\" This documentation was written by David Chisnall under sponsorship from .\" the FreeBSD Foundation. @@ -25,8 +24,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 17, 2011 .Dt XLOCALE 3 .Os @@ -169,10 +166,10 @@ along with the headers that expose them, is provided here: .Xr vsprintf_l 3 , .Xr vsscanf_l 3 .It In stdlib.h -.Xr atof_l 3 , -.Xr atoi_l 3 , -.Xr atol_l 3 , -.Xr atoll_l 3 , +.\".Xr atof_l 3 , +.\".Xr atoi_l 3 , +.\".Xr atol_l 3 , +.\".Xr atoll_l 3 , .Xr mblen_l 3 , .Xr mbstowcs_l 3 , .Xr mbtowc_l 3 , @@ -181,10 +178,8 @@ along with the headers that expose them, is provided here: .Xr strtol_l 3 , .Xr strtold_l 3 , .Xr strtoll_l 3 , -.Xr strtoq_l 3 , .Xr strtoul_l 3 , .Xr strtoull_l 3 , -.Xr strtouq_l 3 , .Xr wcstombs_l 3 , .Xr wctomb_l 3 .It In string.h diff --git a/lib/libc/locale/xlocale.c b/lib/libc/locale/xlocale.c index 4bddc43c086b..0a95fda83aeb 100644 --- a/lib/libc/locale/xlocale.c +++ b/lib/libc/locale/xlocale.c @@ -1,8 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. * * This software was developed by David Chisnall under sponsorship from * the FreeBSD Foundation. @@ -27,8 +26,6 @@ * 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. - * - * $FreeBSD$ */ #include <pthread.h> diff --git a/lib/libc/locale/xlocale_private.h b/lib/libc/locale/xlocale_private.h index bc40f28fc9eb..ef1a8687a376 100644 --- a/lib/libc/locale/xlocale_private.h +++ b/lib/libc/locale/xlocale_private.h @@ -1,8 +1,7 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. * * This software was developed by David Chisnall under sponsorship from * the FreeBSD Foundation. @@ -27,8 +26,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _XLOCALE_PRIVATE__H_ @@ -164,7 +161,10 @@ xlocale_release(void *val) /** * Load functions. Each takes the name of a locale and a pointer to the data - * to be initialised as arguments. Two special values are allowed for the + * to be initialised as arguments. Three special values are allowed for the + * name of the locale: C, POSIX, and C.UTF-8. When these are used, we may + * use some statically defined tables rather than allocating memory for the + * locales' use. */ extern void* __collate_load(const char*, locale_t); extern void* __ctype_load(const char*, locale_t); |
