History log of /openbsd-current/lib/libc/locale/setlocale.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.30 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.29 29-Mar-2018 schwarze

Resolve some code duplication.
Minus eight lines of code, no functional change.
OK martijn@.


# 1.28 29-Mar-2018 schwarze

Fix three bugs in setlocale(3):
1. setlocale(LC_ALL, "A"); setlocale(LC_CTYPE, "T"); setlocale(LC_ALL, NULL);
must return "A/T/A/A/A/A", not "A". Fix this by always initializing the
LC_ALL entry of newgl to "" in dupgl(). Reported by Karl Williamson
<public at khwilliamson dot com> on bugs@, thanks!
2. Do not leak newgl when strdup(3) fails in setlocale(3).
3. For setlocale(LC_ALL, "C/C/fr_FR.UTF-8/C/C/C"); correctly set
_GlobalRuneLocale; i found 2. and 3. while looking at the code.
Feedback on a buggy earlier version and OK martijn@.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.27 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.26 05-Aug-2017 schwarze

We only support ASCII and UTF-8, so we never need to
change _ctype_, _tolower_tab_, and _toupper_tab_.
No functional change.
Suggested by and OK kettenis@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.25 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.24 14-Sep-2015 guenther

Wrap <locale.h> so internal calls go direct


# 1.23 14-Aug-2015 stsp

Load LC_MESSAGES locale only if the character encoding is UTF-8.
ok mpi tedu phessler zhuk, and discussed with many at c2k15


Revision tags: OPENBSD_5_8_BASE
# 1.22 02-Jul-2015 semarie

remove new_categories variable from global.

This variable is used as temporary buffer in order to do checking
before copying the content to current_categories variable.

Switch it as local variable in setlocale function. Adapts some functions.

the commit collapse 3 proposed diffs on tech@, and all OK stsp@


# 1.21 09-Jun-2015 stsp

Remove unused parameter of load_locale_sub(). No assembly change on i386.
Diff from Sebastien Marie. objdump foo help from uwe


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.20 28-Aug-2013 stsp

Allow setlocale(LC_MESSAGES, ...); to succeed. This always returned an
error, but that makes some ports (e.g. GNOME) freak out. We can allow
any message language to be used as long as the encoding specified as
part of the locale name is supported (i.e. listed in locale -m output).
The primary users of LC_MESSAGES are catopen(3) and gettext(3), which
already worked without this change.
ok ajacoutot, naddy, matthew


Revision tags: OPENBSD_5_4_BASE
# 1.19 01-Jun-2013 stsp

Change the naming scheme used for directories in /usr/share/locale to
eliminate redundant copies of LC_CTYPE files.

Instead of names using "language_territory.codeset" permutations, use just
the codeset component to name directories storing LC_CTYPE files. Suggested
by bluhm@ while discussing the idea of using symlinks in /usr/share/locale
like FreeBSD does.

Future locale features which store language and/or territory specific data
can name directories after language or territory names.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.18 15-Mar-2011 stsp

Remove evaluation of PATH_LOCALE environment variable because it can be
abused to cause an integer overflow and serves no real purpose.
Found by Alexander Schrijver.
ok millert deraadt


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.17 28-Nov-2007 chl

remove unused function

ok otto@


# 1.16 17-Sep-2007 moritz

Check snprintf(3) return value for error or truncation.
Mostly path construction, where truncation could be bad.

ok and input from deraadt@ millert@ ray@


# 1.15 06-Sep-2007 moritz

_xpg4_setrunelocale() returns an errno(2) value in the failure
case and 0 if the locale was found. So checking against -1 makes
no sense.

ok millert@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.14 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.13 08-Aug-2005 espie

activate LC_CTYPE for 8 bits locale.
Make sure tolower/toupper use the whole 8 bits.

okay deraadt@
thanks to everyone who tested


# 1.12 23-Mar-2005 otto

ansify. ok deraadt@ millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.11 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 17-Sep-2002 itojun

typo


# 1.9 17-Sep-2002 itojun

correct possible buffer overrun in setlocale(x, y) where y is supplied from
outside. see NetBSD SA2002-012.


Revision tags: OPENBSD_3_1_BASE
# 1.8 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.6 09-Jul-1997 millert

Clean up some -Wall flowers.


Revision tags: OPENBSD_2_1_BASE
# 1.5 29-Oct-1996 millert

POSIX compliance.


Revision tags: OPENBSD_2_0_BASE
# 1.4 15-Sep-1996 tholo

Remove dead code
Remove unused variables
Silence some warnings
lint(1) is your friend


# 1.3 26-Aug-1996 deraadt

use issetugid() to protect against bad getenv


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.29 29-Mar-2018 schwarze

Resolve some code duplication.
Minus eight lines of code, no functional change.
OK martijn@.


