CVS commit: [netbsd-10] src/lib/libc/locale
Module Name:src Committed By: martin Date: Tue May 2 17:23:33 UTC 2023 Modified Files: src/lib/libc/locale [netbsd-10]: newlocale.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #152): lib/libc/locale/newlocale.c: revision 1.4 Fix parsing a locale string with multiple components. Also check for truncation of a long locale string. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.38.1 src/lib/libc/locale/newlocale.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/locale/newlocale.c diff -u src/lib/libc/locale/newlocale.c:1.3 src/lib/libc/locale/newlocale.c:1.3.38.1 --- src/lib/libc/locale/newlocale.c:1.3 Fri Sep 13 13:13:32 2013 +++ src/lib/libc/locale/newlocale.c Tue May 2 17:23:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $ */ +/* $NetBSD: newlocale.c,v 1.3.38.1 2023/05/02 17:23:32 martin Exp $ */ /*- * Copyright (c)2008, 2011 Citrus Project, @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $"); +__RCSID("$NetBSD: newlocale.c,v 1.3.38.1 2023/05/02 17:23:32 martin Exp $"); #include "namespace.h" #include @@ -57,7 +57,10 @@ newlocale(int mask, const char *name, lo if (src == NULL) src = _current_locale(); memcpy(dst, src, sizeof(*src)); - strlcpy([0], name, sizeof(head)); + if (strlcpy([0], name, sizeof(head)) >= sizeof(head)) { + free(dst); + return (locale_t)NULL; + } tokens[0] = (const char *)[0]; tail = strchr(tokens[0], '/'); if (tail == NULL) { @@ -77,6 +80,7 @@ newlocale(int mask, const char *name, lo } if (howmany-- > 0) { for (i = 1; i < howmany; ++i) { +*tail++ = '\0'; tokens[i] = (const char *)tail; tail = strchr(tokens[i], '/'); if (tail == NULL) { @@ -84,6 +88,7 @@ newlocale(int mask, const char *name, lo return NULL; } } + *tail++ = '\0'; tokens[howmany] = tail; tail = strchr(tokens[howmany], '/'); if (tail != NULL) {
CVS commit: [netbsd-10] src/lib/libc/locale
Module Name:src Committed By: martin Date: Tue May 2 17:23:33 UTC 2023 Modified Files: src/lib/libc/locale [netbsd-10]: newlocale.c Log Message: Pull up following revision(s) (requested by mlelstv in ticket #152): lib/libc/locale/newlocale.c: revision 1.4 Fix parsing a locale string with multiple components. Also check for truncation of a long locale string. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.38.1 src/lib/libc/locale/newlocale.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-10] src/lib/libc/locale
Module Name:src Committed By: martin Date: Tue Jan 3 18:24:53 UTC 2023 Modified Files: src/lib/libc/locale [netbsd-10]: setlocale.3 Log Message: Pull up following revision(s) (requested by nia in ticket #33): lib/libc/locale/setlocale.3: revision 1.23 setlocale.3: Reflect state of NetBSD locale support in the 21st century Don't use LC_COLLATE in a real code example, since a real call to set LC_COLLATE will fail. Mention this. Inconsistencies noticed by khw on IRC. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.22.2.1 src/lib/libc/locale/setlocale.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/locale/setlocale.3 diff -u src/lib/libc/locale/setlocale.3:1.22 src/lib/libc/locale/setlocale.3:1.22.2.1 --- src/lib/libc/locale/setlocale.3:1.22 Sun Oct 24 17:30:19 2021 +++ src/lib/libc/locale/setlocale.3 Tue Jan 3 18:24:53 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: setlocale.3,v 1.22 2021/10/24 17:30:19 gutteridge Exp $ +.\" $NetBSD: setlocale.3,v 1.22.2.1 2023/01/03 18:24:53 martin Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 .\" -.Dd October 24, 2021 +.Dd December 31, 2022 .Dt SETLOCALE 3 .Os .Sh NAME @@ -314,6 +314,14 @@ which may be altered by later calls to .Fn setlocale or .Fn localeconv . +.Pp +Currently, +.Fn setlocale +returns +.Dv NULL +and fails to change the locale when +.Dv LC_COLLATE +is modified independently of other values. .Sh EXAMPLES The following code illustrates how a program can initialize the international environment for one language, while selectively @@ -322,7 +330,7 @@ string operations can be applied to text language: .Bd -literal setlocale(LC_ALL, "de"); - setlocale(LC_COLLATE, "fr"); + setlocale(LC_NUMERIC, "C"); .Ed .Pp When a process is started, its current locale is set to the C or POSIX @@ -379,21 +387,13 @@ and functions first appeared in .Bx 4.4 . .Sh BUGS -The current implementation supports only the -.Li "\&""C"" -and -.Li "\&""POSIX"" -locales for all but the -.Dv LC_CTYPE -locale. -.Pp In spite of the gnarly currency support in .Fn localeconv , the standards don't include any functions for generalized currency formatting. .Pp .Dv LC_COLLATE -does not make sense for many languages. +is unimplemented (but does not make sense for many languages). Use of .Dv LC_MONETARY could lead to misleading results until we have a real time currency
CVS commit: [netbsd-10] src/lib/libc/locale
Module Name:src Committed By: martin Date: Tue Jan 3 18:24:53 UTC 2023 Modified Files: src/lib/libc/locale [netbsd-10]: setlocale.3 Log Message: Pull up following revision(s) (requested by nia in ticket #33): lib/libc/locale/setlocale.3: revision 1.23 setlocale.3: Reflect state of NetBSD locale support in the 21st century Don't use LC_COLLATE in a real code example, since a real call to set LC_COLLATE will fail. Mention this. Inconsistencies noticed by khw on IRC. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.22.2.1 src/lib/libc/locale/setlocale.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.