| #
cf85e703
|
| 26-Nov-2025 |
Jose Luis Duran <jlduran@FreeBSD.org> |
strfmon: Fix negative sign handling for C locale
If the locale's positive_sign and negative_sign values would both be returned by localeconv() as empty strings, strfmon() shall behave as if the nega
strfmon: Fix negative sign handling for C locale
If the locale's positive_sign and negative_sign values would both be returned by localeconv() as empty strings, strfmon() shall behave as if the negative_sign value was the string "-".
This occurs with the C locale. The implementation previously assigned "0" to sign_posn (parentheses around the entire string); now it assigns it to "1" (sign before the string) when it is undefined (CHAR_MAX).
Austin Group Defect 1199[1] is applied, changing the requirements for the '+' and '(' flags.
[1]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53913
show more ...
|
| #
1fd01897
|
| 26-Nov-2025 |
Jose Luis Duran <jlduran@FreeBSD.org> |
strfmon: EINVAL if the '+' flag and both signs are empty
According to the Open Group Base Specifications Issue 8[1], strfmon(3) should return EINVAL when the '+' flag was included in a conversion sp
strfmon: EINVAL if the '+' flag and both signs are empty
According to the Open Group Base Specifications Issue 8[1], strfmon(3) should return EINVAL when the '+' flag was included in a conversion specification and the locale's positive_sign and negative_sign values would both be returned by localeconv(3) as empty strings.
Austin Group Defect 1199[2] is applied, adding the [EINVAL] error.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html [2]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53912
show more ...
|
| #
91e7f19e
|
| 23-Nov-2025 |
Jose Luis Duran <jlduran@FreeBSD.org> |
strfmon: Fix typo s/poistion/position/
MFC after: 1 week
|
| #
86e2bcbf
|
| 09-Dec-2023 |
Konstantin Belousov <kib@FreeBSD.org> |
strfmon.c: Use the restrict keyword directly
libc sources assume C99 or even C11 compiler already, unlike headers. There is no reason to obfuscate the basic C constructs.
Sponsored by: The FreeBSD
strfmon.c: Use the restrict keyword directly
libc sources assume C99 or even C11 compiler already, unlike headers. There is no reason to obfuscate the basic C constructs.
Sponsored by: The FreeBSD Foundation MFC after: 1 week
show more ...
|
| #
56a0d544
|
| 30-Nov-2023 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: style fixes
Check style(9) with checkstyle9.pl and clang-format. No functional change intended.
MFC after: 1 week
|
| #
6abee52e
|
| 30-Nov-2023 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Silence scan-build warning
The value stored to 'value' is never read.
Reported by: Jenkins (scan-build) MFC after: 1 week
|
| #
559a218c
|
| 01-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
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. Kee
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
show more ...
|
| #
1d386b48
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
| #
4d846d26
|
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
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
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
show more ...
|
| #
f5924ad8
|
| 08-Nov-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon(3): Match the return type
Reviewed by: kib MFC after: 1 week
|
| #
f0a15aaf
|
| 28-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Remove XXX marks
phantom@'s HDD crashed with the final version of strfmon.c, as explained in 9d430a5991d3f64a75fee951a1efab3593207832.
Now there are tests in place that cover these code pa
strfmon: Remove XXX marks
phantom@'s HDD crashed with the final version of strfmon.c, as explained in 9d430a5991d3f64a75fee951a1efab3593207832.
Now there are tests in place that cover these code paths.
Reviewed by: kib PR: 267410 Github PR: #620 MFC after: 1 week
show more ...
|
| #
621bf918
|
| 28-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon_l: Use specified locale for number formatting
strfmon_l does not take fully into consideration the explicitly passed locale to perform the formatting.
Parallel universe bug report: https://
strfmon_l: Use specified locale for number formatting
strfmon_l does not take fully into consideration the explicitly passed locale to perform the formatting.
Parallel universe bug report: https://sourceware.org/bugzilla/show_bug.cgi?id=19633
Obtained from: Darwin Reviewed by: kib PR: 267410 Github PR: #620 MFC after: 1 week
show more ...
|
| #
34f88528
|
| 21-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Fix formatting of a second fixed-width value
There is a bug when formatting two consecutive values using fixed-widths and the values need padding. This was because the value of pad_size wa
strfmon: Fix formatting of a second fixed-width value
There is a bug when formatting two consecutive values using fixed-widths and the values need padding. This was because the value of pad_size was zeroed only every other time.
Format Before After [%8n] [%8n] [ $123.45] [ $123.45] [ $123.45] [ $123.45]
Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
show more ...
|
| #
750fe3e6
|
| 18-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Fix an edge case when sep_by_space is 2
Fix an edge case by printing the required space when, the currency symbol succeeds the value, a space separates the sign from the value and the sign
strfmon: Fix an edge case when sep_by_space is 2
Fix an edge case by printing the required space when, the currency symbol succeeds the value, a space separates the sign from the value and the sign position precedes the quantity and the currency symbol.
In other words:
n_cs_precedes = 0 n_sep_by_space = 2 n_sign_posn = 1
From The Open Group's localeconv[1]:
> When {p,n,int_p,int_n}_sep_by_space is 2: > If the currency symbol and sign string are adjacent, a space separates > them; otherwise, a space separates the sign string from the value.
Format Before After [%n] [-123.45¤] [- 123.45¤]
[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html
Obtained from: Darwin Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
show more ...
|
| #
947efadc
|
| 14-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Fix alignment when enclosed by parentheses
Take into consideration the possibility of quantities enclosed by parentheses when aligning.
Matches the examples from The Open Group's:
Format
strfmon: Fix alignment when enclosed by parentheses
Take into consideration the possibility of quantities enclosed by parentheses when aligning.
Matches the examples from The Open Group's:
Format Before After %(#5n [$ 123.45] [ $ 123.45 ] Use an alternative pos/neg style [($ 123.45)] [($ 123.45)] [$ 3,456.78] [ $ 3,456.78 ]
%!(#5n [ 123.45] [ 123.45 ] Disable the currency symbol [( 123.45)] [( 123.45)] [ 3,456.78] [ 3,456.78 ]
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html
SD5-XSH-ERN-29 is applied, updating the examples for %(#5n and %!(#5n.
Obtained from: Darwin Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
show more ...
|
| #
6da51e19
|
| 21-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Trim the SPACE from international currency symbol
The international currency symbol (int_curr_symbol) has a mandatory SPACE character as the last character.
Trim this space after reading i
strfmon: Trim the SPACE from international currency symbol
The international currency symbol (int_curr_symbol) has a mandatory SPACE character as the last character.
Trim this space after reading it, otherwise this extra space will always be printed when displaying the int_curr_symbol.
Fixes the output when the international currency format is selected (%i).
Locale Format Before After en_US.UTF-8 [%i] [USD 123.45] [USD123.45] fr_FR.UTF-8 [%i] [123,45 EUR ] [123,45 EUR]
Note that the en_US.UTF-8 locale states that no space should be printed between the currency symbol and the value (sep_by_space = 0).
Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
show more ...
|
| #
9e03b903
|
| 13-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Avoid an out-of-bounds access
Avoid an out-of-bounds access when trying to set the space_char using an international currency format (%i) and the C/POSIX locale.
The current code tries to
strfmon: Avoid an out-of-bounds access
Avoid an out-of-bounds access when trying to set the space_char using an international currency format (%i) and the C/POSIX locale.
The current code tries to read the SPACE from int_curr_symbol[3]:
currency_symbol = strdup(lc->int_curr_symbol); space_char = *(currency_symbol+3);
But on C/POSIX locales, int_curr_symbol is empty.
Three implementations have been examined: NetBSD[1], Darwin[2], and Illumos[3]. Only NetBSD has fixed it[4].
Darwin and NetBSD also trim the mandatory final SPACE character after reading it.
Locale Format Darwin/NetBSD FreeBSD/Illumos en_US.UTF-8 [%i] [USD123.45] [USD 123.45] fr_FR.UTF-8 [%i] [123,45 EUR] [123,45 EUR ]
This commit only fixes the out-of-bounds access.
[1]: https://github.com/NetBSD/src/blob/trunk/lib/libc/stdlib/strfmon.c [2]: https://opensource.apple.com/source/Libc/Libc-1439.141.1/stdlib/NetBSD/strfmon.c.auto.html [3]: https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/locale/strfmon.c [4]: https://github.com/NetBSD/src/commit/3d7b5d498aa9609f2bc9ece9c734c5f493a8e239
Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
show more ...
|
| #
0afd11d5
|
| 13-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Fix typos in source code comments
s/defult/default s/internaltion/international
Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
|
| #
d5980dff
|
| 13-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Fix typo in constant
s/SUPRESS_CURR_SYMBOL/SUPPRESS_CURR_SYMBOL
Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
|
| #
f81dfea2
|
| 14-Oct-2022 |
Jose Luis Duran <jlduran@gmail.com> |
strfmon: Code cleanup
No functional change intended. Not claiming full style(9) compliance.
Reviewed by: kib PR: 267282 Github PR: #619 MFC after: 1 week
|
| #
5b5fa75a
|
| 04-Aug-2022 |
Ed Maste <emaste@FreeBSD.org> |
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 mul
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
show more ...
|
| #
1a4531bc
|
| 02-Sep-2020 |
John Baldwin <jhb@FreeBSD.org> |
Compute the correct size of the string to move forward.
Previously this was counting the amount of spare room at the start of the buffer that the string needed to move forward and passing that as th
Compute the correct size of the string to move forward.
Previously this was counting the amount of spare room at the start of the buffer that the string needed to move forward and passing that as the number of bytes to copy to memmove rather than the length of the string to be copied.
In the strfmon test in the test suite this caused the memmove to overflow the allocated buffer by one byte which CHERI caught.
Reported by: CHERI Reviewed by: kevans Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26280
show more ...
|
| #
8c1c50ff
|
| 19-Dec-2018 |
Conrad Meyer <cem@FreeBSD.org> |
Allow multi-byte thousands separators in strfmon(3)
PR: 234010 Reported by: Jon Tejnung <jon AT herrskogen.se> Reviewed by: yuripv Differential Revision: https://reviews.freebsd.org/D18605
|
| #
cf85e703
|
| 26-Nov-2025 |
Jose Luis Duran <jlduran@FreeBSD.org> |
strfmon: Fix negative sign handling for C locale
If the locale's positive_sign and negative_sign values would both be returned by localeconv() as empty strings, strfmon() shall behave as if the nega
strfmon: Fix negative sign handling for C locale
If the locale's positive_sign and negative_sign values would both be returned by localeconv() as empty strings, strfmon() shall behave as if the negative_sign value was the string "-".
This occurs with the C locale. The implementation previously assigned "0" to sign_posn (parentheses around the entire string); now it assigns it to "1" (sign before the string) when it is undefined (CHAR_MAX).
Austin Group Defect 1199[1] is applied, changing the requirements for the '+' and '(' flags.
[1]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53913
show more ...
|
| #
1fd01897
|
| 26-Nov-2025 |
Jose Luis Duran <jlduran@FreeBSD.org> |
strfmon: EINVAL if the '+' flag and both signs are empty
According to the Open Group Base Specifications Issue 8[1], strfmon(3) should return EINVAL when the '+' flag was included in a conversion sp
strfmon: EINVAL if the '+' flag and both signs are empty
According to the Open Group Base Specifications Issue 8[1], strfmon(3) should return EINVAL when the '+' flag was included in a conversion specification and the locale's positive_sign and negative_sign values would both be returned by localeconv(3) as empty strings.
Austin Group Defect 1199[2] is applied, adding the [EINVAL] error.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html [2]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53912
show more ...
|