# 1.28 29-Mar-2018 schwarze

Fix three bugs in setlocale(3):
1. setlocale(LC_ALL, "A"); setlocale(LC_CTYPE, "T"); setlocale(LC_ALL, NULL);
must return "A/T/A/A/A/A", not "A". Fix this by always initializing the
LC_ALL entry of newgl to "" in dupgl(). Reported by Karl Williamson
<public at khwilliamson dot com> on bugs@, thanks!
2. Do not leak newgl when strdup(3) fails in setlocale(3).
3. For setlocale(LC_ALL, "C/C/fr_FR.UTF-8/C/C/C"); correctly set
_GlobalRuneLocale; i found 2. and 3. while looking at the code.
Feedback on a buggy earlier version and OK martijn@.


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.27 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.26 05-Aug-2017 schwarze

We only support ASCII and UTF-8, so we never need to
change _ctype_, _tolower_tab_, and _toupper_tab_.
No functional change.
Suggested by and OK kettenis@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.25 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.24 14-Sep-2015 guenther

Wrap <locale.h> so internal calls go direct


# 1.23 14-Aug-2015 stsp

Load LC_MESSAGES locale only if the character encoding is UTF-8.
ok mpi tedu phessler zhuk, and discussed with many at c2k15


Revision tags: OPENBSD_5_8_BASE
# 1.22 02-Jul-2015 semarie

remove new_categories variable from global.

This variable is used as temporary buffer in order to do checking
before copying the content to current_categories variable.

Switch it as local variable in setlocale function. Adapts some functions.

the commit collapse 3 proposed diffs on tech@, and all OK stsp@


# 1.21 09-Jun-2015 stsp

Remove unused parameter of load_locale_sub(). No assembly change on i386.
Diff from Sebastien Marie. objdump foo help from uwe


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.20 28-Aug-2013 stsp

Allow setlocale(LC_MESSAGES, ...); to succeed. This always returned an
error, but that makes some ports (e.g. GNOME) freak out. We can allow
any message language to be used as long as the encoding specified as
part of the locale name is supported (i.e. listed in locale -m output).
The primary users of LC_MESSAGES are catopen(3) and gettext(3), which
already worked without this change.
ok ajacoutot, naddy, matthew


Revision tags: OPENBSD_5_4_BASE
# 1.19 01-Jun-2013 stsp

Change the naming scheme used for directories in /usr/share/locale to
eliminate redundant copies of LC_CTYPE files.

Instead of names using "language_territory.codeset" permutations, use just
the codeset component to name directories storing LC_CTYPE files. Suggested
by bluhm@ while discussing the idea of using symlinks in /usr/share/locale
like FreeBSD does.

Future locale features which store language and/or territory specific data
can name directories after language or territory names.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.18 15-Mar-2011 stsp

Remove evaluation of PATH_LOCALE environment variable because it can be
abused to cause an integer overflow and serves no real purpose.
Found by Alexander Schrijver.
ok millert deraadt


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.17 28-Nov-2007 chl

remove unused function

ok otto@


# 1.16 17-Sep-2007 moritz

Check snprintf(3) return value for error or truncation.
Mostly path construction, where truncation could be bad.

ok and input from deraadt@ millert@ ray@


# 1.15 06-Sep-2007 moritz

_xpg4_setrunelocale() returns an errno(2) value in the failure
case and 0 if the locale was found. So checking against -1 makes
no sense.

ok millert@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.14 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.13 08-Aug-2005 espie

activate LC_CTYPE for 8 bits locale.
Make sure tolower/toupper use the whole 8 bits.

okay deraadt@
thanks to everyone who tested


# 1.12 23-Mar-2005 otto

ansify. ok deraadt@ millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.11 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 17-Sep-2002 itojun

typo


# 1.9 17-Sep-2002 itojun

correct possible buffer overrun in setlocale(x, y) where y is supplied from
outside. see NetBSD SA2002-012.


Revision tags: OPENBSD_3_1_BASE
# 1.8 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.6 09-Jul-1997 millert

Clean up some -Wall flowers.


Revision tags: OPENBSD_2_1_BASE
# 1.5 29-Oct-1996 millert

POSIX compliance.


Revision tags: OPENBSD_2_0_BASE
# 1.4 15-Sep-1996 tholo

Remove dead code
Remove unused variables
Silence some warnings
lint(1) is your friend


# 1.3 26-Aug-1996 deraadt

use issetugid() to protect against bad getenv


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_2_BASE
# 1.27 05-Sep-2017 schwarze

New POSIX xlocale implementation written from scratch.
Complete in the sense that all POSIX *locale(3) and *_l(3) functions
are included, but in OpenBSD, we of course only really care about
LC_CTYPE and we only support ASCII and UTF-8.

