Commit graph

683 commits

Author SHA1 Message Date
Christopher Davidson 96a2e036b7 Update manual page references and macros to align to mandoc syntax
xlocale.3: Comment out reference to atof_l(3), atoi_l(3), atol_l(3), atoll_l(3)
  These manual page references do not exist.

lagg.4: Change the reference for /etc/rc.conf from a reference link
  .Xr -> .Pa based on the context within the manual page it is used.

buf.9: Remove .Xr entries from the file
  The buf.9 manual page contains a commented out .Xr reference.
  The <filmmein> 9 entry is a placeholder and has been removed for
  clarity.

Reviewed by:	mhorne
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1114
2024-04-23 12:50:54 -03:00
rilysh 2f1da80f21 libc(localeconv.c): fix "appropriate" spelling
From "approprate" to "appropriate".

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1119
2024-04-12 16:34:51 -06:00
Brooks Davis ec911a4f10 libc/locale: don't expose nonexistant __collate_load_error
The private symbol __collate_load_error was removed in 2015 in commit
2a6abeebef.  While it had previously been accidently removed in 2011
(commit 3c87aa1d3dc1a) and restored in 2012 (commit bb4317bf3c) I
think it's time to write it off after four major releases without it.

Fixes:		2a6abeebef The collate functions within libc have...

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D44182
2024-03-05 01:00:50 +00:00
Warner Losh dc36d6f9bb lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Brooks Davis 9fc0ff9d85 libc: remove some obsolete VCS data
These wide char support files were copied from the previous versions
with expanded $FreeBSD$ strings in #if 0 blocks.  Remove them and the
scssid definitions in the same #if 0 blocks.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42688
2023-11-21 22:46:43 +00:00
Brooks Davis 1ca63a8219 libc: Remove empty comments in Symbol.map
These were left over from $FreeBSD$ removal.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42612
2023-11-15 17:51:03 +00:00
Warner Losh 559a218c9b libc: Purge unneeded cdefs.h
These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42385
2023-11-01 16:44:30 -06:00
Dag-Erling Smørgrav d9dc1603d6 libc: Implement N2630.
This adds formatted input/output of binary integer numbers to the printf(), scanf(), and strtol() families, including their wide-character counterparts.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41511
2023-08-28 15:33:51 +00:00
Dag-Erling Smørgrav b8b6bef43f libc: Fix parsing of hexadecimal numbers in strtol() family.
This had previously been partly fixed in 2571c7f720.

MFC after:	1 week
Reviewed by:	imp, allanjude, emaste
Differential Revision:	https://reviews.freebsd.org/D41510
2023-08-24 21:31:54 +00:00
Kyle Evans 939199a2b5 libc: iconv: zero out cv_shared on allocation
Right now we have to zero-initialize most fields in the varius callers,
but this is a little error prone.  Simplify it by zeroing it out upon
allocation instead, drop the other redundant initialization.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41546
2023-08-22 22:40:45 -05:00
Kyle Evans e2030ca246 libc: fix c*rtomb/mbrtoc*
In 693f88c9da ("iconv_std: complete the //IGNORE support"), we
more completely implemented //IGNORE, which changed the semantics of
ci_discard_ilseq. DISCARD_ILSEQ semantics are supposed to match
//IGNORE, so we really can't do much about that particular
incompatibility.  This broke c*rtomb and mbrtoc* handling of invalid
sequences, but it turns out they don't want DISCARD_ILSEQ semantics at
all; they really want the subset that we call
_CITRUS_ICONV_F_HIDE_INVALID.

This restores the exact flow in iconv_std to precisely how it happened
prior to 693f88c9da.

PR:	265871
Fixes:	693f88c9da ("iconv_std: complete the //IGNORE support")
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41513
2023-08-22 22:40:45 -05:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Kyle Evans b744861818 libc: locale: flesh out an incomplete comment
Extrapolate from the context what the intention for the rest of the
comment probably was -- that the C/POSIX (and now C.UTF-8) locales may
avoid an allocation and reuse a global table.

Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D41087
2023-07-20 23:27:24 -05:00
Kyle Evans e15da6b10a libc: locale: fix collation file size validation
At a minimum, we need enough for the colllation format version string +
locale definition version string and a full collate_info definition,
rather than just the first two and a pointer.

Sponsored by:	Klara, Inc.
2023-05-28 12:54:24 -05:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Yuri Pankov 269dea90d6 libc: use separate collate objects for C, POSIX, and C.UTF-8
Fix newlocale() overwriting the locale name in collate object
when same instance was used for those locales, and querylocale()
reporting unexpected value for LC_COLLATE_MASK.

PR:		255646, 269375
Reviewed by:	markj, bapt (previous version)
Differential Revision:	https://reviews.freebsd.org/D30146
2023-03-28 17:16:30 +02:00
Mark Johnston 68ca8363c7 libc: Use secure_getenv(3) where appropriate
No functional change intended.

Reviewed by:	mjg, imp, kib
Differential Revision:	https://reviews.freebsd.org/D39278
2023-03-27 08:56:22 -04:00
Val Packett 939b24b0ab xlocale: garbage collect references to strtoq_l/strtouq_l
These were explicitly never implemented (see
lib/libc/locale/DESIGN.xlocale), but were referenced in the
manpage and the symbol map.

Fixes:          3c87aa1d3d ("Implement xlocale APIs from Darwin")
Reported by:    ld.lld 16 being --no-undefined-version by default
Reviewed by:    theraven, emaste
Sponsored by:   https://www.patreon.com/valpackett
Pull Request:	https://github.com/freebsd/freebsd-src/pull/679
Differential Revision: https://reviews.freebsd.org/D38408
2023-03-02 15:53:29 -05:00
Jose Luis Duran 77e4249319 xlocale(3): Link man pages
- provide various missing MLINKS for library functions
- update various SEE ALSO section to include the
  new linked manual pages
- add various definitions of new functions like isideogram_l(3)
- document COMPATIBILITY for some functions
- bump man page dates

Reviewed by:	gbe, bcr
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/621
Differential Revision:	https://reviews.freebsd.org/D37203
2022-12-19 05:54:52 +01:00
Ed Maste 5b5fa75acf libc: drop "All rights reserved" from Foundation copyrights
This has already been done for most files that have the Foundation as
the only listed copyright holder.  Do it now for files that list
multiple copyright holders, but have the Foundation copyright in its own
section.

Sponsored by:	The FreeBSD Foundation
2022-08-04 16:57:50 -04:00
Ed Maste 560e22c8fe Remove "All Rights Reserved" from FreeBSD Foundation libc copyrights
As per the updated FreeBSD copyright template.  These were unambiguous
cases where the Foundation was the only listed copyright holder.

Sponsored by:	The FreeBSD Foundation
2022-07-21 09:53:31 -04:00
Gordon Bergling 4b7f35db44 libc: Add HISTORY sections to the manual pages
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.

Obtained from:	OpenBSD
MFC after:	1 month
Differential Revision: https://reviews.freebsd.org/D34759
2022-05-05 18:46:32 +02:00
Konstantin Belousov 529575be27 lnumeric.c: replace some space*8 by tabs
Reported by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-02-03 20:56:03 +02:00
Konstantin Belousov ef061a2e29 __ctype_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:04:00 +02:00
Konstantin Belousov 87151b60e0 __numeric_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:52 +02:00
Konstantin Belousov 1aa669c5f9 libc/locale/lnumeric.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:44 +02:00
Konstantin Belousov 4d3b84f67c __monetary_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:35 +02:00
Konstantin Belousov 0fed1e6f18 libc/locale/lmonetary.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:29 +02:00
Konstantin Belousov bc9ce839f9 __messages_load(): check for calloc() failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:24 +02:00
Konstantin Belousov 5b7e92d48f libc/locale/lmessages.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:17 +02:00
Konstantin Belousov b8ad908ad9 __collate_load(): check for calloc failure
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:03:07 +02:00
Konstantin Belousov a8be061167 libc/locale/collate.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:59 +02:00
Konstantin Belousov 7bf532c9d4 xlocale.c: only call init_key() when locale was successfully allocated
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:59 +02:00
Konstantin Belousov b68522308d xlocale.c: check for allocation failure
PR:	261679
Reported by:	phil.stone@gmx.com
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:58 +02:00
Konstantin Belousov fcdf9d7de5 xlocale.c:init_key(): do not ignore errors from pthread_key_create()
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:58 +02:00
Konstantin Belousov aaa6fa65a6 libc/locale/xlocale.c: minor style
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34140
2022-02-03 03:02:58 +02:00
Mark Johnston 7eb138a9e5 libc/locale: Fix races between localeconv(3) and setlocale(3)
Each locale embeds a lazily initialized lconv which is populated by
localeconv(3) and localeconv_l(3).  When setlocale(3) updates the global
locale, the lconv needs to be (lazily) reinitialized.  To signal this,
we set flag variables in the locale structure.  There are two problems:

- The flags are set before the locale is fully updated, so a concurrent
  localeconv() call can observe partially initialized locale data.
- No barriers ensure that localeconv() observes a fully initialized
  locale if a flag is set.

So, move the flag update appropriately, and use acq/rel barriers to
provide some synchronization.  Note that this is inadequate in the face
of multiple concurrent calls to setlocale(3), but this is not expected
to work regardless.

Thanks to Henry Hu <henry.hu.sh@gmail.com> for providing a test case
demonstrating the race.

PR:		258360
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31899
2021-09-17 10:47:46 -04:00
Mark Johnston 98bfb9dac2 libc/locale: Use O_CLOEXEC when opening locale tables
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-07-29 09:14:50 -04:00
Konstantin Belousov 3ae8d83d04 Remove __NO_TLS.
All supported platforms support thread-local vars and __thread.

Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28796
2021-02-23 20:08:10 +02:00
Gordon Bergling f6d234d870 libc: Fix most issues reported by mandoc
- varios "new sentence, new line" warnings
- varios "sections out of conventional order" warnings
- varios "unusual Xr order" warnings
- varios "missing section argument" warnings
- varios "no blank before trailing delimiter" warnings
- varios "normalizing date format" warnings

MFC after:	1 month
2020-12-19 14:54:28 +00:00
Yuri Pankov 3cd6e2390c nl_langinfo(3): document recognized item names
While here, remove .Tn macro usage (prompted by mandoc lint).

PR:		251468
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D27606
2020-12-17 02:33:52 +00:00
Thomas Munro cc7edd258c Add collation version support to querylocale(3).
Provide a way to ask for an opaque version string for a locale_t, so
that potential changes in sort order can be detected.  Similar to
ICU's ucol_getVersion() and Windows' GetNLSVersionEx(), this API is
intended to allow databases to detect when text order-based indexes
might need to be rebuilt.

The CLDR version is extracted from CLDR source data by the Makefile
under tools/tools/locale, written into the machine-generated Makefile
under shared/colldef, passed to localedef -V, and then written into
LC_COLLATE file headers.  The initial version is 34.0.
tools/tools/locale was recently updated to pull down 35.0, but the
output hasn't been committed under share/colldef yet, so that will
provide the first observable change when it happens.  Other versioning
schemes are possible in future, because the format is unspecified.

Reviewed by:	bapt, 0mp, kib, yuripv (albeit a long time ago)
Differential Revision:	https://reviews.freebsd.org/D17166
2020-11-08 02:50:34 +00:00
Mark Johnston afd95785c0 newlocale(3): Fix a memory leak.
newlocale() optionally takes a "base" locale, from which components not
specified in the mask are inherited.  POSIX says that newlocale() may
modify "base" and return it, or free "base" and return a newly allocated
locale.  We were not doing either, so applications which use newlocale()
to modify an existing base locale end up leaking memory on FreeBSD.

This diff fixes the leak by releasing a reference to the base locale
before returning.  This is less efficient than modifying "base"
directly, but is simpler for an initial bug fix.  Also, update the man
page to clarify behaviour with respect to "base".

PR:		249416
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26522
2020-10-02 18:35:55 +00:00