With important help from kettenis@, guenther@, and jca@.
Repeated testing in ports bulk builds by naddy@.
Additional testing by jca@, sebastia@, dcoppa@, and others.
OK kettenis@ dcoppa@, and guenther@ on an earlier version.
Riding guenther@'s libc/librthread major bump.


# 1.26 05-Aug-2017 schwarze

We only support ASCII and UTF-8, so we never need to
change _ctype_, _tolower_tab_, and _toupper_tab_.
No functional change.
Suggested by and OK kettenis@


Revision tags: OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.25 23-May-2016 guenther

Stop exposing <sys/localedef.h> and various symbols internal to the libc
locale implementation: _{Current,Default}*Locale, __[mn]locale_changed,
__mb_len_max_runtime

ok millert@ schwarze@ deraadt@


Revision tags: OPENBSD_5_9_BASE
# 1.24 14-Sep-2015 guenther

Wrap <locale.h> so internal calls go direct


# 1.23 14-Aug-2015 stsp

Load LC_MESSAGES locale only if the character encoding is UTF-8.
ok mpi tedu phessler zhuk, and discussed with many at c2k15


Revision tags: OPENBSD_5_8_BASE
# 1.22 02-Jul-2015 semarie

remove new_categories variable from global.

This variable is used as temporary buffer in order to do checking
before copying the content to current_categories variable.

Switch it as local variable in setlocale function. Adapts some functions.

the commit collapse 3 proposed diffs on tech@, and all OK stsp@


# 1.21 09-Jun-2015 stsp

Remove unused parameter of load_locale_sub(). No assembly change on i386.
Diff from Sebastien Marie. objdump foo help from uwe


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.20 28-Aug-2013 stsp

Allow setlocale(LC_MESSAGES, ...); to succeed. This always returned an
error, but that makes some ports (e.g. GNOME) freak out. We can allow
any message language to be used as long as the encoding specified as
part of the locale name is supported (i.e. listed in locale -m output).
The primary users of LC_MESSAGES are catopen(3) and gettext(3), which
already worked without this change.
ok ajacoutot, naddy, matthew


Revision tags: OPENBSD_5_4_BASE
# 1.19 01-Jun-2013 stsp

Change the naming scheme used for directories in /usr/share/locale to
eliminate redundant copies of LC_CTYPE files.

Instead of names using "language_territory.codeset" permutations, use just
the codeset component to name directories storing LC_CTYPE files. Suggested
by bluhm@ while discussing the idea of using symlinks in /usr/share/locale
like FreeBSD does.

Future locale features which store language and/or territory specific data
can name directories after language or territory names.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.18 15-Mar-2011 stsp

Remove evaluation of PATH_LOCALE environment variable because it can be
abused to cause an integer overflow and serves no real purpose.
Found by Alexander Schrijver.
ok millert deraadt


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.17 28-Nov-2007 chl

remove unused function

ok otto@


# 1.16 17-Sep-2007 moritz

Check snprintf(3) return value for error or truncation.
Mostly path construction, where truncation could be bad.

ok and input from deraadt@ millert@ ray@


# 1.15 06-Sep-2007 moritz

_xpg4_setrunelocale() returns an errno(2) value in the failure
case and 0 if the locale was found. So checking against -1 makes
no sense.

ok millert@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.14 08-Aug-2005 espie

zap remaining rcsid.

Kill old files that are no longer compiled.

okay theo


# 1.13 08-Aug-2005 espie

activate LC_CTYPE for 8 bits locale.
Make sure tolower/toupper use the whole 8 bits.

okay deraadt@
thanks to everyone who tested


# 1.12 23-Mar-2005 otto

ansify. ok deraadt@ millert@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE
# 1.11 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE
# 1.10 17-Sep-2002 itojun

typo


# 1.9 17-Sep-2002 itojun

correct possible buffer overrun in setlocale(x, y) where y is supplied from
outside. see NetBSD SA2002-012.


Revision tags: OPENBSD_3_1_BASE
# 1.8 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


Revision tags: OPENBSD_3_0_BASE
# 1.7 27-Jun-2001 lebel

use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE OPENBSD_2_4_BASE OPENBSD_2_5_BASE OPENBSD_2_6_BASE OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.6 09-Jul-1997 millert

Clean up some -Wall flowers.


Revision tags: OPENBSD_2_1_BASE
# 1.5 29-Oct-1996 millert

POSIX compliance.


Revision tags: OPENBSD_2_0_BASE
# 1.4 15-Sep-1996 tholo

Remove dead code
Remove unused variables
Silence some warnings
lint(1) is your friend


# 1.3 26-Aug-1996 deraadt

use issetugid() to protect against bad getenv


# 1.2 19-Aug-1996 tholo

Fix RCS ids
Make sure everything uses {SYS,}LIBC_SCCS properly


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision