CVS commit: src/lib/libc/locale

2024-06-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jun  7 13:53:02 UTC 2024

Modified Files:
src/lib/libc/locale: global_locale.c

Log Message:
libc/locale/global_locale.c: Nix confusing NBCHAR_MAX.

NBCHAR_MAX is used only in the usr.bin/mklocale build, but that
doesn't use global_locale.c.  This was added when inserting char
casts, but using the mklocale's hook just to insert a char cast is
unnecessarily confusing -- and the char casts are unnecessary anyway.

No functional change intended.  No binary change to aarch64 libc.

Raised in PR lib/58319.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libc/locale/global_locale.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/global_locale.c
diff -u src/lib/libc/locale/global_locale.c:1.25 src/lib/libc/locale/global_locale.c:1.26
--- src/lib/libc/locale/global_locale.c:1.25	Fri Apr 29 16:26:48 2016
+++ src/lib/libc/locale/global_locale.c	Fri Jun  7 13:53:02 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.25 2016/04/29 16:26:48 joerg Exp $ */
+/* $NetBSD: global_locale.c,v 1.26 2024/06/07 13:53:02 riastradh Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.25 2016/04/29 16:26:48 joerg Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.26 2024/06/07 13:53:02 riastradh Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -43,10 +43,6 @@ __RCSID("$NetBSD: global_locale.c,v 1.25
 #include "runetype_local.h"
 #include "setlocale_local.h"
 
-#ifndef NBCHAR_MAX
-#define NBCHAR_MAX (char)CHAR_MAX
-#endif
-
 static const _MessagesLocale _DefaultMessagesLocale = {
 	"^[Yy]",
 	"^[Nn]",
@@ -124,20 +120,20 @@ __dso_hidden const struct _locale_cache_
 	.mon_grouping		= __UNCONST(""),
 	.positive_sign		= __UNCONST(""),
 	.negative_sign		= __UNCONST(""),
-	.int_frac_digits	= NBCHAR_MAX,
-	.frac_digits		= NBCHAR_MAX,
-	.p_cs_precedes		= NBCHAR_MAX,
-	.p_sep_by_space		= NBCHAR_MAX,
-	.n_cs_precedes		= NBCHAR_MAX,
-	.n_sep_by_space		= NBCHAR_MAX,
-	.p_sign_posn		= NBCHAR_MAX,
-	.n_sign_posn		= NBCHAR_MAX,
-	.int_p_cs_precedes	= NBCHAR_MAX,
-	.int_n_cs_precedes	= NBCHAR_MAX,
-	.int_p_sep_by_space	= NBCHAR_MAX,
-	.int_n_sep_by_space	= NBCHAR_MAX,
-	.int_p_sign_posn	= NBCHAR_MAX,
-	.int_n_sign_posn	= NBCHAR_MAX,
+	.int_frac_digits	= CHAR_MAX,
+	.frac_digits		= CHAR_MAX,
+	.p_cs_precedes		= CHAR_MAX,
+	.p_sep_by_space		= CHAR_MAX,
+	.n_cs_precedes		= CHAR_MAX,
+	.n_sep_by_space		= CHAR_MAX,
+	.p_sign_posn		= CHAR_MAX,
+	.n_sign_posn		= CHAR_MAX,
+	.int_p_cs_precedes	= CHAR_MAX,
+	.int_n_cs_precedes	= CHAR_MAX,
+	.int_p_sep_by_space	= CHAR_MAX,
+	.int_n_sep_by_space	= CHAR_MAX,
+	.int_p_sign_posn	= CHAR_MAX,
+	.int_n_sign_posn	= CHAR_MAX,
 },
 .monetary_name = _lc_C_locale_name,
 .numeric_name = _lc_C_locale_name,



CVS commit: src/lib/libc/locale

2024-06-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jun  7 13:53:02 UTC 2024

Modified Files:
src/lib/libc/locale: global_locale.c

Log Message:
libc/locale/global_locale.c: Nix confusing NBCHAR_MAX.

NBCHAR_MAX is used only in the usr.bin/mklocale build, but that
doesn't use global_locale.c.  This was added when inserting char
casts, but using the mklocale's hook just to insert a char cast is
unnecessarily confusing -- and the char casts are unnecessary anyway.

No functional change intended.  No binary change to aarch64 libc.

Raised in PR lib/58319.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libc/locale/global_locale.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2024-02-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb  3 10:55:38 UTC 2024

Modified Files:
src/lib/libc/locale: mblen.3

Log Message:
mblen.3: clean up wording and grammar


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/locale/mblen.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/mblen.3
diff -u src/lib/libc/locale/mblen.3:1.6 src/lib/libc/locale/mblen.3:1.7
--- src/lib/libc/locale/mblen.3:1.6	Sat Oct 14 07:51:01 2006
+++ src/lib/libc/locale/mblen.3	Sat Feb  3 10:55:38 2024
@@ -1,4 +1,4 @@
-.\" $NetBSD: mblen.3,v 1.6 2006/10/14 07:51:01 wiz Exp $
+.\" $NetBSD: mblen.3,v 1.7 2024/02/03 10:55:38 rillig Exp $
 .\"
 .\" Copyright (c)2002 Citrus Project,
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd February 3, 2002
+.Dd February 3, 2024
 .Dt MBLEN 3
 .Os
 .\" --
@@ -47,18 +47,20 @@ function usually determines the number o
 a multibyte character pointed to by
 .Fa s
 and returns it.
-This function shall only examine max n bytes of the array beginning from
+This function examines at most
+.Fa n
+bytes of the array beginning from
 .Fa s .
 .Pp
 In state-dependent encodings,
 .Fa s
-may point the special sequence bytes to change the shift-state.
+may point to the special sequence bytes to change the shift-state.
 Although such sequence bytes corresponds to no individual
 wide-character code,
 the
 .Fn mblen
-changes the own state by them and treats them
-as if they are a part of the subsequent multibyte character.
+function changes its own state by them and treats them
+as if they were part of the subsequent multibyte character.
 .Pp
 Unlike
 .Xr mbrlen 3 ,
@@ -106,8 +108,7 @@ determines whether the current encoding 
 This function returns 0 if the encoding is state-independent,
 otherwise non-zero.
 .It "n == 0"
-In this case,
-the first
+The first
 .Fa n
 bytes of the array pointed to by
 .Fa s
@@ -128,11 +129,11 @@ points to a nul byte
 .Pq Sq \e0 .
 .It "positive"
 The value returned is
-a number of bytes for the valid multibyte character pointed to by
+the number of bytes for the valid multibyte character pointed to by
 .Fa s .
-There are no cases that this value is greater than
-.Fa n
-or the value of the
+The value returned is at most
+.Fa n ,
+and at most the value of the
 .Dv MB_CUR_MAX
 macro.
 .It "-1"
@@ -140,7 +141,7 @@ macro.
 points to an invalid or incomplete multibyte character.
 The
 .Fn mblen
-also sets
+function also sets
 .Va errno
 to indicate the error.
 .El
@@ -151,7 +152,7 @@ is equal to
 .Dv NULL ,
 the
 .Fn mblen
-returns:
+function returns:
 .Bl -tag -width 0123456789
 .It "0"
 The current encoding is state-independent.



CVS commit: src/lib/libc/locale

2024-02-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb  3 10:55:38 UTC 2024

Modified Files:
src/lib/libc/locale: mblen.3

Log Message:
mblen.3: clean up wording and grammar


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/locale/mblen.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2023-04-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 16 20:37:59 UTC 2023

Modified Files:
src/lib/libc/locale: newlocale.c

Log Message:
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.4 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.4
--- src/lib/libc/locale/newlocale.c:1.3	Fri Sep 13 13:13:32 2013
+++ src/lib/libc/locale/newlocale.c	Sun Apr 16 20:37:59 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $ */
+/* $NetBSD: newlocale.c,v 1.4 2023/04/16 20:37:59 mlelstv 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.4 2023/04/16 20:37:59 mlelstv 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: src/lib/libc/locale

2023-04-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 16 20:37:59 UTC 2023

Modified Files:
src/lib/libc/locale: newlocale.c

Log Message:
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.4 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: src/lib/libc/locale

2022-12-31 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Dec 31 14:35:56 UTC 2022

Modified Files:
src/lib/libc/locale: setlocale.3

Log Message:
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.23 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.23
--- src/lib/libc/locale/setlocale.3:1.22	Sun Oct 24 17:30:19 2021
+++ src/lib/libc/locale/setlocale.3	Sat Dec 31 14:35:56 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: setlocale.3,v 1.22 2021/10/24 17:30:19 gutteridge Exp $
+.\"	$NetBSD: setlocale.3,v 1.23 2022/12/31 14:35:56 nia 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: src/lib/libc/locale

2022-12-31 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Dec 31 14:35:56 UTC 2022

Modified Files:
src/lib/libc/locale: setlocale.3

Log Message:
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.23 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.



CVS commit: src/lib/libc/locale

2021-10-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 24 17:30:19 UTC 2021

Modified Files:
src/lib/libc/locale: setlocale.3

Log Message:
setlocale.3: minor updates to reflect the current implementation

Reflect a couple of amendments noted by John Marino on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2021/10/19/msg013091.html


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.21 src/lib/libc/locale/setlocale.3:1.22
--- src/lib/libc/locale/setlocale.3:1.21	Sat Jan 24 16:58:54 2004
+++ src/lib/libc/locale/setlocale.3	Sun Oct 24 17:30:19 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: setlocale.3,v 1.21 2004/01/24 16:58:54 wiz Exp $
+.\"	$NetBSD: setlocale.3,v 1.22 2021/10/24 17:30:19 gutteridge 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 May 30, 2003
+.Dd October 24, 2021
 .Dt SETLOCALE 3
 .Os
 .Sh NAME
@@ -81,9 +81,6 @@ functions.
 This controls recognition of upper and lower case,
 alphabetic or non-alphabetic characters,
 and so on.
-The real work is done by the
-.Fn setrunelocale
-function.
 .It Dv LC_MESSAGES
 Set a locale for message catalogs.
 This controls the selection of message catalogs by the
@@ -336,7 +333,9 @@ following manner before using any of the
 .Bd -literal
 	setlocale(LC_ALL, "");
 .Ed
-.\" .Sh FILES			XXX
+.Sh FILES
+The use of multibyte locales requires shared libraries located in
+.Pa /usr/lib/i18n .
 .\" .Bl -tag -width /usr/share/locale/locale/category -compact	XXX
 .\" .It Pa $PATH_LOCALE/\fIlocale\fP/\fIcategory\fP		XXX
 .\" .It Pa /usr/share/locale/\fIlocale\fP/\fIcategory\fP	XXX



CVS commit: src/lib/libc/locale

2021-10-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 24 17:30:19 UTC 2021

Modified Files:
src/lib/libc/locale: setlocale.3

Log Message:
setlocale.3: minor updates to reflect the current implementation

Reflect a couple of amendments noted by John Marino on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2021/10/19/msg013091.html


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.



Re: CVS commit: src/lib/libc/locale

2021-02-15 Thread Joerg Sonnenberger
On Mon, Feb 15, 2021 at 04:37:15PM +0100, Thomas Klausner wrote:
> Hi!
> 
> Thanks for the man pages.
> 
> There is none for uselocale(3), which is heavily referenced from
> these, nor do I find a prototype in /usr/include...
> so how does one use these? :)

We don't support uselocale. You use this functions by passing the
locale_t to the *_l functions directly.

Joerg


CVS commit: src/lib/libc/locale

2021-02-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Feb 15 15:38:43 UTC 2021

Modified Files:
src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3

Log Message:
Remove reference to multibyte(3) and trailing commas.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/duplocale.3 \
src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.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/duplocale.3
diff -u src/lib/libc/locale/duplocale.3:1.2 src/lib/libc/locale/duplocale.3:1.3
--- src/lib/libc/locale/duplocale.3:1.2	Mon Feb 15 15:36:53 2021
+++ src/lib/libc/locale/duplocale.3	Mon Feb 15 15:38:43 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: duplocale.3,v 1.2 2021/02/15 15:36:53 christos Exp $
+.\" $NetBSD: duplocale.3,v 1.3 2021/02/15 15:38:43 wiz Exp $
 .\" Copyright (c) 2011 The FreeBSD Foundation
 .\" All rights reserved.
 .\"
@@ -51,7 +51,7 @@ The locale returned by this call must be
 .Sh SEE ALSO
 .Xr freelocale 3 ,
 .Xr localeconv 3 ,
-.Xr newlocale 3 ,
+.Xr newlocale 3
 .\" .Xr querylocale 3 ,
 .\" .Xr uselocale 3 ,
 .\" .Xr xlocale 3
Index: src/lib/libc/locale/freelocale.3
diff -u src/lib/libc/locale/freelocale.3:1.2 src/lib/libc/locale/freelocale.3:1.3
--- src/lib/libc/locale/freelocale.3:1.2	Mon Feb 15 15:36:53 2021
+++ src/lib/libc/locale/freelocale.3	Mon Feb 15 15:38:43 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: freelocale.3,v 1.2 2021/02/15 15:36:53 christos Exp $
+.\" $NetBSD: freelocale.3,v 1.3 2021/02/15 15:38:43 wiz Exp $
 .\" Copyright (c) 2011 The FreeBSD Foundation
 .\" All rights reserved.
 .\"
@@ -49,7 +49,7 @@ This relinquishes any resources held exc
 .Sh SEE ALSO
 .Xr duplocale 3 ,
 .Xr localeconv 3 ,
-.Xr newlocale 3 ,
+.Xr newlocale 3
 .\" .Xr querylocale 3 ,
 .\" .Xr uselocale 3 ,
 .\" .Xr xlocale 3
Index: src/lib/libc/locale/newlocale.3
diff -u src/lib/libc/locale/newlocale.3:1.2 src/lib/libc/locale/newlocale.3:1.3
--- src/lib/libc/locale/newlocale.3:1.2	Mon Feb 15 15:36:53 2021
+++ src/lib/libc/locale/newlocale.3	Mon Feb 15 15:38:43 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: newlocale.3,v 1.2 2021/02/15 15:36:53 christos Exp $
+.\" $NetBSD: newlocale.3,v 1.3 2021/02/15 15:38:43 wiz Exp $
 .\" Copyright (c) 2011 The FreeBSD Foundation
 .\" All rights reserved.
 .\"
@@ -78,8 +78,8 @@ and
 .It LC_CTYPE_MASK
 The locale for the
 .Xr ctype 3
-and
-.Xr multibyte 3
+.\" and
+.\" .Xr multibyte 3
 functions.
 This controls recognition of upper and lower case, alphabetic or
 non-alphabetic characters, and so on.
@@ -117,7 +117,7 @@ You must free the returned locale with
 .Sh SEE ALSO
 .Xr duplocale 3 ,
 .Xr freelocale 3 ,
-.Xr localeconv 3 ,
+.Xr localeconv 3
 .\" .Xr querylocale 3 ,
 .\" .Xr uselocale 3 ,
 .\" .Xr xlocale 3



CVS commit: src/lib/libc/locale

2021-02-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Feb 15 15:38:43 UTC 2021

Modified Files:
src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3

Log Message:
Remove reference to multibyte(3) and trailing commas.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/duplocale.3 \
src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libc/locale

2021-02-15 Thread Thomas Klausner
Hi!

Thanks for the man pages.

There is none for uselocale(3), which is heavily referenced from
these, nor do I find a prototype in /usr/include...
so how does one use these? :)
 Thomas

On Mon, Feb 15, 2021 at 09:35:04AM -0500, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Mon Feb 15 14:35:04 UTC 2021
> 
> Modified Files:
>   src/lib/libc/locale: Makefile.inc
> Added Files:
>   src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3
> 
> Log Message:
> Add missing man pages (from FreeBSD)
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.64 -r1.65 src/lib/libc/locale/Makefile.inc
> cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/duplocale.3 \
> src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.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/Makefile.inc
> diff -u src/lib/libc/locale/Makefile.inc:1.64 
> src/lib/libc/locale/Makefile.inc:1.65
> --- src/lib/libc/locale/Makefile.inc:1.64 Sun Aug 18 16:03:48 2013
> +++ src/lib/libc/locale/Makefile.inc  Mon Feb 15 09:35:04 2021
> @@ -1,5 +1,5 @@
>  #from: @(#)Makefile.inc  5.1 (Berkeley) 2/18/91
> -#$NetBSD: Makefile.inc,v 1.64 2013/08/18 20:03:48 joerg Exp $
> +#$NetBSD: Makefile.inc,v 1.65 2021/02/15 14:35:04 christos Exp $
>  
>  # locale sources
>  .PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
> @@ -21,7 +21,7 @@ CPPFLAGS.runetable.c+=  -I${LIBCDIR}/cit
>  CPPFLAGS.multibyte_c90.c+=   -I${LIBCDIR}/citrus
>  CPPFLAGS.multibyte_amd1.c+=  -I${LIBCDIR}/citrus
>  
> -MAN+=setlocale.3 nl_langinfo.3
> +MAN+=duplocale.3 freelocale.3 newlocale.3 setlocale.3 nl_langinfo.3 
>  
>  MAN+=mbtowc.3 mbstowcs.3 wctomb.3 wcstombs.3 mblen.3 \
>  
> 
> Added files:
> 
> Index: src/lib/libc/locale/duplocale.3
> diff -u /dev/null src/lib/libc/locale/duplocale.3:1.1
> --- /dev/null Mon Feb 15 09:35:04 2021
> +++ src/lib/libc/locale/duplocale.3   Mon Feb 15 09:35:04 2021
> @@ -0,0 +1,80 @@
> +.\" $NetBSD: duplocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $
> +.\" Copyright (c) 2011 The FreeBSD Foundation
> +.\" All rights reserved.
> +.\"
> +.\" This documentation was written by David Chisnall under sponsorship from
> +.\" the FreeBSD Foundation.
> +.\"
> +.\" Redistribution and use in source and binary forms, with or without
> +.\" modification, are permitted provided that the following conditions
> +.\" are met:
> +.\" 1. Redistributions of source code must retain the above copyright
> +.\"notice, this list of conditions and the following disclaimer.
> +.\" 2. Redistributions in binary form must reproduce the above copyright
> +.\"notice, this list of conditions and the following disclaimer in the
> +.\"documentation and/or other materials provided with the distribution.
> +.\"
> +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
> +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> +.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
> +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> CONSEQUENTIAL
> +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
> STRICT
> +.\" 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: head/lib/libc/locale/duplocale.3 281925 2015-04-24 10:17:55Z 
> theraven $
> +.\"
> +.Dd September 17, 2011
> +.Dt DUPLOCALE 3
> +.Os
> +.Sh NAME
> +.Nm duplocale
> +.Nd duplicate an locale
> +.Sh LIBRARY
> +.Lb libc
> +.Sh SYNOPSIS
> +.In locale.h
> +.Ft locale_t
> +.Fn duplocale "locale_t locale"
> +.Sh DESCRIPTION
> +Duplicates an existing
> +.Fa locale_t
> +returning a new
> +.Fa locale_t
> +that refers to the same locale values but has an independent internal state.
> +Various functions, such as
> +.Xr mblen 3
> +require a persistent state.
> +These functions formerly used static variables and calls to them from 
> multiple
> +threads had undefined behavior.
> +They now use fields in the
> +.Fa locale_t
> +associated with the current thread by
> +.Xr uselocale 3 .
> +These calls are therefore only thread safe on threads with a unique 
> per-thread
> +locale.
> +The locale returned by this call must be freed with
> +.Xr freelocale 3 .
> +.Sh SEE ALSO
> +.Xr freelocale 3 ,
> +.Xr localeconv 3 ,
> +.Xr newlocale 3 ,
> +.\" .Xr querylocale 3 ,
> +.Xr uselocale 3 ,
> +.\" .Xr xlocale 3
> +.Sh STANDARDS
> +This function conforms to
> +.St -p1003.1-2008 .
> +.Sh BUGS
> +Ideally,
> +.Xr uselocale 3
> +should make a 

CVS commit: src/lib/libc/locale

2021-02-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 15 15:36:53 UTC 2021

Modified Files:
src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3

Log Message:
Remove FreeBSD portions that are not relevant to our implementation (pointed
out by joerg@)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/locale/duplocale.3 \
src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2021-02-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 15 15:36:53 UTC 2021

Modified Files:
src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3

Log Message:
Remove FreeBSD portions that are not relevant to our implementation (pointed
out by joerg@)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/locale/duplocale.3 \
src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.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/duplocale.3
diff -u src/lib/libc/locale/duplocale.3:1.1 src/lib/libc/locale/duplocale.3:1.2
--- src/lib/libc/locale/duplocale.3:1.1	Mon Feb 15 09:35:04 2021
+++ src/lib/libc/locale/duplocale.3	Mon Feb 15 10:36:53 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: duplocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $
+.\" $NetBSD: duplocale.3,v 1.2 2021/02/15 15:36:53 christos Exp $
 .\" Copyright (c) 2011 The FreeBSD Foundation
 .\" All rights reserved.
 .\"
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD: head/lib/libc/locale/duplocale.3 281925 2015-04-24 10:17:55Z theraven $
 .\"
-.Dd September 17, 2011
+.Dd February 15, 2021
 .Dt DUPLOCALE 3
 .Os
 .Sh NAME
@@ -46,17 +46,6 @@ Duplicates an existing
 returning a new
 .Fa locale_t
 that refers to the same locale values but has an independent internal state.
-Various functions, such as
-.Xr mblen 3
-require a persistent state.
-These functions formerly used static variables and calls to them from multiple
-threads had undefined behavior.
-They now use fields in the
-.Fa locale_t
-associated with the current thread by
-.Xr uselocale 3 .
-These calls are therefore only thread safe on threads with a unique per-thread
-locale.
 The locale returned by this call must be freed with
 .Xr freelocale 3 .
 .Sh SEE ALSO
@@ -64,17 +53,8 @@ The locale returned by this call must be
 .Xr localeconv 3 ,
 .Xr newlocale 3 ,
 .\" .Xr querylocale 3 ,
-.Xr uselocale 3 ,
+.\" .Xr uselocale 3 ,
 .\" .Xr xlocale 3
 .Sh STANDARDS
 This function conforms to
 .St -p1003.1-2008 .
-.Sh BUGS
-Ideally,
-.Xr uselocale 3
-should make a copy of the
-.Fa locale_t
-implicitly to ensure thread safety,
-and a copy of the global locale should be installed lazily on each thread.
-The FreeBSD implementation does not do this,
-for compatibility with Darwin.
Index: src/lib/libc/locale/freelocale.3
diff -u src/lib/libc/locale/freelocale.3:1.1 src/lib/libc/locale/freelocale.3:1.2
--- src/lib/libc/locale/freelocale.3:1.1	Mon Feb 15 09:35:04 2021
+++ src/lib/libc/locale/freelocale.3	Mon Feb 15 10:36:53 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: freelocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $
+.\" $NetBSD: freelocale.3,v 1.2 2021/02/15 15:36:53 christos Exp $
 .\" Copyright (c) 2011 The FreeBSD Foundation
 .\" All rights reserved.
 .\"
@@ -27,7 +27,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD: head/lib/libc/locale/freelocale.3 303495 2016-07-29 17:18:47Z ed $
-.Dd July 26, 2016
+.Dd February 15, 2021
 .Dt FREELOCALE 3
 .Os
 .Sh NAME
@@ -46,14 +46,12 @@ or
 Frees a
 .Fa locale_t .
 This relinquishes any resources held exclusively by this locale.
-Note that locales share reference-counted components,
-so a call to this function is not guaranteed to free all of the components.
 .Sh SEE ALSO
 .Xr duplocale 3 ,
 .Xr localeconv 3 ,
 .Xr newlocale 3 ,
 .\" .Xr querylocale 3 ,
-.Xr uselocale 3 ,
+.\" .Xr uselocale 3 ,
 .\" .Xr xlocale 3
 .Sh STANDARDS
 This function conforms to
Index: src/lib/libc/locale/newlocale.3
diff -u src/lib/libc/locale/newlocale.3:1.1 src/lib/libc/locale/newlocale.3:1.2
--- src/lib/libc/locale/newlocale.3:1.1	Mon Feb 15 09:35:04 2021
+++ src/lib/libc/locale/newlocale.3	Mon Feb 15 10:36:53 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: newlocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $
+.\" $NetBSD: newlocale.3,v 1.2 2021/02/15 15:36:53 christos Exp $
 .\" Copyright (c) 2011 The FreeBSD Foundation
 .\" All rights reserved.
 .\"
@@ -27,7 +27,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD: head/lib/libc/locale/newlocale.3 366375 2020-10-02 18:35:55Z markj $
-.Dd October 2, 2020
+.Dd February 15, 2021
 .Dt NEWLOCALE 3
 .Os
 .Sh NAME
@@ -118,9 +118,9 @@ You must free the returned locale with
 .Xr duplocale 3 ,
 .Xr freelocale 3 ,
 .Xr localeconv 3 ,
-\" .Xr querylocale 3 ,
-.Xr uselocale 3 ,
-\" .Xr xlocale 3
+.\" .Xr querylocale 3 ,
+.\" .Xr uselocale 3 ,
+.\" .Xr xlocale 3
 .Sh STANDARDS
 This function conforms to
 .St -p1003.1-2008 .



CVS commit: src/lib/libc/locale

2021-02-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 15 14:35:04 UTC 2021

Modified Files:
src/lib/libc/locale: Makefile.inc
Added Files:
src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3

Log Message:
Add missing man pages (from FreeBSD)


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/duplocale.3 \
src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.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/Makefile.inc
diff -u src/lib/libc/locale/Makefile.inc:1.64 src/lib/libc/locale/Makefile.inc:1.65
--- src/lib/libc/locale/Makefile.inc:1.64	Sun Aug 18 16:03:48 2013
+++ src/lib/libc/locale/Makefile.inc	Mon Feb 15 09:35:04 2021
@@ -1,5 +1,5 @@
 #	from: @(#)Makefile.inc	5.1 (Berkeley) 2/18/91
-#	$NetBSD: Makefile.inc,v 1.64 2013/08/18 20:03:48 joerg Exp $
+#	$NetBSD: Makefile.inc,v 1.65 2021/02/15 14:35:04 christos Exp $
 
 # locale sources
 .PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
@@ -21,7 +21,7 @@ CPPFLAGS.runetable.c+=		-I${LIBCDIR}/cit
 CPPFLAGS.multibyte_c90.c+=	-I${LIBCDIR}/citrus
 CPPFLAGS.multibyte_amd1.c+=	-I${LIBCDIR}/citrus
 
-MAN+=	setlocale.3 nl_langinfo.3
+MAN+=	duplocale.3 freelocale.3 newlocale.3 setlocale.3 nl_langinfo.3 
 
 MAN+=	mbtowc.3 mbstowcs.3 wctomb.3 wcstombs.3 mblen.3 \
 

Added files:

Index: src/lib/libc/locale/duplocale.3
diff -u /dev/null src/lib/libc/locale/duplocale.3:1.1
--- /dev/null	Mon Feb 15 09:35:04 2021
+++ src/lib/libc/locale/duplocale.3	Mon Feb 15 09:35:04 2021
@@ -0,0 +1,80 @@
+.\" $NetBSD: duplocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $
+.\" Copyright (c) 2011 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This documentation was written by David Chisnall under sponsorship from
+.\" the FreeBSD Foundation.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" 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: head/lib/libc/locale/duplocale.3 281925 2015-04-24 10:17:55Z theraven $
+.\"
+.Dd September 17, 2011
+.Dt DUPLOCALE 3
+.Os
+.Sh NAME
+.Nm duplocale
+.Nd duplicate an locale
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In locale.h
+.Ft locale_t
+.Fn duplocale "locale_t locale"
+.Sh DESCRIPTION
+Duplicates an existing
+.Fa locale_t
+returning a new
+.Fa locale_t
+that refers to the same locale values but has an independent internal state.
+Various functions, such as
+.Xr mblen 3
+require a persistent state.
+These functions formerly used static variables and calls to them from multiple
+threads had undefined behavior.
+They now use fields in the
+.Fa locale_t
+associated with the current thread by
+.Xr uselocale 3 .
+These calls are therefore only thread safe on threads with a unique per-thread
+locale.
+The locale returned by this call must be freed with
+.Xr freelocale 3 .
+.Sh SEE ALSO
+.Xr freelocale 3 ,
+.Xr localeconv 3 ,
+.Xr newlocale 3 ,
+.\" .Xr querylocale 3 ,
+.Xr uselocale 3 ,
+.\" .Xr xlocale 3
+.Sh STANDARDS
+This function conforms to
+.St -p1003.1-2008 .
+.Sh BUGS
+Ideally,
+.Xr uselocale 3
+should make a copy of the
+.Fa locale_t
+implicitly to ensure thread safety,
+and a copy of the global locale should be installed lazily on each thread.
+The FreeBSD implementation does not do this,
+for compatibility with Darwin.
Index: src/lib/libc/locale/freelocale.3
diff -u /dev/null src/lib/libc/locale/freelocale.3:1.1
--- /dev/null	Mon Feb 15 09:35:04 2021
+++ src/lib/libc/locale/freelocale.3	Mon Feb 15 09:35:04 2021
@@ -0,0 +1,60 @@
+.\" $NetBSD: freelocale.3,v 1.1 2021/02/15 14:35:04 christos Exp $
+.\" Copyright (c) 2011 The FreeBSD Foundation
+.\" All rights reserved.

CVS commit: src/lib/libc/locale

2021-02-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 15 14:35:04 UTC 2021

Modified Files:
src/lib/libc/locale: Makefile.inc
Added Files:
src/lib/libc/locale: duplocale.3 freelocale.3 newlocale.3

Log Message:
Add missing man pages (from FreeBSD)


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/duplocale.3 \
src/lib/libc/locale/freelocale.3 src/lib/libc/locale/newlocale.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2017-12-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  9 22:48:00 UTC 2017

Modified Files:
src/lib/libc/locale: wcstod.c wcstof.c wcstold.c

Log Message:
PR/52801: Kamil Rytarowski: Add missing weak aliases for wcsto{f,d,ld}_l
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/wcstod.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/wcstof.c \
src/lib/libc/locale/wcstold.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2017-12-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  9 22:48:00 UTC 2017

Modified Files:
src/lib/libc/locale: wcstod.c wcstof.c wcstold.c

Log Message:
PR/52801: Kamil Rytarowski: Add missing weak aliases for wcsto{f,d,ld}_l
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/wcstod.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/wcstof.c \
src/lib/libc/locale/wcstold.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/wcstod.c
diff -u src/lib/libc/locale/wcstod.c:1.15 src/lib/libc/locale/wcstod.c:1.16
--- src/lib/libc/locale/wcstod.c:1.15	Thu Apr 18 18:23:17 2013
+++ src/lib/libc/locale/wcstod.c	Sat Dec  9 17:48:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: wcstod.c,v 1.15 2013/04/18 22:23:17 joerg Exp $ */
+/* $NetBSD: wcstod.c,v 1.16 2017/12/09 22:48:00 christos Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstod.c,v 1.15 2013/04/18 22:23:17 joerg Exp $");
+__RCSID("$NetBSD: wcstod.c,v 1.16 2017/12/09 22:48:00 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: wcstod.c,v 1.15 2013/0
 #include 
 
 __weak_alias(wcstod,_wcstod)
+__weak_alias(wcstod_l,_wcstod_l)
 
 #define _FUNCNAME	wcstod
 #define _RETURN_TYPE	double

Index: src/lib/libc/locale/wcstof.c
diff -u src/lib/libc/locale/wcstof.c:1.4 src/lib/libc/locale/wcstof.c:1.5
--- src/lib/libc/locale/wcstof.c:1.4	Thu Apr 18 18:23:18 2013
+++ src/lib/libc/locale/wcstof.c	Sat Dec  9 17:48:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: wcstof.c,v 1.4 2013/04/18 22:23:18 joerg Exp $ */
+/* $NetBSD: wcstof.c,v 1.5 2017/12/09 22:48:00 christos Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstof.c,v 1.4 2013/04/18 22:23:18 joerg Exp $");
+__RCSID("$NetBSD: wcstof.c,v 1.5 2017/12/09 22:48:00 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: wcstof.c,v 1.4 2013/04
 #include 
 
 __weak_alias(wcstof,_wcstof)
+__weak_alias(wcstof_l,_wcstof_l)
 
 #define _FUNCNAME	wcstof
 #define _RETURN_TYPE	float
Index: src/lib/libc/locale/wcstold.c
diff -u src/lib/libc/locale/wcstold.c:1.4 src/lib/libc/locale/wcstold.c:1.5
--- src/lib/libc/locale/wcstold.c:1.4	Thu Apr 18 18:23:18 2013
+++ src/lib/libc/locale/wcstold.c	Sat Dec  9 17:48:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: wcstold.c,v 1.4 2013/04/18 22:23:18 joerg Exp $ */
+/* $NetBSD: wcstold.c,v 1.5 2017/12/09 22:48:00 christos Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcstold.c,v 1.4 2013/04/18 22:23:18 joerg Exp $");
+__RCSID("$NetBSD: wcstold.c,v 1.5 2017/12/09 22:48:00 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: wcstold.c,v 1.4 2013/0
 #include 
 
 __weak_alias(wcstold,_wcstold)
+__weak_alias(wcstold_l,_wcstold_l)
 
 #define _FUNCNAME	wcstold
 #define _RETURN_TYPE	long double



CVS commit: src/lib/libc/locale

2017-10-25 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Oct 25 16:07:34 UTC 2017

Modified Files:
src/lib/libc/locale: towlower.3

Log Message:
Add towupper to the NAME section as well.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/locale/towlower.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/towlower.3
diff -u src/lib/libc/locale/towlower.3:1.7 src/lib/libc/locale/towlower.3:1.8
--- src/lib/libc/locale/towlower.3:1.7	Mon Sep  8 17:54:31 2003
+++ src/lib/libc/locale/towlower.3	Wed Oct 25 16:07:34 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: towlower.3,v 1.7 2003/09/08 17:54:31 wiz Exp $
+.\"	$NetBSD: towlower.3,v 1.8 2017/10/25 16:07:34 abhinav Exp $
 .\"
 .\" Copyright (c) 1989, 1991 The Regents of the University of California.
 .\" All rights reserved.
@@ -37,7 +37,8 @@
 .Dt TOWLOWER 3
 .Os
 .Sh NAME
-.Nm towlower
+.Nm towlower ,
+.Nm towupper
 .Nd wide character case letter conversion utilities
 .Sh LIBRARY
 .Lb libc



CVS commit: src/lib/libc/locale

2017-10-25 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Oct 25 16:07:34 UTC 2017

Modified Files:
src/lib/libc/locale: towlower.3

Log Message:
Add towupper to the NAME section as well.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/locale/towlower.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 17:50:24 UTC 2017

Modified Files:
src/lib/libc/locale: nl_langinfo.c

Log Message:
pacify lint.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/locale/nl_langinfo.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/nl_langinfo.c
diff -u src/lib/libc/locale/nl_langinfo.c:1.17 src/lib/libc/locale/nl_langinfo.c:1.18
--- src/lib/libc/locale/nl_langinfo.c:1.17	Tue Aug 20 15:58:30 2013
+++ src/lib/libc/locale/nl_langinfo.c	Tue Jan 10 12:50:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: nl_langinfo.c,v 1.17 2013/08/20 19:58:30 joerg Exp $ */
+/* $NetBSD: nl_langinfo.c,v 1.18 2017/01/10 17:50:24 christos Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: nl_langinfo.c,v 1.17 2013/08/20 19:58:30 joerg Exp $");
+__RCSID("$NetBSD: nl_langinfo.c,v 1.18 2017/01/10 17:50:24 christos Exp $");
 
 #include "namespace.h"
 #include 
@@ -102,59 +102,61 @@ static const char langinfo_category[] = 
 [ ALT_DIGITS ] = 0,
 };
 
+#define offsetofu16(a, b) ((uint16_t)offsetof(a, b))
+
 static const uint16_t langinfo_offset[] = {
-[ D_T_FMT ] = offsetof(_TimeLocale, d_t_fmt),
-[ D_FMT ] = offsetof(_TimeLocale, d_fmt),
-[ T_FMT ] = offsetof(_TimeLocale, t_fmt),
-[ T_FMT_AMPM ] = offsetof(_TimeLocale, t_fmt_ampm),
-[ AM_STR ] = offsetof(_TimeLocale, am_pm[0]),
-[ PM_STR ] = offsetof(_TimeLocale, am_pm[1]),
-[ DAY_1 ] = offsetof(_TimeLocale, day[0]),
-[ DAY_2 ] = offsetof(_TimeLocale, day[1]),
-[ DAY_3 ] = offsetof(_TimeLocale, day[2]),
-[ DAY_4 ] = offsetof(_TimeLocale, day[3]),
-[ DAY_5 ] = offsetof(_TimeLocale, day[4]),
-[ DAY_6 ] = offsetof(_TimeLocale, day[5]),
-[ DAY_7 ] = offsetof(_TimeLocale, day[6]),
-[ ABDAY_1 ] = offsetof(_TimeLocale, abday[0]),
-[ ABDAY_2 ] = offsetof(_TimeLocale, abday[1]),
-[ ABDAY_3 ] = offsetof(_TimeLocale, abday[2]),
-[ ABDAY_4 ] = offsetof(_TimeLocale, abday[3]),
-[ ABDAY_5 ] = offsetof(_TimeLocale, abday[4]),
-[ ABDAY_6 ] = offsetof(_TimeLocale, abday[5]),
-[ ABDAY_7 ] = offsetof(_TimeLocale, abday[6]),
-[ MON_1 ] = offsetof(_TimeLocale, mon[0]),
-[ MON_2 ] = offsetof(_TimeLocale, mon[1]),
-[ MON_3 ] = offsetof(_TimeLocale, mon[2]),
-[ MON_4 ] = offsetof(_TimeLocale, mon[3]),
-[ MON_5 ] = offsetof(_TimeLocale, mon[4]),
-[ MON_6 ] = offsetof(_TimeLocale, mon[5]),
-[ MON_7 ] = offsetof(_TimeLocale, mon[6]),
-[ MON_8 ] = offsetof(_TimeLocale, mon[7]),
-[ MON_9 ] = offsetof(_TimeLocale, mon[8]),
-[ MON_10 ] = offsetof(_TimeLocale, mon[9]),
-[ MON_11 ] = offsetof(_TimeLocale, mon[10]),
-[ MON_12 ] = offsetof(_TimeLocale, mon[11]),
-[ ABMON_1 ] = offsetof(_TimeLocale, abmon[0]),
-[ ABMON_2 ] = offsetof(_TimeLocale, abmon[1]),
-[ ABMON_3 ] = offsetof(_TimeLocale, abmon[2]),
-[ ABMON_4 ] = offsetof(_TimeLocale, abmon[3]),
-[ ABMON_5 ] = offsetof(_TimeLocale, abmon[4]),
-[ ABMON_6 ] = offsetof(_TimeLocale, abmon[5]),
-[ ABMON_7 ] = offsetof(_TimeLocale, abmon[6]),
-[ ABMON_8 ] = offsetof(_TimeLocale, abmon[7]),
-[ ABMON_9 ] = offsetof(_TimeLocale, abmon[8]),
-[ ABMON_10 ] = offsetof(_TimeLocale, abmon[9]),
-[ ABMON_11 ] = offsetof(_TimeLocale, abmon[10]),
-[ ABMON_12 ] = offsetof(_TimeLocale, abmon[11]),
-[ RADIXCHAR ] = offsetof(_NumericLocale, decimal_point),
-[ THOUSEP ] = offsetof(_NumericLocale, thousands_sep),
-[ YESSTR ] = offsetof(_MessagesLocale, yesstr),
-[ YESEXPR ] = offsetof(_MessagesLocale, yesexpr),
-[ NOSTR ] = offsetof(_MessagesLocale, nostr),
-[ NOEXPR ] = offsetof(_MessagesLocale, noexpr),
+[ D_T_FMT ] = offsetofu16(_TimeLocale, d_t_fmt),
+[ D_FMT ] = offsetofu16(_TimeLocale, d_fmt),
+[ T_FMT ] = offsetofu16(_TimeLocale, t_fmt),
+[ T_FMT_AMPM ] = offsetofu16(_TimeLocale, t_fmt_ampm),
+[ AM_STR ] = offsetofu16(_TimeLocale, am_pm[0]),
+[ PM_STR ] = offsetofu16(_TimeLocale, am_pm[1]),
+[ DAY_1 ] = offsetofu16(_TimeLocale, day[0]),
+[ DAY_2 ] = offsetofu16(_TimeLocale, day[1]),
+[ DAY_3 ] = offsetofu16(_TimeLocale, day[2]),
+[ DAY_4 ] = offsetofu16(_TimeLocale, day[3]),
+[ DAY_5 ] = offsetofu16(_TimeLocale, day[4]),
+[ DAY_6 ] = offsetofu16(_TimeLocale, day[5]),
+[ DAY_7 ] = offsetofu16(_TimeLocale, day[6]),
+[ ABDAY_1 ] = offsetofu16(_TimeLocale, abday[0]),
+[ ABDAY_2 ] = offsetofu16(_TimeLocale, abday[1]),
+[ ABDAY_3 ] = offsetofu16(_TimeLocale, abday[2]),
+[ ABDAY_4 ] = offsetofu16(_TimeLocale, abday[3]),
+[ ABDAY_5 ] = offsetofu16(_TimeLocale, abday[4]),
+[ ABDAY_6 ] = offsetofu16(_TimeLocale, abday[5]),
+[ ABDAY_7 ] = offsetofu16(_TimeLocale, abday[6]),
+[ MON_1 ] = offsetofu16(_TimeLocale, mon[0]),
+[ MON_2 ] = offsetofu16(_TimeLocale, 

CVS commit: src/lib/libc/locale

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 17:50:24 UTC 2017

Modified Files:
src/lib/libc/locale: nl_langinfo.c

Log Message:
pacify lint.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/locale/nl_langinfo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2016-06-27 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon Jun 27 08:18:34 UTC 2016

Modified Files:
src/lib/libc/locale: wctomb.3

Log Message:
Fix function prototype in the SYNOPSIS
Also, fix function name in the RETURN VALUES section.

>From Henning Petersen in PR lib/51284


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/wctomb.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/wctomb.3
diff -u src/lib/libc/locale/wctomb.3:1.5 src/lib/libc/locale/wctomb.3:1.6
--- src/lib/libc/locale/wctomb.3:1.5	Sat Oct 14 07:51:01 2006
+++ src/lib/libc/locale/wctomb.3	Mon Jun 27 08:18:34 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: wctomb.3,v 1.5 2006/10/14 07:51:01 wiz Exp $
+.\" $NetBSD: wctomb.3,v 1.6 2016/06/27 08:18:34 abhinav Exp $
 .\"
 .\" Copyright (c)2002 Citrus Project,
 .\" All rights reserved.
@@ -35,7 +35,7 @@
 .Sh SYNOPSIS
 .In stdlib.h
 .Ft int
-.Fn wctomb "char * s" "const wchar_t wchar"
+.Fn wctomb "char * s" "wchar_t wchar"
 .Sh DESCRIPTION
 The
 .Fn wctomb
@@ -112,7 +112,7 @@ If
 .Fa s
 is equal to
 .Dv NULL ,
-.Fn mbtowc
+.Fn wctomb
 returns:
 .Bl -tag -width 0123456789
 .It 0



CVS commit: src/lib/libc/locale

2016-06-27 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon Jun 27 08:18:34 UTC 2016

Modified Files:
src/lib/libc/locale: wctomb.3

Log Message:
Fix function prototype in the SYNOPSIS
Also, fix function name in the RETURN VALUES section.

>From Henning Petersen in PR lib/51284


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/wctomb.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2016-03-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar 17 17:38:14 UTC 2016

Modified Files:
src/lib/libc/locale: global_locale.c

Log Message:
undo the dso protected for clang


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/locale/global_locale.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/global_locale.c
diff -u src/lib/libc/locale/global_locale.c:1.23 src/lib/libc/locale/global_locale.c:1.24
--- src/lib/libc/locale/global_locale.c:1.23	Mon Mar  7 23:00:11 2016
+++ src/lib/libc/locale/global_locale.c	Thu Mar 17 13:38:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.23 2016/03/08 04:00:11 christos Exp $ */
+/* $NetBSD: global_locale.c,v 1.24 2016/03/17 17:38:14 christos Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.23 2016/03/08 04:00:11 christos Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.24 2016/03/17 17:38:14 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -143,7 +143,10 @@ __dso_hidden const struct _locale_cache_
 .numeric_name = _lc_C_locale_name,
 };
 
-__dso_protected struct _locale _lc_global_locale = {
+#ifndef __clang__
+__dso_protected
+#endif
+struct _locale _lc_global_locale = {
 .cache = &_C_cache,
 .query = { _C_LOCALE },
 .part_name = {
@@ -171,7 +174,10 @@ __dso_protected struct _locale _lc_globa
 },
 };
 
-__dso_protected const struct _locale _lc_C_locale = {
+#ifndef __clang__
+__dso_protected
+#endif
+const struct _locale _lc_C_locale = {
 .cache = &_C_cache,
 .query = { _C_LOCALE },
 .part_name = {



CVS commit: src/lib/libc/locale

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  8 04:00:11 UTC 2016

Modified Files:
src/lib/libc/locale: global_locale.c

Log Message:
Undo the __dso_protected hackery.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/locale/global_locale.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/global_locale.c
diff -u src/lib/libc/locale/global_locale.c:1.22 src/lib/libc/locale/global_locale.c:1.23
--- src/lib/libc/locale/global_locale.c:1.22	Fri Jan 29 10:18:08 2016
+++ src/lib/libc/locale/global_locale.c	Mon Mar  7 23:00:11 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.22 2016/01/29 15:18:08 christos Exp $ */
+/* $NetBSD: global_locale.c,v 1.23 2016/03/08 04:00:11 christos Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.22 2016/01/29 15:18:08 christos Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.23 2016/03/08 04:00:11 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -143,7 +143,7 @@ __dso_hidden const struct _locale_cache_
 .numeric_name = _lc_C_locale_name,
 };
 
-/* __dso_protected */ struct _locale _lc_global_locale = {
+__dso_protected struct _locale _lc_global_locale = {
 .cache = &_C_cache,
 .query = { _C_LOCALE },
 .part_name = {
@@ -171,7 +171,7 @@ __dso_hidden const struct _locale_cache_
 },
 };
 
-/* __dso_protected */ const struct _locale _lc_C_locale = {
+__dso_protected const struct _locale _lc_C_locale = {
 .cache = &_C_cache,
 .query = { _C_LOCALE },
 .part_name = {



CVS commit: src/lib/libc/locale

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  8 04:00:11 UTC 2016

Modified Files:
src/lib/libc/locale: global_locale.c

Log Message:
Undo the __dso_protected hackery.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/locale/global_locale.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2016-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 29 15:18:08 UTC 2016

Modified Files:
src/lib/libc/locale: global_locale.c setlocale_local.h

Log Message:
disable dso protected to work around binutils bug.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/locale/global_locale.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/setlocale_local.h

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/global_locale.c
diff -u src/lib/libc/locale/global_locale.c:1.21 src/lib/libc/locale/global_locale.c:1.22
--- src/lib/libc/locale/global_locale.c:1.21	Fri Sep 13 09:13:32 2013
+++ src/lib/libc/locale/global_locale.c	Fri Jan 29 10:18:08 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.21 2013/09/13 13:13:32 joerg Exp $ */
+/* $NetBSD: global_locale.c,v 1.22 2016/01/29 15:18:08 christos Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.21 2013/09/13 13:13:32 joerg Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.22 2016/01/29 15:18:08 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include 
@@ -143,7 +143,7 @@ __dso_hidden const struct _locale_cache_
 .numeric_name = _lc_C_locale_name,
 };
 
-__dso_protected struct _locale _lc_global_locale = {
+/* __dso_protected */ struct _locale _lc_global_locale = {
 .cache = &_C_cache,
 .query = { _C_LOCALE },
 .part_name = {
@@ -171,7 +171,7 @@ __dso_protected struct _locale _lc_globa
 },
 };
 
-__dso_protected const struct _locale _lc_C_locale = {
+/* __dso_protected */ const struct _locale _lc_C_locale = {
 .cache = &_C_cache,
 .query = { _C_LOCALE },
 .part_name = {

Index: src/lib/libc/locale/setlocale_local.h
diff -u src/lib/libc/locale/setlocale_local.h:1.15 src/lib/libc/locale/setlocale_local.h:1.16
--- src/lib/libc/locale/setlocale_local.h:1.15	Fri Sep 13 09:13:32 2013
+++ src/lib/libc/locale/setlocale_local.h	Fri Jan 29 10:18:08 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: setlocale_local.h,v 1.15 2013/09/13 13:13:32 joerg Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.16 2016/01/29 15:18:08 christos Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -85,7 +85,9 @@ int _setlocale_cache(locale_t, struct _l
 __END_DECLS
 
 #ifdef _LIBC
+#if 0
 extern __dso_protected struct _locale	_lc_global_locale;
+#endif
 extern __dso_hidden const struct _locale_cache_t _C_cache;
 
 static __inline struct _locale *



CVS commit: src/lib/libc/locale

2016-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 29 15:18:08 UTC 2016

Modified Files:
src/lib/libc/locale: global_locale.c setlocale_local.h

Log Message:
disable dso protected to work around binutils bug.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/locale/global_locale.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/setlocale_local.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2013-08-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Aug 19 09:12:59 UTC 2013

Modified Files:
src/lib/libc/locale: nb_lc_messages_misc.h nb_lc_monetary_misc.h
nb_lc_numeric_misc.h nb_lc_time_misc.h

Log Message:
Shut up lint.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/nb_lc_messages_misc.h \
src/lib/libc/locale/nb_lc_monetary_misc.h \
src/lib/libc/locale/nb_lc_numeric_misc.h
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/nb_lc_time_misc.h

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/nb_lc_messages_misc.h
diff -u src/lib/libc/locale/nb_lc_messages_misc.h:1.4 src/lib/libc/locale/nb_lc_messages_misc.h:1.5
--- src/lib/libc/locale/nb_lc_messages_misc.h:1.4	Sun Aug 18 20:03:48 2013
+++ src/lib/libc/locale/nb_lc_messages_misc.h	Mon Aug 19 09:12:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_messages_misc.h,v 1.4 2013/08/18 20:03:48 joerg Exp $ */
+/* $NetBSD: nb_lc_messages_misc.h,v 1.5 2013/08/19 09:12:58 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -48,6 +48,7 @@ _PREFIX(build_cache)(struct _locale_cach
 	cache-items[(size_t)NOEXPR ] = data-noexpr;
 }
 
+/* ARGSUSED */
 static __inline void
 _PREFIX(update_global)(_MessagesLocale *data)
 {
Index: src/lib/libc/locale/nb_lc_monetary_misc.h
diff -u src/lib/libc/locale/nb_lc_monetary_misc.h:1.4 src/lib/libc/locale/nb_lc_monetary_misc.h:1.5
--- src/lib/libc/locale/nb_lc_monetary_misc.h:1.4	Sun Aug 18 20:03:48 2013
+++ src/lib/libc/locale/nb_lc_monetary_misc.h	Mon Aug 19 09:12:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_monetary_misc.h,v 1.4 2013/08/18 20:03:48 joerg Exp $ */
+/* $NetBSD: nb_lc_monetary_misc.h,v 1.5 2013/08/19 09:12:58 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -72,6 +72,7 @@ _PREFIX(build_cache)(struct _locale_cach
 	cache-items[(size_t)CRNCYSTR] = NULL; /* NOT IMPLEMENTED YET */
 }
 
+/* ARGSUSED */
 static __inline void
 _PREFIX(update_global)(_MonetaryLocale *data)
 {
Index: src/lib/libc/locale/nb_lc_numeric_misc.h
diff -u src/lib/libc/locale/nb_lc_numeric_misc.h:1.4 src/lib/libc/locale/nb_lc_numeric_misc.h:1.5
--- src/lib/libc/locale/nb_lc_numeric_misc.h:1.4	Sun Aug 18 20:03:48 2013
+++ src/lib/libc/locale/nb_lc_numeric_misc.h	Mon Aug 19 09:12:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_numeric_misc.h,v 1.4 2013/08/18 20:03:48 joerg Exp $ */
+/* $NetBSD: nb_lc_numeric_misc.h,v 1.5 2013/08/19 09:12:58 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -54,6 +54,7 @@ _PREFIX(build_cache)(struct _locale_cach
 	cache-items[(size_t)THOUSEP  ] = data-thousands_sep;
 }
 
+/* ARGSUSED */
 static __inline void
 _PREFIX(update_global)(_NumericLocale *data)
 {

Index: src/lib/libc/locale/nb_lc_time_misc.h
diff -u src/lib/libc/locale/nb_lc_time_misc.h:1.5 src/lib/libc/locale/nb_lc_time_misc.h:1.6
--- src/lib/libc/locale/nb_lc_time_misc.h:1.5	Sun Aug 18 20:03:48 2013
+++ src/lib/libc/locale/nb_lc_time_misc.h	Mon Aug 19 09:12:58 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nb_lc_time_misc.h,v 1.5 2013/08/18 20:03:48 joerg Exp $ */
+/* $NetBSD: nb_lc_time_misc.h,v 1.6 2013/08/19 09:12:58 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -74,6 +74,7 @@ _PREFIX(build_cache)(struct _locale_cach
 	cache-items[(size_t)ALT_DIGITS ] = NULL;
 }
 
+/* ARGSUSED */
 static __inline void
 _PREFIX(update_global)(_TimeLocale *data)
 {



CVS commit: src/lib/libc/locale

2013-08-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Aug 19 20:41:15 UTC 2013

Modified Files:
src/lib/libc/locale: wcsftime.c

Log Message:
Missing locale specific change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/wcsftime.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/wcsftime.c
diff -u src/lib/libc/locale/wcsftime.c:1.4 src/lib/libc/locale/wcsftime.c:1.5
--- src/lib/libc/locale/wcsftime.c:1.4	Mon Aug 19 08:03:34 2013
+++ src/lib/libc/locale/wcsftime.c	Mon Aug 19 20:41:15 2013
@@ -1,4 +1,4 @@
-/*	 $NetBSD: wcsftime.c,v 1.4 2013/08/19 08:03:34 joerg Exp $	*/
+/*	 $NetBSD: wcsftime.c,v 1.5 2013/08/19 20:41:15 joerg Exp $	*/
 /*-
  * Copyright (c) 2002 Tim J. Robbins
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: wcsftime.c,v 1.4 2013/08/19 08:03:34 joerg Exp $);
+__RCSID($NetBSD: wcsftime.c,v 1.5 2013/08/19 20:41:15 joerg Exp $);
 
 #define __SETLOCALE_SOURCE__
 #include namespace.h
@@ -93,7 +93,7 @@ wcsftime_l(wchar_t *wcs, size_t maxsize,
 		errno = EINVAL;
 		goto error;
 	}
-	dst = malloc(maxsize * MB_CUR_MAX);
+	dst = malloc(maxsize * MB_CUR_MAX_L(loc));
 	if (dst == NULL)
 		goto error;
 	if (strftime_l(dst, maxsize, sformat, timeptr, loc) == 0)



CVS commit: src/lib/libc/locale

2013-08-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Aug 19 09:12:59 UTC 2013

Modified Files:
src/lib/libc/locale: nb_lc_messages_misc.h nb_lc_monetary_misc.h
nb_lc_numeric_misc.h nb_lc_time_misc.h

Log Message:
Shut up lint.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/nb_lc_messages_misc.h \
src/lib/libc/locale/nb_lc_monetary_misc.h \
src/lib/libc/locale/nb_lc_numeric_misc.h
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/nb_lc_time_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2013-08-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Aug 19 20:41:15 UTC 2013

Modified Files:
src/lib/libc/locale: wcsftime.c

Log Message:
Missing locale specific change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/wcsftime.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2013-08-17 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Aug 17 18:48:01 UTC 2013

Removed Files:
src/lib/libc/locale: runetype_misc.h

Log Message:
Remove empty file.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r0 src/lib/libc/locale/runetype_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2013-08-17 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Aug 17 18:48:01 UTC 2013

Removed Files:
src/lib/libc/locale: runetype_misc.h

Log Message:
Remove empty file.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r0 src/lib/libc/locale/runetype_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libc/locale

2013-04-22 Thread Joerg Sonnenberger
On Mon, Apr 22, 2013 at 01:45:52AM +, YAMAMOTO Takashi wrote:
  On Thu, Apr 18, 2013 at 06:58:42AM +, YAMAMOTO Takashi wrote:
   On Tue, Apr 16, 2013 at 11:34:52PM +, YAMAMOTO Takashi wrote:
On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
so that the struct _locale __C_locale in libc is much more wasteful.

I should add that it is an internal detail and the way the composed C
locale is stored can and likely will change later. So the way it is
essentially a copy of (old) global locale is just a way to be 
minimally
intrusive.

Joerg
   
   i care the API.
   
   if you really want it be in libc, how about having libc provide a
   locale_t get_static_c_locale(); style API rather than using NULL?
   it's better because 1) less code in *_l, 2) autoconf-like can detect
   the extension easily, and 3) a portable application can trivially
   have a fallback implementation using newlocale+pthread_once.
   
   It adds more cost on the caller side. So far, there are three mechanisms
   available (especially for libraries):
   
   (1) Adhoc access to internal locale state. This is used with glibc.
   (2) Explicit newlocale().
   (3) Implicit access via 0 argument to *_l.
   
   The first one is clearly a hack and not acceptable. Portable code can
   always conditionally use (2), but it requires additional setup and
   storage cost. (3) is used by Apple (which is where a large part of the
   *_l interface originates from) and FreeBSD. It is orthogonal to (2) and
   certainly easier to use. Exposing it via a special library call is also
   possible and effectively a way to implement (2) by a static wrapper.
   It still adds more cost to every caller and this is a classic case where
   there are typically much more callers.
   
   Joerg
  
  (3) adds small costs to every calls of *_l, even when the extension
  is not used.  i sounds worse than a one-time cost of (2) to me.
  
  (2) still needs to load the address (instead of a constant), so it isn't
  free either. Given that this is very popular as functionality and at
  least on modern CPUs often implementable as conditional-move, it sounds
  like a much better trade off.
 
 very popular?  i'm not aware of a single software which uses this extension.
 can you provide examples?

The very popular specifically applies to the need for accessing the C
locale. Most bigger libraries need it one way or another. I am currently
talking with Apple about providing a visible macro (LC_C_LOCALE) to
address the testability issue.

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-21 Thread YAMAMOTO Takashi
 On Thu, Apr 18, 2013 at 06:58:42AM +, YAMAMOTO Takashi wrote:
  On Tue, Apr 16, 2013 at 11:34:52PM +, YAMAMOTO Takashi wrote:
   On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
   so that the struct _locale __C_locale in libc is much more wasteful.
   
   I should add that it is an internal detail and the way the composed C
   locale is stored can and likely will change later. So the way it is
   essentially a copy of (old) global locale is just a way to be minimally
   intrusive.
   
   Joerg
  
  i care the API.
  
  if you really want it be in libc, how about having libc provide a
  locale_t get_static_c_locale(); style API rather than using NULL?
  it's better because 1) less code in *_l, 2) autoconf-like can detect
  the extension easily, and 3) a portable application can trivially
  have a fallback implementation using newlocale+pthread_once.
  
  It adds more cost on the caller side. So far, there are three mechanisms
  available (especially for libraries):
  
  (1) Adhoc access to internal locale state. This is used with glibc.
  (2) Explicit newlocale().
  (3) Implicit access via 0 argument to *_l.
  
  The first one is clearly a hack and not acceptable. Portable code can
  always conditionally use (2), but it requires additional setup and
  storage cost. (3) is used by Apple (which is where a large part of the
  *_l interface originates from) and FreeBSD. It is orthogonal to (2) and
  certainly easier to use. Exposing it via a special library call is also
  possible and effectively a way to implement (2) by a static wrapper.
  It still adds more cost to every caller and this is a classic case where
  there are typically much more callers.
  
  Joerg
 
 (3) adds small costs to every calls of *_l, even when the extension
 is not used.  i sounds worse than a one-time cost of (2) to me.
 
 (2) still needs to load the address (instead of a constant), so it isn't
 free either. Given that this is very popular as functionality and at
 least on modern CPUs often implementable as conditional-move, it sounds
 like a much better trade off.

very popular?  i'm not aware of a single software which uses this extension.
can you provide examples?

YAMAMOTO Takashi

 
 Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-18 Thread YAMAMOTO Takashi
 On Tue, Apr 16, 2013 at 11:34:52PM +, YAMAMOTO Takashi wrote:
  On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
  so that the struct _locale __C_locale in libc is much more wasteful.
  
  I should add that it is an internal detail and the way the composed C
  locale is stored can and likely will change later. So the way it is
  essentially a copy of (old) global locale is just a way to be minimally
  intrusive.
  
  Joerg
 
 i care the API.
 
 if you really want it be in libc, how about having libc provide a
 locale_t get_static_c_locale(); style API rather than using NULL?
 it's better because 1) less code in *_l, 2) autoconf-like can detect
 the extension easily, and 3) a portable application can trivially
 have a fallback implementation using newlocale+pthread_once.
 
 It adds more cost on the caller side. So far, there are three mechanisms
 available (especially for libraries):
 
 (1) Adhoc access to internal locale state. This is used with glibc.
 (2) Explicit newlocale().
 (3) Implicit access via 0 argument to *_l.
 
 The first one is clearly a hack and not acceptable. Portable code can
 always conditionally use (2), but it requires additional setup and
 storage cost. (3) is used by Apple (which is where a large part of the
 *_l interface originates from) and FreeBSD. It is orthogonal to (2) and
 certainly easier to use. Exposing it via a special library call is also
 possible and effectively a way to implement (2) by a static wrapper.
 It still adds more cost to every caller and this is a classic case where
 there are typically much more callers.
 
 Joerg

(3) adds small costs to every calls of *_l, even when the extension
is not used.  i sounds worse than a one-time cost of (2) to me.

YAMAMOTO Takashi


Re: CVS commit: src/lib/libc/locale

2013-04-18 Thread Joerg Sonnenberger
On Thu, Apr 18, 2013 at 06:58:42AM +, YAMAMOTO Takashi wrote:
  On Tue, Apr 16, 2013 at 11:34:52PM +, YAMAMOTO Takashi wrote:
   On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
   so that the struct _locale __C_locale in libc is much more wasteful.
   
   I should add that it is an internal detail and the way the composed C
   locale is stored can and likely will change later. So the way it is
   essentially a copy of (old) global locale is just a way to be minimally
   intrusive.
   
   Joerg
  
  i care the API.
  
  if you really want it be in libc, how about having libc provide a
  locale_t get_static_c_locale(); style API rather than using NULL?
  it's better because 1) less code in *_l, 2) autoconf-like can detect
  the extension easily, and 3) a portable application can trivially
  have a fallback implementation using newlocale+pthread_once.
  
  It adds more cost on the caller side. So far, there are three mechanisms
  available (especially for libraries):
  
  (1) Adhoc access to internal locale state. This is used with glibc.
  (2) Explicit newlocale().
  (3) Implicit access via 0 argument to *_l.
  
  The first one is clearly a hack and not acceptable. Portable code can
  always conditionally use (2), but it requires additional setup and
  storage cost. (3) is used by Apple (which is where a large part of the
  *_l interface originates from) and FreeBSD. It is orthogonal to (2) and
  certainly easier to use. Exposing it via a special library call is also
  possible and effectively a way to implement (2) by a static wrapper.
  It still adds more cost to every caller and this is a classic case where
  there are typically much more callers.
  
  Joerg
 
 (3) adds small costs to every calls of *_l, even when the extension
 is not used.  i sounds worse than a one-time cost of (2) to me.

(2) still needs to load the address (instead of a constant), so it isn't
free either. Given that this is very popular as functionality and at
least on modern CPUs often implementable as conditional-move, it sounds
like a much better trade off.

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-18 Thread Richard Hansen
On 2013-04-16 00:55, YAMAMOTO Takashi wrote:
 On Mon, Apr 15, 2013 at 11:40:57PM +0900, Takehiko NOZAKI wrote:
 POSIX2008 spec say, *_l func with invalid locale handle may EINVAL.
 NULL or (locale_t)0 is invalid locale handle.

Note that POSIX Issue 7 TC1 was recently published [1], and there are
some relevant locale fixes.  Specifically, [2] removes the may fail
EINVAL error from *_l(), and adds the following paragraph:

The behavior is undefined if the locale argument to *_l() is the
special locale object LC_GLOBAL_LOCALE or is not a valid locale
object handle.

-Richard

[1] http://article.gmane.org/gmane.comp.standards.posix.austin.general/7004
[2] http://austingroupbugs.net/view.php?id=283


Re: CVS commit: src/lib/libc/locale

2013-04-17 Thread Joerg Sonnenberger
On Tue, Apr 16, 2013 at 11:34:52PM +, YAMAMOTO Takashi wrote:
  On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
  so that the struct _locale __C_locale in libc is much more wasteful.
  
  I should add that it is an internal detail and the way the composed C
  locale is stored can and likely will change later. So the way it is
  essentially a copy of (old) global locale is just a way to be minimally
  intrusive.
  
  Joerg
 
 i care the API.
 
 if you really want it be in libc, how about having libc provide a
 locale_t get_static_c_locale(); style API rather than using NULL?
 it's better because 1) less code in *_l, 2) autoconf-like can detect
 the extension easily, and 3) a portable application can trivially
 have a fallback implementation using newlocale+pthread_once.

It adds more cost on the caller side. So far, there are three mechanisms
available (especially for libraries):

(1) Adhoc access to internal locale state. This is used with glibc.
(2) Explicit newlocale().
(3) Implicit access via 0 argument to *_l.

The first one is clearly a hack and not acceptable. Portable code can
always conditionally use (2), but it requires additional setup and
storage cost. (3) is used by Apple (which is where a large part of the
*_l interface originates from) and FreeBSD. It is orthogonal to (2) and
certainly easier to use. Exposing it via a special library call is also
possible and effectively a way to implement (2) by a static wrapper.
It still adds more cost to every caller and this is a classic case where
there are typically much more callers.

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-16 Thread Joerg Sonnenberger
On Tue, Apr 16, 2013 at 04:55:01AM +, YAMAMOTO Takashi wrote:
 hi,
 
  On Mon, Apr 15, 2013 at 11:40:57PM +0900, Takehiko NOZAKI wrote:
  POSIX2008 spec say, *_l func with invalid locale handle may EINVAL.
  NULL or (locale_t)0 is invalid locale handle.
  why are you think fallback to C locale?
  
  That's what Apple and FreeBSD provide and which is actually quite
  useful. Wanting access to the C locale is the most common case for many
  locale issues. Making that easy sounds like a good idea in general.
 
 is there consumers of this extension in the field?

Yes.

 an application can have a global c_locale = newlocale(C)
 if it wants an easy access to the C locale.

...which means keeping a copy around in various libraries etc.
It is possible, but wastes memory.

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-16 Thread Joerg Sonnenberger
On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
 before implementing such non-portable *broken* stuff.

At the very least it is a conforming extension.

  ...which means keeping a copy around in various libraries etc.
  It is possible, but wastes memory.
 
 most of application in the world doesn't require multi-locale stuff.
 so that the struct _locale __C_locale in libc is much more wasteful.

Most applications can/should enable the user locales. That means that as
soon as they also have to deal with accessing data from non-internalized
sources, they have to deal with both the user and the C locale. The very
same reasoning applies to libraries.

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-16 Thread Joerg Sonnenberger
On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
  That's what Apple and FreeBSD provide and which is actually quite
  useful.
 
 useful? don't say that.
 
 I have heard same word from who spreads broken iconv(3) usage,
 (such as non-portable //TRANSLIT features that annoying pkgsrc peoples).
 http://mail-index.netbsd.org/tech-userlevel/2006/04/03/.html

//TRANSLIT is quite a different deal because it is a workaround for the
bad default behavior of GNU iconv...

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-16 Thread YAMAMOTO Takashi
 On Tue, Apr 16, 2013 at 11:39:50PM +0900, Takehiko NOZAKI wrote:
 so that the struct _locale __C_locale in libc is much more wasteful.
 
 I should add that it is an internal detail and the way the composed C
 locale is stored can and likely will change later. So the way it is
 essentially a copy of (old) global locale is just a way to be minimally
 intrusive.
 
 Joerg

i care the API.

if you really want it be in libc, how about having libc provide a
locale_t get_static_c_locale(); style API rather than using NULL?
it's better because 1) less code in *_l, 2) autoconf-like can detect
the extension easily, and 3) a portable application can trivially
have a fallback implementation using newlocale+pthread_once.

YAMAMOTO Takashi


Re: CVS commit: src/lib/libc/locale

2013-04-15 Thread Takehiko NOZAKI
I can' t understand why this change is needed.

POSIX2008 spec say, *_l func with invalid locale handle may EINVAL.
NULL or (locale_t)0 is invalid locale handle.
why are you think fallback to C locale?

http://pubs.opengroup.org/onlinepubs/9699919799/functions/isalpha.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/nl_langinfo.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/newlocale.html

glibc2(*_l function's origin) does more simpler, they don't check NULL
and cause Segmentation Fault.
I think glibc2 is reasonable, because POSIX2008  does change for the worse.
as far as is*_l functions, return value is non-zero(=matches class) or
zero(=not matches class) only.
we can't know the error from it.


2013/4/15 Joerg Sonnenberger jo...@netbsd.org:
 Module Name:src
 Committed By:   joerg
 Date:   Sun Apr 14 23:44:54 UTC 2013

 Modified Files:
 src/lib/libc/locale: Makefile.inc setlocale_local.h
 Added Files:
 src/lib/libc/locale: c_locale.c

 Log Message:
 Provide a const copy of global_locale for libc-internal use.
 This will be used by *_l when a NULL pointer is given.


 To generate a diff of this commit:
 cvs rdiff -u -r1.60 -r1.61 src/lib/libc/locale/Makefile.inc
 cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/c_locale.c
 cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/setlocale_local.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


--
Takehiko NOZAKItakehiko.noz...@gmail.com


Re: CVS commit: src/lib/libc/locale

2013-04-15 Thread Joerg Sonnenberger
On Mon, Apr 15, 2013 at 11:40:57PM +0900, Takehiko NOZAKI wrote:
 POSIX2008 spec say, *_l func with invalid locale handle may EINVAL.
 NULL or (locale_t)0 is invalid locale handle.
 why are you think fallback to C locale?

That's what Apple and FreeBSD provide and which is actually quite
useful. Wanting access to the C locale is the most common case for many
locale issues. Making that easy sounds like a good idea in general.

Joerg


Re: CVS commit: src/lib/libc/locale

2013-04-15 Thread YAMAMOTO Takashi
hi,

 On Mon, Apr 15, 2013 at 11:40:57PM +0900, Takehiko NOZAKI wrote:
 POSIX2008 spec say, *_l func with invalid locale handle may EINVAL.
 NULL or (locale_t)0 is invalid locale handle.
 why are you think fallback to C locale?
 
 That's what Apple and FreeBSD provide and which is actually quite
 useful. Wanting access to the C locale is the most common case for many
 locale issues. Making that easy sounds like a good idea in general.

is there consumers of this extension in the field?

an application can have a global c_locale = newlocale(C)
if it wants an easy access to the C locale.

YAMAMOTO Takashi

 
 Joerg


CVS commit: src/lib/libc/locale

2013-04-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Apr 14 23:44:54 UTC 2013

Modified Files:
src/lib/libc/locale: Makefile.inc setlocale_local.h
Added Files:
src/lib/libc/locale: c_locale.c

Log Message:
Provide a const copy of global_locale for libc-internal use.
This will be used by *_l when a NULL pointer is given.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/c_locale.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/setlocale_local.h

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/Makefile.inc
diff -u src/lib/libc/locale/Makefile.inc:1.60 src/lib/libc/locale/Makefile.inc:1.61
--- src/lib/libc/locale/Makefile.inc:1.60	Fri Jan 20 16:31:29 2012
+++ src/lib/libc/locale/Makefile.inc	Sun Apr 14 23:44:53 2013
@@ -1,12 +1,12 @@
 #	from: @(#)Makefile.inc	5.1 (Berkeley) 2/18/91
-#	$NetBSD: Makefile.inc,v 1.60 2012/01/20 16:31:29 joerg Exp $
+#	$NetBSD: Makefile.inc,v 1.61 2013/04/14 23:44:53 joerg Exp $
 
 # locale sources
 .PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
 
 SRCS+=	_def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
 	setlocale.c __mb_cur_max.c \
-	current_locale.c global_locale.c fix_grouping.c \
+	current_locale.c c_locale.c global_locale.c fix_grouping.c \
 	localeconv.c nl_langinfo.c \
 	generic_lc_all.c dummy_lc_collate.c \
 	wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \

Index: src/lib/libc/locale/setlocale_local.h
diff -u src/lib/libc/locale/setlocale_local.h:1.10 src/lib/libc/locale/setlocale_local.h:1.11
--- src/lib/libc/locale/setlocale_local.h:1.10	Sun Apr 14 23:30:16 2013
+++ src/lib/libc/locale/setlocale_local.h	Sun Apr 14 23:44:54 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: setlocale_local.h,v 1.10 2013/04/14 23:30:16 joerg Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.11 2013/04/14 23:44:54 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -92,6 +92,7 @@ _current_cache(void)
 }
 
 extern struct _locale	_global_locale;
+extern __dso_hidden struct _locale *_C_locale;
 extern size_t __mb_len_max_runtime;
 
 #endif /*_SETLOCALE_LOCAL_H_*/

Added files:

Index: src/lib/libc/locale/c_locale.c
diff -u /dev/null src/lib/libc/locale/c_locale.c:1.1
--- /dev/null	Sun Apr 14 23:44:54 2013
+++ src/lib/libc/locale/c_locale.c	Sun Apr 14 23:44:54 2013
@@ -0,0 +1,174 @@
+/* $NetBSD: c_locale.c,v 1.1 2013/04/14 23:44:54 joerg Exp $ */
+
+/*-
+ * Copyright (c)2008 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * 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.
+ */
+
+#include sys/cdefs.h
+__RCSID($NetBSD: c_locale.c,v 1.1 2013/04/14 23:44:54 joerg Exp $);
+
+#include sys/types.h
+#include sys/ctype_bits.h
+#include sys/localedef.h
+#include langinfo.h
+#include limits.h
+#define __SETLOCALE_SOURCE__
+#include locale.h
+#include stdlib.h
+
+#include runetype_local.h
+#include setlocale_local.h
+
+#ifndef NBCHAR_MAX
+#define NBCHAR_MAX (char)CHAR_MAX
+#endif
+
+static const struct lconv _C_ldata = {
+	.decimal_point		= __UNCONST(.),
+	.thousands_sep		= __UNCONST(),
+	.grouping		= __UNCONST(),
+	.int_curr_symbol	= __UNCONST(),
+	.currency_symbol	= __UNCONST(),
+	.mon_decimal_point	= __UNCONST(),
+	.mon_thousands_sep	= __UNCONST(),
+	.mon_grouping		= __UNCONST(),
+	.positive_sign		= __UNCONST(),
+	.negative_sign		= __UNCONST(),
+	.int_frac_digits	= NBCHAR_MAX,
+	.frac_digits		= NBCHAR_MAX,
+	.p_cs_precedes		= NBCHAR_MAX,
+	.p_sep_by_space		= NBCHAR_MAX,
+	.n_cs_precedes		= NBCHAR_MAX,
+	.n_sep_by_space		= NBCHAR_MAX,
+	.p_sign_posn		= NBCHAR_MAX,
+	.n_sign_posn		= NBCHAR_MAX,
+	.int_p_cs_precedes	= NBCHAR_MAX,
+	

CVS commit: src/lib/libc/locale

2013-04-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Apr 14 23:44:54 UTC 2013

Modified Files:
src/lib/libc/locale: Makefile.inc setlocale_local.h
Added Files:
src/lib/libc/locale: c_locale.c

Log Message:
Provide a const copy of global_locale for libc-internal use.
This will be used by *_l when a NULL pointer is given.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/c_locale.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/setlocale_local.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2012-08-08 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Wed Aug  8 18:37:26 UTC 2012

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
fix PR lib/46781 statically compiled bash makes locale loading fail.
analyzed and  patch provided by enami@ nonaka@ obache@ soda@, thanks.
patch modified by me.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libc/locale/rune.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/rune.c
diff -u src/lib/libc/locale/rune.c:1.43 src/lib/libc/locale/rune.c:1.44
--- src/lib/libc/locale/rune.c:1.43	Fri Jan 20 16:31:30 2012
+++ src/lib/libc/locale/rune.c	Wed Aug  8 18:37:26 2012
@@ -1,5 +1,3 @@
-/* $NetBSD: rune.c,v 1.43 2012/01/20 16:31:30 joerg Exp $ */
-
 /*-
  * Copyright (c)2010 Citrus Project,
  * All rights reserved.
@@ -162,7 +160,7 @@ _rune_read_file(const char * __restrict 
 
 	variable_len = be32toh((uint32_t)frl-frl_variable_len);
 
-	n = (len * sizeof(*fre)) + variable_len;
+	n = len * sizeof(*fre);
 	if (lenvar  n)
 		return EFTYPE;
 	lenvar -= n;
@@ -219,15 +217,15 @@ do {	\
 	READ_RANGE(maplower);
 	READ_RANGE(mapupper);
 
-	memcpy((void *)rune, (void const *)frune, variable_len);
-	rl-rl_variable_len = variable_len;
-	rl-rl_variable = (void *)rune;
-
-	if (lenvar  0) {
+	if (lenvar  variable_len) {
 		ret = EFTYPE;
 		goto err;
 	}
 
+	memcpy((void *)rune, (void const *)frune, variable_len);
+	rl-rl_variable_len = variable_len;
+	rl-rl_variable = (void *)rune;
+
 	_rune_find_codeset(rlp-rlp_codeset, sizeof(rlp-rlp_codeset),
 	(char *)rl-rl_variable, rl-rl_variable_len);
 



CVS commit: src/lib/libc/locale

2012-08-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Aug  8 20:16:51 UTC 2012

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
Restore RCS Id lost in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libc/locale/rune.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/rune.c
diff -u src/lib/libc/locale/rune.c:1.44 src/lib/libc/locale/rune.c:1.45
--- src/lib/libc/locale/rune.c:1.44	Wed Aug  8 18:37:26 2012
+++ src/lib/libc/locale/rune.c	Wed Aug  8 20:16:50 2012
@@ -1,3 +1,4 @@
+/*	$NetBSD: rune.c,v 1.45 2012/08/08 20:16:50 wiz Exp $	*/
 /*-
  * Copyright (c)2010 Citrus Project,
  * All rights reserved.



CVS commit: src/lib/libc/locale

2012-08-08 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Wed Aug  8 18:37:26 UTC 2012

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
fix PR lib/46781 statically compiled bash makes locale loading fail.
analyzed and  patch provided by enami@ nonaka@ obache@ soda@, thanks.
patch modified by me.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libc/locale/rune.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2012-08-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Aug  8 20:16:51 UTC 2012

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
Restore RCS Id lost in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/lib/libc/locale/rune.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2012-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 21 14:11:24 UTC 2012

Modified Files:
src/lib/libc/locale: fix_grouping.c global_locale.c

Log Message:
cast CHAR_MAX to (char) for unsigned character machines


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/fix_grouping.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/locale/global_locale.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/fix_grouping.c
diff -u src/lib/libc/locale/fix_grouping.c:1.5 src/lib/libc/locale/fix_grouping.c:1.6
--- src/lib/libc/locale/fix_grouping.c:1.5	Tue Jun  1 09:52:08 2010
+++ src/lib/libc/locale/fix_grouping.c	Wed Mar 21 10:11:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $ */
+/* $NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $ */
 
 /*
  * Copyright (c) 2001 Alexey Zelkin phan...@freebsd.org
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $);
+__RCSID($NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include limits.h
@@ -44,7 +44,7 @@ __RCSID($NetBSD: fix_grouping.c,v 1.5 2
 #include fix_grouping.h
 
 #ifndef NBCHAR_MAX
-#define NBCHAR_MAX	CHAR_MAX
+#define NBCHAR_MAX	(char)CHAR_MAX
 #endif
 
 #ifndef __UNCONST

Index: src/lib/libc/locale/global_locale.c
diff -u src/lib/libc/locale/global_locale.c:1.12 src/lib/libc/locale/global_locale.c:1.13
--- src/lib/libc/locale/global_locale.c:1.12	Fri Jan 20 11:31:29 2012
+++ src/lib/libc/locale/global_locale.c	Wed Mar 21 10:11:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.12 2012/01/20 16:31:29 joerg Exp $ */
+/* $NetBSD: global_locale.c,v 1.13 2012/03/21 14:11:24 christos Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: global_locale.c,v 1.12 2012/01/20 16:31:29 joerg Exp $);
+__RCSID($NetBSD: global_locale.c,v 1.13 2012/03/21 14:11:24 christos Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/types.h
@@ -43,6 +43,10 @@ __RCSID($NetBSD: global_locale.c,v 1.12
 #include runetype_local.h
 #include setlocale_local.h
 
+#ifndef NBCHAR_MAX
+#define NBCHAR_MAX (char)CHAR_MAX
+#endif
+
 static struct lconv _global_ldata = {
 	.decimal_point		= __UNCONST(.),
 	.thousands_sep		= __UNCONST(),
@@ -54,20 +58,20 @@ static struct lconv _global_ldata = {
 	.mon_grouping		= __UNCONST(),
 	.positive_sign		= __UNCONST(),
 	.negative_sign		= __UNCONST(),
-	.int_frac_digits	= CHAR_MAX,
-	.frac_digits		= CHAR_MAX,
-	.p_cs_precedes		= CHAR_MAX,
-	.p_sep_by_space		= CHAR_MAX,
-	.n_cs_precedes		= CHAR_MAX,
-	.n_sep_by_space		= CHAR_MAX,
-	.p_sign_posn		= CHAR_MAX,
-	.n_sign_posn		= CHAR_MAX,
-	.int_p_cs_precedes	= CHAR_MAX,
-	.int_n_cs_precedes	= CHAR_MAX,
-	.int_p_sep_by_space	= CHAR_MAX,
-	.int_n_sep_by_space	= CHAR_MAX,
-	.int_p_sign_posn	= CHAR_MAX,
-	.int_n_sign_posn	= CHAR_MAX,
+	.int_frac_digits	= NBCHAR_MAX,
+	.frac_digits		= NBCHAR_MAX,
+	.p_cs_precedes		= NBCHAR_MAX,
+	.p_sep_by_space		= NBCHAR_MAX,
+	.n_cs_precedes		= NBCHAR_MAX,
+	.n_sep_by_space		= NBCHAR_MAX,
+	.p_sign_posn		= NBCHAR_MAX,
+	.n_sign_posn		= NBCHAR_MAX,
+	.int_p_cs_precedes	= NBCHAR_MAX,
+	.int_n_cs_precedes	= NBCHAR_MAX,
+	.int_p_sep_by_space	= NBCHAR_MAX,
+	.int_n_sep_by_space	= NBCHAR_MAX,
+	.int_p_sign_posn	= NBCHAR_MAX,
+	.int_n_sign_posn	= NBCHAR_MAX,
 };
 
 static const char *_global_items[(size_t)ALT_DIGITS + 1] = {



CVS commit: src/lib/libc/locale

2012-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 21 14:11:24 UTC 2012

Modified Files:
src/lib/libc/locale: fix_grouping.c global_locale.c

Log Message:
cast CHAR_MAX to (char) for unsigned character machines


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/fix_grouping.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/locale/global_locale.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2012-01-18 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jan 18 14:22:28 UTC 2012

Modified Files:
src/lib/libc/locale: runetype_misc.h

Log Message:
_runetype_from_ctype is unused


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/runetype_misc.h

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/runetype_misc.h
diff -u src/lib/libc/locale/runetype_misc.h:1.2 src/lib/libc/locale/runetype_misc.h:1.3
--- src/lib/libc/locale/runetype_misc.h:1.2	Tue Dec 14 02:28:57 2010
+++ src/lib/libc/locale/runetype_misc.h	Wed Jan 18 14:22:27 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: runetype_misc.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
+/* $NetBSD: runetype_misc.h,v 1.3 2012/01/18 14:22:27 joerg Exp $ */
 
 /*-
  * Copyright (c) 1993
@@ -79,52 +79,4 @@ _runetype_to_ctype(_RuneType bits)
 	return ret;
 }
 
-static __inline _RuneType
-_runetype_from_ctype(int bits, int ch)
-{
-_RuneType ret;
-
-	/*
-	 * TWEAKS!
-	 * - old locale file declarations do not have proper _B
-	 *   in many cases.
-	 * - isprint() declaration in ctype.h incorrectly uses _B.
-	 *   _B means isprint but !isgraph, not isblank with the
-	 *   declaration.
-	 * - _X and _RUNETYPE_X have negligible difference in meaning.
-	 * - we don't set digit value, fearing that it would be
-	 *   too much of hardcoding.  we may need to revisit it.
-	 */
-
-	ret = (_RuneType)0;
-	if (bits  _CTYPE_U)
-		ret |= _RUNETYPE_U;
-	if (bits  _CTYPE_L)
-		ret |= _RUNETYPE_L;
-	if (bits  _CTYPE_N)
-		ret |= _RUNETYPE_D;
-	if (bits  _CTYPE_S)
-		ret |= _RUNETYPE_S;
-	if (bits  _CTYPE_P)
-		ret |= _RUNETYPE_P;
-	if (bits  _CTYPE_C)
-		ret |= _RUNETYPE_C;
-	/* derived flag bits, duplicate of ctype.h */
-	if (bits  (_CTYPE_U|_CTYPE_L))
-		ret |= _RUNETYPE_A;
-	if (bits  (_CTYPE_N|_CTYPE_X))
-		ret |= _RUNETYPE_X;
-	if (bits  (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N))
-		ret |= _RUNETYPE_G;
-	/* we don't really trust _B in the file.  see above. */
-	if (bits  _CTYPE_B)
-		ret |= _RUNETYPE_B;
-	if ((bits  (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)) ||
-	ch == ' ')
-		ret |= (_RUNETYPE_R | _RUNETYPE_SW1);
-	if (ch == ' ' || ch == '\t')
-		ret |= _RUNETYPE_B;
-	return ret;
-}
-
 #endif	/* !_RUNETYPE_MISC_H_ */



CVS commit: src/lib/libc/locale

2012-01-18 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jan 18 14:22:28 UTC 2012

Modified Files:
src/lib/libc/locale: runetype_misc.h

Log Message:
_runetype_from_ctype is unused


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/runetype_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2011-03-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Mar 25 00:45:24 UTC 2011

Modified Files:
src/lib/libc/locale: bsdctype.c bsdctype_file.h rune.c

Log Message:
Remove support for the old BSDCTYPE format.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/locale/bsdctype.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/locale/bsdctype_file.h
cvs rdiff -u -r1.41 -r1.42 src/lib/libc/locale/rune.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/bsdctype.c
diff -u src/lib/libc/locale/bsdctype.c:1.9 src/lib/libc/locale/bsdctype.c:1.10
--- src/lib/libc/locale/bsdctype.c:1.9	Sun Jun 20 02:23:15 2010
+++ src/lib/libc/locale/bsdctype.c	Fri Mar 25 00:45:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 tnozaki Exp $ */
+/* $NetBSD: bsdctype.c,v 1.10 2011/03/25 00:45:24 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 tnozaki Exp $);
+__RCSID($NetBSD: bsdctype.c,v 1.10 2011/03/25 00:45:24 joerg Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/endian.h
@@ -79,35 +79,6 @@
 }
 
 static __inline int
-_bsdctype_read_file(const char * __restrict var, size_t lenvar,
-_BSDCTypeLocalePriv * __restrict blp)
-{
-	const _FileBSDCTypeLocale *fbl;
-	uint32_t value;
-	int i;
-
-	_DIAGASSERT(blp != NULL);
-
-	if (lenvar  sizeof(*fbl))
-		return EFTYPE;
-	fbl = (const _FileBSDCTypeLocale *)(const void *)var;
-	if (memcmp(fbl-fbl_id[0], _CTYPE_ID, sizeof(fbl-fbl_id)))
-		return EFTYPE;
-	value = be32toh(fbl-fbl_rev);
-	if (value != _CTYPE_REV)
-		return EFTYPE;
-	value = be32toh(fbl-fbl_num_chars);
-	if (value != _CTYPE_CACHE_SIZE)
-		return EFTYPE;
-	for (i = 0; i  _CTYPE_CACHE_SIZE; ++i) {
-		blp-blp_ctype_tab  [i + 1] = fbl-fbl_ctype_tab[i];
-		blp-blp_tolower_tab[i + 1] = be16toh(fbl-fbl_tolower_tab[i]);
-		blp-blp_toupper_tab[i + 1] = be16toh(fbl-fbl_toupper_tab[i]);
-	}
-	return 0;
-}
-
-static __inline int
 _bsdctype_read_runetype(const char * __restrict var, size_t lenvar,
 _BSDCTypeLocalePriv * __restrict blp)
 {
@@ -161,9 +132,6 @@
 		return errno;
 	_bsdctype_init_priv(blp);
 	switch (*var) {
-	case 'B':
-		_bsdctype_read_file(var, lenvar, blp);
-		break;
 	case 'R':
 		_bsdctype_read_runetype(var, lenvar, blp);
 		break;

Index: src/lib/libc/locale/bsdctype_file.h
diff -u src/lib/libc/locale/bsdctype_file.h:1.1 src/lib/libc/locale/bsdctype_file.h:1.2
--- src/lib/libc/locale/bsdctype_file.h:1.1	Sun Jun 13 04:14:57 2010
+++ src/lib/libc/locale/bsdctype_file.h	Fri Mar 25 00:45:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype_file.h,v 1.1 2010/06/13 04:14:57 tnozaki Exp $ */
+/* $NetBSD: bsdctype_file.h,v 1.2 2011/03/25 00:45:24 joerg Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -40,7 +40,6 @@
 	int16_t			fbl_toupper_tab[_CTYPE_CACHE_SIZE];
 } __packed _FileBSDCTypeLocale;
 
-#define _CTYPE_ID		BSDCTYPE
 #define _CTYPE_REV		2
 
 #endif /*_BSDCTYPE_FILE_H_*/

Index: src/lib/libc/locale/rune.c
diff -u src/lib/libc/locale/rune.c:1.41 src/lib/libc/locale/rune.c:1.42
--- src/lib/libc/locale/rune.c:1.41	Tue Nov 30 15:25:05 2010
+++ src/lib/libc/locale/rune.c	Fri Mar 25 00:45:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rune.c,v 1.41 2010/11/30 15:25:05 tnozaki Exp $ */
+/* $NetBSD: rune.c,v 1.42 2011/03/25 00:45:24 joerg Exp $ */
 
 /*-
  * Copyright (c)2010 Citrus Project,
@@ -280,52 +280,6 @@
 	return ret;
 }
 
-static __inline int
-_rune_read_bsdctype(const char * __restrict var, size_t lenvar,
-_RuneLocale ** __restrict prl)
-{
-	const _FileBSDCTypeLocale *fbl;
-	uint32_t value;
-	int i, bits;
-	uint16_t lower, upper;
-	_RuneLocalePriv *rlp;
-	_RuneLocale *rl;
-
-if (lenvar  sizeof(*fbl))
-		return EFTYPE;
-	fbl = (const _FileBSDCTypeLocale *)(const void *)var;
-	if (memcmp(fbl-fbl_id[0], _CTYPE_ID, sizeof(fbl-fbl_id)))
-		return EFTYPE;
-	value = be32toh(fbl-fbl_rev);
-	if (value != _CTYPE_REV)
-		return EFTYPE;
-	value = be32toh(fbl-fbl_num_chars);
-	if (value != _CTYPE_CACHE_SIZE)
-		return EFTYPE;
-	rlp = (_RuneLocalePriv *)malloc(sizeof(*rlp));
-	if (rlp == NULL)
-		return ENOMEM;
-	_rune_init_priv(rlp);
-	rlp-rlp_codeset[0] = '\0';
-
-	rl = rlp-rl;
-	for (i = 0; i  _CTYPE_CACHE_SIZE; ++i) {
-		bits  = fbl-fbl_ctype_tab[i];
-		lower = be16toh(fbl-fbl_tolower_tab[i]);
-		upper = be16toh(fbl-fbl_toupper_tab[i]);
-
-		rlp-rlp_ctype_tab  [i + 1] = (unsigned char)bits;
-		rlp-rlp_tolower_tab[i + 1] = (short)lower;
-		rlp-rlp_toupper_tab[i + 1] = (short)upper;
-
-		rl-rl_runetype[i] = _runetype_from_ctype(bits, i);
-		rl-rl_maplower[i] = (__nbrune_t)lower;
-		rl-rl_mapupper[i] = (__nbrune_t)upper;
-	}
-	*prl = rl;
-	return 0;
-}
-
 int
 _rune_load(const char * __restrict var, size_t lenvar,
 _RuneLocale ** __restrict prl)
@@ -341,9 +295,6 @@
 	case 'R':
 		ret = 

CVS commit: src/lib/libc/locale

2011-03-16 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Wed Mar 16 09:32:12 UTC 2011

Modified Files:
src/lib/libc/locale: mbstowcs.3 wcstombs.3

Log Message:
Crosslink wcstombs(3) and mbstowcs(3).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/locale/mbstowcs.3
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/locale/wcstombs.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/mbstowcs.3
diff -u src/lib/libc/locale/mbstowcs.3:1.11 src/lib/libc/locale/mbstowcs.3:1.12
--- src/lib/libc/locale/mbstowcs.3:1.11	Thu Dec 16 17:42:27 2010
+++ src/lib/libc/locale/mbstowcs.3	Wed Mar 16 09:32:12 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: mbstowcs.3,v 1.11 2010/12/16 17:42:27 wiz Exp $
+.\ $NetBSD: mbstowcs.3,v 1.12 2011/03/16 09:32:12 mbalmer Exp $
 .\
 .\ Copyright (c)2002 Citrus Project,
 .\ All rights reserved.
@@ -24,7 +24,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd February 3, 2002
+.Dd March 16, 2011
 .Dt MBSTOWCS 3
 .Os
 .\ --
@@ -117,7 +117,8 @@
 .\ --
 .Sh SEE ALSO
 .Xr mbtowc 3 ,
-.Xr setlocale 3
+.Xr setlocale 3 ,
+.Xr wcstombs 3
 .\ --
 .Sh STANDARDS
 The

Index: src/lib/libc/locale/wcstombs.3
diff -u src/lib/libc/locale/wcstombs.3:1.12 src/lib/libc/locale/wcstombs.3:1.13
--- src/lib/libc/locale/wcstombs.3:1.12	Thu Dec 16 17:42:27 2010
+++ src/lib/libc/locale/wcstombs.3	Wed Mar 16 09:32:12 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: wcstombs.3,v 1.12 2010/12/16 17:42:27 wiz Exp $
+.\ $NetBSD: wcstombs.3,v 1.13 2011/03/16 09:32:12 mbalmer Exp $
 .\
 .\ Copyright (c)2002 Citrus Project,
 .\ All rights reserved.
@@ -24,7 +24,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd August 8, 2006
+.Dd March 16, 2011
 .Dt WCSTOMBS 3
 .Os
 .\ --
@@ -120,6 +120,7 @@
 .El
 .\ --
 .Sh SEE ALSO
+.Xr mbstowcs 3 ,
 .Xr setlocale 3 ,
 .Xr wctomb 3
 .\ --



CVS commit: src/lib/libc/locale

2011-03-16 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Wed Mar 16 09:32:12 UTC 2011

Modified Files:
src/lib/libc/locale: mbstowcs.3 wcstombs.3

Log Message:
Crosslink wcstombs(3) and mbstowcs(3).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/locale/mbstowcs.3
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/locale/wcstombs.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-11-30 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Tue Nov 30 15:25:05 UTC 2010

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
variable must to be nul terminated before CODESET=foo.
ISO2022 module doesn't understand this and may fail setlocale(3).


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libc/locale/rune.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/rune.c
diff -u src/lib/libc/locale/rune.c:1.40 src/lib/libc/locale/rune.c:1.41
--- src/lib/libc/locale/rune.c:1.40	Sat Jun 19 14:48:16 2010
+++ src/lib/libc/locale/rune.c	Tue Nov 30 15:25:05 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rune.c,v 1.40 2010/06/19 14:48:16 tnozaki Exp $ */
+/* $NetBSD: rune.c,v 1.41 2010/11/30 15:25:05 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2010 Citrus Project,
@@ -107,14 +107,18 @@
 
 static __inline void
 _rune_find_codeset(char *s, size_t n,
-const char *var, size_t lenvar)
+char *var, size_t *plenvar)
 {
+	size_t lenvar;
 	const char *endvar;
 
 #define _RUNE_CODESET_LEN (sizeof(_RUNE_CODESET)-1)
 
+	lenvar = *plenvar;
 	for (/**/; lenvar  _RUNE_CODESET_LEN; ++var, --lenvar) {
 		if (!memcmp(var, _RUNE_CODESET, _RUNE_CODESET_LEN)) {
+			*var = '\0';
+			*plenvar -= lenvar;
 			endvar = var[_RUNE_CODESET_LEN];
 			while (n--  1  lenvar--  _RUNE_CODESET_LEN) {
 if (*endvar == ' ' || *endvar == '\t')
@@ -226,7 +230,7 @@
 	}
 
 	_rune_find_codeset(rlp-rlp_codeset, sizeof(rlp-rlp_codeset),
-	(const char *)rl-rl_variable, rl-rl_variable_len);
+	(char *)rl-rl_variable, rl-rl_variable_len);
 
 	ret = _citrus_ctype_open(rl-rl_citrus_ctype, frl-frl_encoding,
 	rl-rl_variable, rl-rl_variable_len, _PRIVSIZE);



CVS commit: src/lib/libc/locale

2010-11-30 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Tue Nov 30 15:25:05 UTC 2010

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
variable must to be nul terminated before CODESET=foo.
ISO2022 module doesn't understand this and may fail setlocale(3).


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libc/locale/rune.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-06-19 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sun Jun 20 02:23:15 UTC 2010

Modified Files:
src/lib/libc/locale: bsdctype.c runetype_file.h runetype_local.h
Added Files:
src/lib/libc/locale: runetype_misc.h

Log Message:
fix cross build breakage mklocale(1).
move inline finction that uses sys/ctype_bits.h to runetype_misc.h.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/locale/bsdctype.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/runetype_file.h
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/locale/runetype_local.h
cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/runetype_misc.h

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/bsdctype.c
diff -u src/lib/libc/locale/bsdctype.c:1.8 src/lib/libc/locale/bsdctype.c:1.9
--- src/lib/libc/locale/bsdctype.c:1.8	Sat Jun 19 13:26:52 2010
+++ src/lib/libc/locale/bsdctype.c	Sun Jun 20 02:23:15 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype.c,v 1.8 2010/06/19 13:26:52 tnozaki Exp $ */
+/* $NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: bsdctype.c,v 1.8 2010/06/19 13:26:52 tnozaki Exp $);
+__RCSID($NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/endian.h
@@ -41,7 +41,7 @@
 #include unistd.h
 
 #include bsdctype_local.h
-#include runetype_file.h
+#include runetype_misc.h
 
 const _BSDCTypeLocale _DefaultBSDCTypeLocale = {
 _C_ctype_,

Index: src/lib/libc/locale/runetype_file.h
diff -u src/lib/libc/locale/runetype_file.h:1.2 src/lib/libc/locale/runetype_file.h:1.3
--- src/lib/libc/locale/runetype_file.h:1.2	Sat Jun 19 13:26:52 2010
+++ src/lib/libc/locale/runetype_file.h	Sun Jun 20 02:23:15 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: runetype_file.h,v 1.2 2010/06/19 13:26:52 tnozaki Exp $ */
+/* $NetBSD: runetype_file.h,v 1.3 2010/06/20 02:23:15 tnozaki Exp $ */
 
 /*-
  * Copyright (c) 1993
@@ -39,7 +39,6 @@
 
 #include sys/cdefs.h
 #include sys/types.h
-#include sys/ctype_bits.h
 
 #include ctype_local.h
 
@@ -79,93 +78,6 @@
 #define	_RUNETYPE_SW2	UINT32_C(0x8000)	/* 2 width character */
 #define	_RUNETYPE_SW3	UINT32_C(0xc000)	/* 3 width character */
 
-static __inline int
-_runetype_to_ctype(_RuneType bits)
-{
-	int ret;
-
-	if (bits == (_RuneType)0)
-		return 0;
-	ret = 0;
-	if (bits  _RUNETYPE_U)
-		ret |= _U;
-	if (bits  _RUNETYPE_L)
-		ret |= _L;
-	if (bits  _RUNETYPE_D)
-		ret |= _N;
-	if (bits  _RUNETYPE_S)
-		ret |= _S;
-	if (bits  _RUNETYPE_P)
-		ret |= _P;
-	if (bits  _RUNETYPE_C)
-		ret |= _C;
-	if (bits  _RUNETYPE_X)
-		ret |= _X;
-	/*
-	 * TWEAK!  _B has been used incorrectly (or with older
-	 * declaration) in ctype.h isprint() macro.
-	 * _B does not mean isblank, it means isprint  !isgraph.
-	 * the following is okay since isblank() was hardcoded in
-	 * function (i.e. isblank() is inherently locale unfriendly).
-	 */
-#if 1
-	if ((bits  (_RUNETYPE_R | _RUNETYPE_G)) == _RUNETYPE_R)
-		ret |= _B;
-#else
-	if (bits  _RUNETYPE_B)
-		ret |= _B;
-#endif
-	return ret;
-}
-
-static __inline _RuneType
-_runetype_from_ctype(int bits, int ch)
-{
-_RuneType ret;
-
-	/*
-	 * TWEAKS!
-	 * - old locale file declarations do not have proper _B
-	 *   in many cases.
-	 * - isprint() declaration in ctype.h incorrectly uses _B.
-	 *   _B means isprint but !isgraph, not isblank with the
-	 *   declaration.
-	 * - _X and _RUNETYPE_X have negligible difference in meaning.
-	 * - we don't set digit value, fearing that it would be
-	 *   too much of hardcoding.  we may need to revisit it.
-	 */
-
-	ret = (_RuneType)0;
-	if (bits  _U)
-		ret |= _RUNETYPE_U;
-	if (bits  _L)
-		ret |= _RUNETYPE_L;
-	if (bits  _N)
-		ret |= _RUNETYPE_D;
-	if (bits  _S)
-		ret |= _RUNETYPE_S;
-	if (bits  _P)
-		ret |= _RUNETYPE_P;
-	if (bits  _C)
-		ret |= _RUNETYPE_C;
-	/* derived flag bits, duplicate of ctype.h */
-	if (bits  (_U|_L))
-		ret |= _RUNETYPE_A;
-	if (bits  (_N|_X))
-		ret |= _RUNETYPE_X;
-	if (bits  (_P|_U|_L|_N))
-		ret |= _RUNETYPE_G;
-	/* we don't really trust _B in the file.  see above. */
-	if (bits  _B)
-		ret |= _RUNETYPE_B;
-	if ((bits  (_P|_U|_L|_N|_B)) || ch == ' ')
-		ret |= (_RUNETYPE_R | _RUNETYPE_SW1);
-	if (ch == ' ' || ch == '\t')
-		ret |= _RUNETYPE_B;
-	return ret;
-}
-
-
 /*
  * rune file format.  network endian.
  */

Index: src/lib/libc/locale/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.11 src/lib/libc/locale/runetype_local.h:1.12
--- src/lib/libc/locale/runetype_local.h:1.11	Sat Jun 19 13:26:52 2010
+++ src/lib/libc/locale/runetype_local.h	Sun Jun 20 02:23:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.11 2010/06/19 13:26:52 tnozaki Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.12 2010/06/20 02:23:15 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -42,7 

CVS commit: src/lib/libc/locale

2010-06-19 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun 19 14:48:17 UTC 2010

Modified Files:
src/lib/libc/locale: rune.c

Log Message:
null terminate


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/libc/locale/rune.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-06-12 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun 12 18:03:09 UTC 2010

Modified Files:
src/lib/libc/locale: bsdctype.h

Log Message:
s/_CTYPE_NUM_CHARS/_CTYPE_CACHE_SIZE/


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/bsdctype.h

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/bsdctype.h
diff -u src/lib/libc/locale/bsdctype.h:1.4 src/lib/libc/locale/bsdctype.h:1.5
--- src/lib/libc/locale/bsdctype.h:1.4	Tue Jun  1 18:00:28 2010
+++ src/lib/libc/locale/bsdctype.h	Sat Jun 12 18:03:09 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype.h,v 1.4 2010/06/01 18:00:28 tnozaki Exp $ */
+/* $NetBSD: bsdctype.h,v 1.5 2010/06/12 18:03:09 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -35,9 +35,9 @@
 	char			fbl_id[8];
 	uint32_t		fbl_rev;
 	uint32_t		fbl_num_chars;
-	uint8_t			fbl_ctype_tab  [_CTYPE_NUM_CHARS];
-	int16_t			fbl_tolower_tab[_CTYPE_NUM_CHARS];
-	int16_t			fbl_toupper_tab[_CTYPE_NUM_CHARS];
+	uint8_t			fbl_ctype_tab  [_CTYPE_CACHE_SIZE];
+	int16_t			fbl_tolower_tab[_CTYPE_CACHE_SIZE];
+	int16_t			fbl_toupper_tab[_CTYPE_CACHE_SIZE];
 } __packed _FileBSDCTypeLocale;
 
 typedef struct {



CVS commit: src/lib/libc/locale

2010-06-12 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun 12 18:03:09 UTC 2010

Modified Files:
src/lib/libc/locale: bsdctype.h

Log Message:
s/_CTYPE_NUM_CHARS/_CTYPE_CACHE_SIZE/


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/bsdctype.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-06-11 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun 12 05:54:05 UTC 2010

Modified Files:
src/lib/libc/locale: iswctype_mb.c rune.c rune_local.h runeglue.c
runetable.c

Log Message:
stop to renaming _CTYPE_* - _RUNETYPE_*.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/locale/iswctype_mb.c
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/rune_local.h
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/locale/runeglue.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/locale/runetable.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/iswctype_mb.c
diff -u src/lib/libc/locale/iswctype_mb.c:1.9 src/lib/libc/locale/iswctype_mb.c:1.10
--- src/lib/libc/locale/iswctype_mb.c:1.9	Wed Jun  2 15:47:25 2010
+++ src/lib/libc/locale/iswctype_mb.c	Sat Jun 12 05:54:05 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: iswctype_mb.c,v 1.9 2010/06/02 15:47:25 tnozaki Exp $ */
+/* $NetBSD: iswctype_mb.c,v 1.10 2010/06/12 05:54:05 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: iswctype_mb.c,v 1.9 2010/06/02 15:47:25 tnozaki Exp $);
+__RCSID($NetBSD: iswctype_mb.c,v 1.10 2010/06/12 05:54:05 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -156,8 +156,8 @@
 		return 0;
 	rl = _RUNE_LOCALE();
 	x = _runetype_priv(rl, wc);
-	if (x  _CTYPE_R)
-		return ((unsigned)x  _CTYPE_SWM)  _CTYPE_SWS;
+	if (x  _RUNETYPE_R)
+		return ((unsigned)x  _RUNETYPE_SWM)  _RUNETYPE_SWS;
 	return -1;
 }
 
@@ -174,9 +174,9 @@
 	width = 0;
 	while (wn  0  *ws != L'\0') {
 		x = _runetype_priv(rl, *ws);
-		if ((x  _CTYPE_R) == 0)
+		if ((x  _RUNETYPE_R) == 0)
 			return -1;
-		width += ((unsigned)x  _CTYPE_SWM)  _CTYPE_SWS;
+		width += ((unsigned)x  _RUNETYPE_SWM)  _RUNETYPE_SWS;
 		++ws, --wn;
 	}
 	return width;

Index: src/lib/libc/locale/rune.c
diff -u src/lib/libc/locale/rune.c:1.36 src/lib/libc/locale/rune.c:1.37
--- src/lib/libc/locale/rune.c:1.36	Tue Jun  1 13:52:08 2010
+++ src/lib/libc/locale/rune.c	Sat Jun 12 05:54:05 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune.c,v 1.36 2010/06/01 13:52:08 tnozaki Exp $	*/
+/*	$NetBSD: rune.c,v 1.37 2010/06/12 05:54:05 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = @(#)rune.c	8.1 (Berkeley) 6/4/93;
 #else
-__RCSID($NetBSD: rune.c,v 1.36 2010/06/01 13:52:08 tnozaki Exp $);
+__RCSID($NetBSD: rune.c,v 1.37 2010/06/12 05:54:05 tnozaki Exp $);
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -433,37 +433,37 @@
 		 * - isprint() declaration in ctype.h incorrectly uses _B.
 		 *   _B means isprint but !isgraph, not isblank with the
 		 *   declaration.
-		 * - _X and _CTYPE_X have negligible difference in meaning.
+		 * - _X and _RUNETYPE_X have negligible difference in meaning.
 		 * - we don't set digit value, fearing that it would be
 		 *   too much of hardcoding.  we may need to revisit it.
 		 */
 
 		if (new_ctype[1 + x]  _U)
-			rl-rl_runetype[x] |= _CTYPE_U;
+			rl-rl_runetype[x] |= _RUNETYPE_U;
 		if (new_ctype[1 + x]  _L)
-			rl-rl_runetype[x] |= _CTYPE_L;
+			rl-rl_runetype[x] |= _RUNETYPE_L;
 		if (new_ctype[1 + x]  _N)
-			rl-rl_runetype[x] |= _CTYPE_D;
+			rl-rl_runetype[x] |= _RUNETYPE_D;
 		if (new_ctype[1 + x]  _S)
-			rl-rl_runetype[x] |= _CTYPE_S;
+			rl-rl_runetype[x] |= _RUNETYPE_S;
 		if (new_ctype[1 + x]  _P)
-			rl-rl_runetype[x] |= _CTYPE_P;
+			rl-rl_runetype[x] |= _RUNETYPE_P;
 		if (new_ctype[1 + x]  _C)
-			rl-rl_runetype[x] |= _CTYPE_C;
+			rl-rl_runetype[x] |= _RUNETYPE_C;
 		/* derived flag bits, duplicate of ctype.h */
 		if (new_ctype[1 + x]  (_U | _L))
-			rl-rl_runetype[x] |= _CTYPE_A;
+			rl-rl_runetype[x] |= _RUNETYPE_A;
 		if (new_ctype[1 + x]  (_N | _X))
-			rl-rl_runetype[x] |= _CTYPE_X;
+			rl-rl_runetype[x] |= _RUNETYPE_X;
 		if (new_ctype[1 + x]  (_P|_U|_L|_N))
-			rl-rl_runetype[x] |= _CTYPE_G;
+			rl-rl_runetype[x] |= _RUNETYPE_G;
 		/* we don't really trust _B in the file.  see above. */
 		if (new_ctype[1 + x]  _B)
-			rl-rl_runetype[x] |= _CTYPE_B;
+			rl-rl_runetype[x] |= _RUNETYPE_B;
 		if ((new_ctype[1 + x]  (_P|_U|_L|_N|_B)) || x == ' ')
-			rl-rl_runetype[x] |= (_CTYPE_R | _CTYPE_SW1);
+			rl-rl_runetype[x] |= (_RUNETYPE_R | _RUNETYPE_SW1);
 		if (x == ' ' || x == '\t')
-			rl-rl_runetype[x] |= _CTYPE_B;
+			rl-rl_runetype[x] |= _RUNETYPE_B;
 
 		/* XXX may fail on non-8bit encoding only */
 		rl-rl_mapupper[x] = ntohs(new_toupper[1 + x]);

Index: src/lib/libc/locale/rune_local.h
diff -u src/lib/libc/locale/rune_local.h:1.15 src/lib/libc/locale/rune_local.h:1.16
--- src/lib/libc/locale/rune_local.h:1.15	Sat Jun  5 16:37:13 2010
+++ src/lib/libc/locale/rune_local.h	Sat Jun 12 05:54:05 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune_local.h,v 1.15 2010/06/05 16:37:13 tnozaki Exp $	*/
+/*	

CVS commit: src/lib/libc/locale

2010-06-11 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun 12 05:54:05 UTC 2010

Modified Files:
src/lib/libc/locale: iswctype_mb.c rune.c rune_local.h runeglue.c
runetable.c

Log Message:
stop to renaming _CTYPE_* - _RUNETYPE_*.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/locale/iswctype_mb.c
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/rune_local.h
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/locale/runeglue.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/locale/runetable.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/libc/locale

2010-06-06 Thread Izumi Tsutsui
 I was just wondering why this change was made? It seems to be a backwards
 step to me?

If we need exact-width interger we should use uintNN_t
but I don't think exact width is required in locale.

As other guys say we can't assume uint8_t == unsigned char implicitly:
http://cvsweb.NetBSD.org/bsdweb.cgi/src/sys/arch/pdp10/include/Attic/int_types.h?rev=1.4
(though pdp10 has been removed)
---
Izumi Tsutsui


Re: CVS commit: src/lib/libc/locale

2010-06-06 Thread Alan Barrett
On Sun, 06 Jun 2010, Izumi Tsutsui wrote:
 If we need exact-width interger we should use uintNN_t
 but I don't think exact width is required in locale.

The [u]int_leastN_t types may be useful in this sort of code.  For
example, [u]int_least32_t is required to exist, and on a 36-bit machine
it would presumably be a 36-bit type; whereas [u]int32_t would not exist
on a 36-bit machine (because C99 requires the [u]intN_t types to have
exact sizes with no padding bits).

--apb (Alan Barrett)


Re: CVS commit: src/lib/libc/locale

2010-06-06 Thread Takehiko NOZAKI
hi, all

 I was just wondering why this change was made? It seems to be a backwards
 step to me?

my intension is quite paranoia.

changing uint8_t - unsigned char / int16_t - short is because
_ctype_ / _tolower_tab_ / _toupper_tab_ in ctype.h (now splitted
sys/ctype_bits.h)
declared as unsigned char / short.

ctype.h(rev1.29) -- http://tinyurl.com/365ycfq

extern const unsigned char  *_ctype_;
extern const short  *_tolower_tab_;
extern const short  *_toupper_tab_;


but ctypeio.c read them from LC_CTYPE as uint8_t / int16_t and network endian
and directly cast to unsigned char/short.

ctypeio.c(rev1.11) -- http://tinyurl.com/22my4t8

if (fread((void *)ptr, sizeof(uint8_t), len, fp) != len)
...
if (fread((void *)ptr, sizeof(int16_t), len, fp) != len)
...
if (fread((void *)ptr, sizeof(int16_t), len, fp) != len)
...
#if BYTE_ORDER == LITTLE_ENDIAN
for (i = 1; i = len; i++) {
new_toupper[i] = ntohs(new_toupper[i]);
new_tolower[i] = ntohs(new_tolower[i]);
}
#endif
...
data-ctype_tab = (const unsigned char *)new_ctype;
data-toupper_tab = (const short *)new_toupper;
data-tolower_tab = (const short *)new_tolower;

if the case, someone port to the machine that sizeof(unsigned char) !=
sizeof(uint8_t)
or sizeof(short) != sizeof(int16_t), is*/to* function doesn't work correctlly.
# such as NetBSD/pdp10(9bit char), or cray1(64bit char)


 If you ever port to a 36-bit machine, you are going to have to lie and
 define int32_t as 'int' anyway

intN_t is not portable type, these are optimal:

ISO/IEC9899:1999 7.18.1.1

3 These types are optional. However, if an implementation provides
integer types with widths of 8, 16, 32, or 64 bits, no padding bits,
and (for the signed types) that have a two’s complement representation,
it shall define the corresponding typedef names.

NetBSD/pdp10 seems that providing them by using gcc extension
__attribute__((size N)).


 The [u]int_leastN_t types may be useful in this sort of code.

exactly, but it require C99 stdint.h(or sys/types.h).
ctype.h should keep C90 namespace, i'm not willing to include it.


P.S.

i'm now attempting increase _ctype_ bits 8 - 16 before branching netbsd-6.
because these ancient code(delived from 4BSD) have two bugs:

1. _B bit desn't means isblank(3) but isprint(3)  !isgraph(3).
   so we have to provide real isblank bit, but there is no bit space 
left.

2. isprint(3) doesn't recognize some japanese half-width character
   and vietnamese's phonogram character, we have to provide
phonogram bit too.

i'll post patch to tech-userlevel@, this weekend or next week.


very truly yours.
--
Takehiko NOZAKI tnoz...@netbsd.org


Re: CVS commit: src/lib/libc/locale

2010-06-05 Thread Alistair Crooks
Hi Nozaki-san,

On Wed, Jun 02, 2010 at 04:04:52PM +, Takehiko NOZAKI wrote:
 Module Name:  src
 Committed By: tnozaki
 Date: Wed Jun  2 16:04:52 UTC 2010
 
 Modified Files:
   src/lib/libc/locale: bsdctype.c
 
 Log Message:
 uint8_t - unsigned char, int16_t - short.

As ever, thank you for looking after our locale code.

I was just wondering why this change was made? It seems to be a backwards
step to me?

Thanks,
Alistair


Re: CVS commit: src/lib/libc/locale

2010-06-05 Thread David Holland
On Sat, Jun 05, 2010 at 11:53:32PM +0200, Alistair Crooks wrote:
   Module Name:   src
   Committed By:  tnozaki
   Date:  Wed Jun  2 16:04:52 UTC 2010
   
   Modified Files:
  src/lib/libc/locale: bsdctype.c
   
   Log Message:
   uint8_t - unsigned char, int16_t - short.
  
  As ever, thank you for looking after our locale code.
  
  I was just wondering why this change was made? It seems to be a backwards
  step to me?

I looked at it and it appears to me that it's a change to use
non-sized types (that are guaranteed to be large enough) in the
in-memory structures. If we ever do a port to a 36-bit machine or
whatever it's probably desirable.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/lib/libc/locale

2010-06-05 Thread M. Warner Losh
In message: 20100606041254.gb19...@netbsd.org
David Holland dholland-sourcechan...@netbsd.org writes:
: On Sat, Jun 05, 2010 at 11:53:32PM +0200, Alistair Crooks wrote:
:Module Name: src
:Committed By:tnozaki
:Date:Wed Jun  2 16:04:52 UTC 2010
:
:Modified Files:
: src/lib/libc/locale: bsdctype.c
:
:Log Message:
:uint8_t - unsigned char, int16_t - short.
:   
:   As ever, thank you for looking after our locale code.
:   
:   I was just wondering why this change was made? It seems to be a backwards
:   step to me?
: 
: I looked at it and it appears to me that it's a change to use
: non-sized types (that are guaranteed to be large enough) in the
: in-memory structures. If we ever do a port to a 36-bit machine or
: whatever it's probably desirable.

If you ever port to a 36-bit machine, you are going to have to lie and
define int32_t as 'int' anyway

Warner


Re: CVS commit: src/lib/libc/locale

2010-06-05 Thread David Holland
On Sat, Jun 05, 2010 at 11:28:31PM -0600, M. Warner Losh wrote:
  : I looked at it and it appears to me that it's a change to use
  : non-sized types (that are guaranteed to be large enough) in the
  : in-memory structures. If we ever do a port to a 36-bit machine or
  : whatever it's probably desirable.
  
  If you ever port to a 36-bit machine, you are going to have to lie and
  define int32_t as 'int' anyway

Well, maybe... it would be sort of interesting to try, actually.

-- 
David A. Holland
dholl...@netbsd.org


CVS commit: src/lib/libc/locale

2010-06-05 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun  5 16:37:13 UTC 2010

Modified Files:
src/lib/libc/locale: rune_local.h runetype_local.h

Log Message:
remove unused magic.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/locale/rune_local.h
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/locale/runetype_local.h

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/rune_local.h
diff -u src/lib/libc/locale/rune_local.h:1.14 src/lib/libc/locale/rune_local.h:1.15
--- src/lib/libc/locale/rune_local.h:1.14	Sat May 22 13:50:02 2010
+++ src/lib/libc/locale/rune_local.h	Sat Jun  5 16:37:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune_local.h,v 1.14 2010/05/22 13:50:02 tnozaki Exp $	*/
+/*	$NetBSD: rune_local.h,v 1.15 2010/06/05 16:37:13 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 2000 Citrus Project,
@@ -105,7 +105,6 @@
 #define _RuneRange		_NBRuneRange
 #define _RuneLocale		_NBRuneLocale
 #define _RUNE_MAGIC_1		_NB_RUNE_MAGIC_1
-#define _RUNE_MODULE_1		_NB_RUNE_MODULE_1
 #define _RUNE_CODESET		_NB_RUNE_CODESET
 
 /*

Index: src/lib/libc/locale/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.8 src/lib/libc/locale/runetype_local.h:1.9
--- src/lib/libc/locale/runetype_local.h:1.8	Sat May 22 18:15:21 2010
+++ src/lib/libc/locale/runetype_local.h	Sat Jun  5 16:37:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.8 2010/05/22 18:15:21 tnozaki Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.9 2010/06/05 16:37:13 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -218,9 +218,6 @@
 /* magic number for LC_CTYPE (rune)locale declaration */
 #define	_NB_RUNE_MAGIC_1 RuneCT10	/* Indicates version 0 of RuneLocale */
 
-/* magic string for dynamic link module - type should be like LC_CTYPE */
-#define	_NB_RUNE_MODULE_1(type)	RuneModule10. type
-
 /* codeset tag */
 #define _NB_RUNE_CODESET CODESET=
 



CVS commit: src/lib/libc/locale

2010-06-05 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat Jun  5 16:37:13 UTC 2010

Modified Files:
src/lib/libc/locale: rune_local.h runetype_local.h

Log Message:
remove unused magic.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/locale/rune_local.h
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/locale/runetype_local.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-06-02 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Wed Jun  2 15:47:25 UTC 2010

Modified Files:
src/lib/libc/locale: _wctrans.c _wctrans_local.h _wctype.c
_wctype_local.h iswctype_mb.c

Log Message:
remove duplicated towctrans internal function.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/_wctrans.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/locale/_wctrans_local.h \
src/lib/libc/locale/iswctype_mb.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/locale/_wctype.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/_wctype_local.h

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/_wctrans.c
diff -u src/lib/libc/locale/_wctrans.c:1.15 src/lib/libc/locale/_wctrans.c:1.16
--- src/lib/libc/locale/_wctrans.c:1.15	Tue Jun  1 13:52:08 2010
+++ src/lib/libc/locale/_wctrans.c	Wed Jun  2 15:47:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: _wctrans.c,v 1.15 2010/06/01 13:52:08 tnozaki Exp $	*/
+/*	$NetBSD: _wctrans.c,v 1.16 2010/06/02 15:47:25 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -60,7 +60,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: _wctrans.c,v 1.15 2010/06/01 13:52:08 tnozaki Exp $);
+__RCSID($NetBSD: _wctrans.c,v 1.16 2010/06/02 15:47:25 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -77,7 +77,7 @@
  *	translate a character (extended part)
  */
 wint_t
-_towctrans_ext(wint_t c, struct _WCTransEntry *te)
+_towctrans_ext(wint_t c, struct _WCTransEntry const *te)
 {
 	__nbrune_t c0;
 	uint32_t x;

Index: src/lib/libc/locale/_wctrans_local.h
diff -u src/lib/libc/locale/_wctrans_local.h:1.8 src/lib/libc/locale/_wctrans_local.h:1.9
--- src/lib/libc/locale/_wctrans_local.h:1.8	Thu Feb 12 05:00:46 2009
+++ src/lib/libc/locale/_wctrans_local.h	Wed Jun  2 15:47:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: _wctrans_local.h,v 1.8 2009/02/12 05:00:46 lukem Exp $	*/
+/*	$NetBSD: _wctrans_local.h,v 1.9 2010/06/02 15:47:25 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -30,11 +30,11 @@
 #define _WCTRANS_LOCAL_H_
 
 __BEGIN_DECLS
-wint_t	_towctrans_ext(wint_t, _WCTransEntry *);
+wint_t	_towctrans_ext(wint_t, _WCTransEntry const *);
 __END_DECLS
 
 static __inline wint_t
-_towctrans(wint_t c, _WCTransEntry *te)
+_towctrans_priv(wint_t c, _WCTransEntry const *te)
 {
 	return (_RUNE_ISCACHED(c)
 		? (wint_t)te-te_cached[(size_t)c]
Index: src/lib/libc/locale/iswctype_mb.c
diff -u src/lib/libc/locale/iswctype_mb.c:1.8 src/lib/libc/locale/iswctype_mb.c:1.9
--- src/lib/libc/locale/iswctype_mb.c:1.8	Tue Jun  1 13:52:08 2010
+++ src/lib/libc/locale/iswctype_mb.c	Wed Jun  2 15:47:25 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: iswctype_mb.c,v 1.8 2010/06/01 13:52:08 tnozaki Exp $ */
+/* $NetBSD: iswctype_mb.c,v 1.9 2010/06/02 15:47:25 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: iswctype_mb.c,v 1.8 2010/06/01 13:52:08 tnozaki Exp $);
+__RCSID($NetBSD: iswctype_mb.c,v 1.9 2010/06/02 15:47:25 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -82,7 +82,7 @@
 			\
 	rl = _RUNE_LOCALE();\
 	te = rl-rl_wctrans[index];			\
-	return _towctrans_priv(rl, wc, te);		\
+	return _towctrans_priv(wc, te);			\
 }
 _TOWCTRANS_FUNC(upper, _WCTRANS_INDEX_UPPER)
 _TOWCTRANS_FUNC(lower, _WCTRANS_INDEX_LOWER)
@@ -134,16 +134,14 @@
 wint_t
 towctrans(wint_t wc, wctrans_t charmap)
 {
-	_RuneLocale const *rl;
 	_WCTransEntry const *te;
 
 	if (charmap == NULL) {
 		errno = EINVAL;
 		return wc;
 	}
-	rl = _RUNE_LOCALE();
 	te = (_WCTransEntry const *)(void *)charmap;
-	return _towctrans_priv(rl, wc, te);
+	return _towctrans_priv(wc, te);
 }
 
 __weak_alias(wcwidth,_wcwidth)

Index: src/lib/libc/locale/_wctype.c
diff -u src/lib/libc/locale/_wctype.c:1.7 src/lib/libc/locale/_wctype.c:1.8
--- src/lib/libc/locale/_wctype.c:1.7	Tue Jun  1 13:52:08 2010
+++ src/lib/libc/locale/_wctype.c	Wed Jun  2 15:47:25 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: _wctype.c,v 1.7 2010/06/01 13:52:08 tnozaki Exp $ */
+/* $NetBSD: _wctype.c,v 1.8 2010/06/02 15:47:25 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -60,7 +60,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: _wctype.c,v 1.7 2010/06/01 13:52:08 tnozaki Exp $);
+__RCSID($NetBSD: _wctype.c,v 1.8 2010/06/02 15:47:25 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/types.h
@@ -110,37 +110,3 @@
 {
 	return !!(_runetype_priv(rl, wc)  te-te_mask);
 }
-
-wint_t
-/*ARGSUSED*/
-_towctrans_priv(_RuneLocale const *rl,
-wint_t wc, _WCTransEntry const *te)
-{
-	__nbrune_t wc0;
-	_RuneRange *rr;
-	_RuneEntry *base, *re;
-	uint32_t x;
-
-	_DIAGASSERT(rl != NULL);
-	_DIAGASSERT(te != NULL);
-
-	if (wc == WEOF)
-		return wc;
-	_DIAGASSERT(te-te_name != NULL);
-	if 

CVS commit: src/lib/libc/locale

2010-06-02 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Wed Jun  2 16:04:52 UTC 2010

Modified Files:
src/lib/libc/locale: bsdctype.c

Log Message:
uint8_t - unsigned char, int16_t - short.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/bsdctype.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/bsdctype.c
diff -u src/lib/libc/locale/bsdctype.c:1.5 src/lib/libc/locale/bsdctype.c:1.6
--- src/lib/libc/locale/bsdctype.c:1.5	Tue Jun  1 18:00:28 2010
+++ src/lib/libc/locale/bsdctype.c	Wed Jun  2 16:04:52 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype.c,v 1.5 2010/06/01 18:00:28 tnozaki Exp $ */
+/* $NetBSD: bsdctype.c,v 1.6 2010/06/02 16:04:52 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: bsdctype.c,v 1.5 2010/06/01 18:00:28 tnozaki Exp $);
+__RCSID($NetBSD: bsdctype.c,v 1.6 2010/06/02 16:04:52 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/stat.h
@@ -52,18 +52,18 @@
 const _BSDCTypeLocale *_CurrentBSDCTypeLocale = _DefaultBSDCTypeLocale;
 
 typedef struct {
-	_BSDCTypeLocale bl;
-	uint8_t blp_ctype_tab  [_CTYPE_NUM_CHARS + 1];
-	int16_t blp_tolower_tab[_CTYPE_NUM_CHARS + 1];
-	int16_t blp_toupper_tab[_CTYPE_NUM_CHARS + 1];
+	_BSDCTypeLocale	bl;
+	unsigned char	blp_ctype_tab  [_CTYPE_NUM_CHARS + 1];
+	short		blp_tolower_tab[_CTYPE_NUM_CHARS + 1];
+	short		blp_toupper_tab[_CTYPE_NUM_CHARS + 1];
 } _BSDCTypeLocalePriv;
 
 static __inline void
 _bsdctype_init_priv(_BSDCTypeLocalePriv *blp)
 {
-	blp-blp_ctype_tab  [0] = (uint8_t)0;
-	blp-blp_tolower_tab[0] = (int16_t)EOF;
-	blp-blp_toupper_tab[0] = (int16_t)EOF;
+	blp-blp_ctype_tab  [0] = 0;
+	blp-blp_tolower_tab[0] = EOF;
+	blp-blp_toupper_tab[0] = EOF;
 	blp-bl.bl_ctype_tab   = blp-blp_ctype_tab  [0];
 	blp-bl.bl_tolower_tab = blp-blp_tolower_tab[0];
 	blp-bl.bl_toupper_tab = blp-blp_toupper_tab[0];



CVS commit: src/lib/libc/locale

2010-06-02 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Wed Jun  2 16:04:52 UTC 2010

Modified Files:
src/lib/libc/locale: bsdctype.c

Log Message:
uint8_t - unsigned char, int16_t - short.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/bsdctype.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-06-01 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Tue Jun  1 18:00:28 UTC 2010

Modified Files:
src/lib/libc/locale: Makefile.inc bsdctype.c bsdctype.h iswctype_sb.c
localeio_lc_ctype.c
Removed Files:
src/lib/libc/locale: ctypeio.c ctypeio.h

Log Message:
refactoring old locale-db(BSDCTYPE) loading method with mmap(2).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/bsdctype.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/bsdctype.h \
src/lib/libc/locale/localeio_lc_ctype.c
cvs rdiff -u -r1.13 -r0 src/lib/libc/locale/ctypeio.c
cvs rdiff -u -r1.4 -r0 src/lib/libc/locale/ctypeio.h
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/iswctype_sb.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/Makefile.inc
diff -u src/lib/libc/locale/Makefile.inc:1.55 src/lib/libc/locale/Makefile.inc:1.56
--- src/lib/libc/locale/Makefile.inc:1.55	Sun May 30 08:28:53 2010
+++ src/lib/libc/locale/Makefile.inc	Tue Jun  1 18:00:28 2010
@@ -1,5 +1,5 @@
 #	from: @(#)Makefile.inc	5.1 (Berkeley) 2/18/91
-#	$NetBSD: Makefile.inc,v 1.55 2010/05/30 08:28:53 tnozaki Exp $
+#	$NetBSD: Makefile.inc,v 1.56 2010/06/01 18:00:28 tnozaki Exp $
 
 # locale sources
 .PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
@@ -29,7 +29,7 @@
 SRCS+=	aliasname.c bsdctype.c localeio.c \
 	multibyte_sb.c iswctype_sb.c \
 	localeio_lc_ctype.c localeio_lc_monetary.c \
-	localeio_lc_numeric.c localeio_lc_time.c
+	localeio_lc_numeric.c localeio_lc_time.c localeio_lc_messages.c
 .endif
 
 MAN+=	setlocale.3 nl_langinfo.3

Index: src/lib/libc/locale/bsdctype.c
diff -u src/lib/libc/locale/bsdctype.c:1.4 src/lib/libc/locale/bsdctype.c:1.5
--- src/lib/libc/locale/bsdctype.c:1.4	Sun May 30 08:28:53 2010
+++ src/lib/libc/locale/bsdctype.c	Tue Jun  1 18:00:28 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype.c,v 1.4 2010/05/30 08:28:53 tnozaki Exp $ */
+/* $NetBSD: bsdctype.c,v 1.5 2010/06/01 18:00:28 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,9 +28,19 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: bsdctype.c,v 1.4 2010/05/30 08:28:53 tnozaki Exp $);
+__RCSID($NetBSD: bsdctype.c,v 1.5 2010/06/01 18:00:28 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
+#include sys/stat.h
+#include sys/mman.h
+#include assert.h
+#include errno.h
+#include fcntl.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+
 #include bsdctype.h
 
 const _BSDCTypeLocale _DefaultBSDCTypeLocale = {
@@ -40,3 +50,130 @@
 };
 
 const _BSDCTypeLocale *_CurrentBSDCTypeLocale = _DefaultBSDCTypeLocale;
+
+typedef struct {
+	_BSDCTypeLocale bl;
+	uint8_t blp_ctype_tab  [_CTYPE_NUM_CHARS + 1];
+	int16_t blp_tolower_tab[_CTYPE_NUM_CHARS + 1];
+	int16_t blp_toupper_tab[_CTYPE_NUM_CHARS + 1];
+} _BSDCTypeLocalePriv;
+
+static __inline void
+_bsdctype_init_priv(_BSDCTypeLocalePriv *blp)
+{
+	blp-blp_ctype_tab  [0] = (uint8_t)0;
+	blp-blp_tolower_tab[0] = (int16_t)EOF;
+	blp-blp_toupper_tab[0] = (int16_t)EOF;
+	blp-bl.bl_ctype_tab   = blp-blp_ctype_tab  [0];
+	blp-bl.bl_tolower_tab = blp-blp_tolower_tab[0];
+	blp-bl.bl_toupper_tab = blp-blp_toupper_tab[0];
+}
+
+static __inline int
+_bsdctype_read_file(const char * __restrict var, size_t lenvar,
+_BSDCTypeLocalePriv * __restrict blp)
+{
+	const _FileBSDCTypeLocale *fbl;
+	uint32_t value;
+	int i;
+
+	if (lenvar  sizeof(*fbl))
+		return EFTYPE;
+	fbl = (const _FileBSDCTypeLocale *)(const void *)var;
+	if (memcmp(fbl-fbl_id[0], _CTYPE_ID, sizeof(fbl-fbl_id)))
+		return EFTYPE;
+	value = ntohl(fbl-fbl_rev);
+	if (value != _CTYPE_REV)
+		return EFTYPE;
+	value = ntohl(fbl-fbl_num_chars);
+	if (value != _CTYPE_CACHE_SIZE)
+		return EFTYPE;
+	for (i = 0; i  _CTYPE_CACHE_SIZE; ++i) {
+		blp-blp_ctype_tab  [i + 1] = fbl-fbl_ctype_tab[i];
+		blp-blp_tolower_tab[i + 1] = ntohs(fbl-fbl_tolower_tab[i]);
+		blp-blp_toupper_tab[i + 1] = ntohs(fbl-fbl_toupper_tab[i]);
+	}
+#if _CTYPE_CACHE_SIZE != _CTYPE_NUM_CHARS
+	for (i = _CTYPE_CACHE_SIZE; i  _CTYPE_NUM_CHARS; ++i) {
+		blp-blp_ctype_tab  [i + 1] = 0;
+		blp-blp_tolower_tab[i + 1] = i;
+		blp-blp_toupper_tab[i + 1] = i;
+	}
+#endif
+	return 0;
+}
+
+static __inline int
+_bsdctype_load_priv(const char * __restrict path,
+_BSDCTypeLocalePriv * __restrict blp)
+{
+	int fd, ret;
+	struct stat st;
+	size_t lenvar;
+	char *var;
+
+	fd = open(path, O_RDONLY);
+	if (fd == -1)
+		goto err;
+	if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
+		goto err;
+	if (fstat(fd, st) == -1)
+		goto err;
+	if (!S_ISREG(st.st_mode)) {
+		close(fd);
+		return EBADF;
+	}
+	lenvar = (size_t)st.st_size;
+	if (lenvar  1) {
+		close(fd);
+		return EFTYPE;
+	}
+	var = mmap(NULL, lenvar, PROT_READ,
+	MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
+	if (var == MAP_FAILED)
+		goto err;
+	if (close(fd) == -1) {
+		ret = errno;
+		munmap(var, 

CVS commit: src/lib/libc/locale

2010-06-01 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Tue Jun  1 18:00:28 UTC 2010

Modified Files:
src/lib/libc/locale: Makefile.inc bsdctype.c bsdctype.h iswctype_sb.c
localeio_lc_ctype.c
Removed Files:
src/lib/libc/locale: ctypeio.c ctypeio.h

Log Message:
refactoring old locale-db(BSDCTYPE) loading method with mmap(2).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/lib/libc/locale/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/bsdctype.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/bsdctype.h \
src/lib/libc/locale/localeio_lc_ctype.c
cvs rdiff -u -r1.13 -r0 src/lib/libc/locale/ctypeio.c
cvs rdiff -u -r1.4 -r0 src/lib/libc/locale/ctypeio.h
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/iswctype_sb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-05-30 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sun May 30 11:36:12 UTC 2010

Modified Files:
src/lib/libc/locale: ctype_local.h

Log Message:
remove redundant guard.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/ctype_local.h

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/ctype_local.h
diff -u src/lib/libc/locale/ctype_local.h:1.2 src/lib/libc/locale/ctype_local.h:1.3
--- src/lib/libc/locale/ctype_local.h:1.2	Sat May 22 18:15:21 2010
+++ src/lib/libc/locale/ctype_local.h	Sun May 30 11:36:12 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: ctype_local.h,v 1.2 2010/05/22 18:15:21 tnozaki Exp $ */
+/* $NetBSD: ctype_local.h,v 1.3 2010/05/30 11:36:12 tnozaki Exp $ */
 
 /*-
  * Copyright (c) 2010 Citrus Project,
@@ -40,8 +40,4 @@
 extern const short _C_toupper_[];
 extern const short _C_tolower_[];
 
-#endif
-#ifndef _CTYPE_LOCAL_H_
-#define _CTYPE_LOCAL_H_
-
 #endif /*_CTYPE_LOCAL_H_*/



CVS commit: src/lib/libc/locale

2010-05-22 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat May 22 13:50:02 UTC 2010

Modified Files:
src/lib/libc/locale: rune_local.h setlocale1.c setlocale32.c
setlocale_local.h

Log Message:
move __mb_len_max_runtime from rune_local.h - setlocale_local.h.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/locale/rune_local.h
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/setlocale1.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/setlocale32.c \
src/lib/libc/locale/setlocale_local.h

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/rune_local.h
diff -u src/lib/libc/locale/rune_local.h:1.13 src/lib/libc/locale/rune_local.h:1.14
--- src/lib/libc/locale/rune_local.h:1.13	Sat May 22 07:18:43 2010
+++ src/lib/libc/locale/rune_local.h	Sat May 22 13:50:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune_local.h,v 1.13 2010/05/22 07:18:43 tnozaki Exp $	*/
+/*	$NetBSD: rune_local.h,v 1.14 2010/05/22 13:50:02 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 2000 Citrus Project,
@@ -111,9 +111,6 @@
 /*
  * global variables
  */
-extern size_t __mb_len_max_runtime;
-#define __MB_LEN_MAX_RUNTIME	__mb_len_max_runtime
-
 extern const _RuneLocale _DefaultRuneLocale;
 extern const _RuneLocale *_CurrentRuneLocale;
 

Index: src/lib/libc/locale/setlocale1.c
diff -u src/lib/libc/locale/setlocale1.c:1.3 src/lib/libc/locale/setlocale1.c:1.4
--- src/lib/libc/locale/setlocale1.c:1.3	Sat May 22 07:18:43 2010
+++ src/lib/libc/locale/setlocale1.c	Sat May 22 13:50:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: setlocale1.c,v 1.3 2010/05/22 07:18:43 tnozaki Exp $	*/
+/*	$NetBSD: setlocale1.c,v 1.4 2010/05/22 13:50:02 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -28,12 +28,14 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: setlocale1.c,v 1.3 2010/05/22 07:18:43 tnozaki Exp $);
+__RCSID($NetBSD: setlocale1.c,v 1.4 2010/05/22 13:50:02 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
+#include sys/types.h
 #define __SETLOCALE_SOURCE__
 #include locale.h
+#include setlocale_local.h
 #include rune_local.h
 
 __warn_references(setlocale,

Index: src/lib/libc/locale/setlocale32.c
diff -u src/lib/libc/locale/setlocale32.c:1.5 src/lib/libc/locale/setlocale32.c:1.6
--- src/lib/libc/locale/setlocale32.c:1.5	Sat May 22 07:18:43 2010
+++ src/lib/libc/locale/setlocale32.c	Sat May 22 13:50:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: setlocale32.c,v 1.5 2010/05/22 07:18:43 tnozaki Exp $	*/
+/*	$NetBSD: setlocale32.c,v 1.6 2010/05/22 13:50:02 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -28,13 +28,15 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: setlocale32.c,v 1.5 2010/05/22 07:18:43 tnozaki Exp $);
+__RCSID($NetBSD: setlocale32.c,v 1.6 2010/05/22 13:50:02 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
+#include sys/types.h
 #define __SETLOCALE_SOURCE__
 #include locale.h
 #include limits.h
+#include setlocale_local.h
 #include rune_local.h
 
 char *
Index: src/lib/libc/locale/setlocale_local.h
diff -u src/lib/libc/locale/setlocale_local.h:1.5 src/lib/libc/locale/setlocale_local.h:1.6
--- src/lib/libc/locale/setlocale_local.h:1.5	Sat May 22 13:15:59 2010
+++ src/lib/libc/locale/setlocale_local.h	Sat May 22 13:50:02 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: setlocale_local.h,v 1.5 2010/05/22 13:15:59 tnozaki Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.6 2010/05/22 13:50:02 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -77,4 +77,7 @@
 	return (*_current_locale())-cache;
 }
 
+extern size_t __mb_len_max_runtime;
+#define __MB_LEN_MAX_RUNTIME	__mb_len_max_runtime
+
 #endif /*_SETLOCALE_LOCAL_H_*/



CVS commit: src/lib/libc/locale

2010-05-22 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat May 22 17:47:25 UTC 2010

Modified Files:
src/lib/libc/locale: runetype_local.h

Log Message:
fix cross build breakage under linux box, reported by Andreas Gustafsson, 
thanks!

runetype_local.h: don't include ctype_local.h when toolchain build.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/locale/runetype_local.h

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/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.6 src/lib/libc/locale/runetype_local.h:1.7
--- src/lib/libc/locale/runetype_local.h:1.6	Sat May 22 06:38:15 2010
+++ src/lib/libc/locale/runetype_local.h	Sat May 22 17:47:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.6 2010/05/22 06:38:15 tnozaki Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.7 2010/05/22 17:47:25 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -39,7 +39,12 @@
 
 #include sys/cdefs.h
 #include sys/types.h
+
+#ifdef HAVE_NBTOOL_CONFIG_H
+#define _CTYPE_CACHE_SIZE	(1  8)
+#else
 #include ctype_local.h
+#endif
 
 /* for cross host tools on older systems */
 #ifndef UINT32_C



CVS commit: src/lib/libc/locale

2010-05-22 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat May 22 13:50:02 UTC 2010

Modified Files:
src/lib/libc/locale: rune_local.h setlocale1.c setlocale32.c
setlocale_local.h

Log Message:
move __mb_len_max_runtime from rune_local.h - setlocale_local.h.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/locale/rune_local.h
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/setlocale1.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/setlocale32.c \
src/lib/libc/locale/setlocale_local.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-05-22 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sat May 22 17:47:25 UTC 2010

Modified Files:
src/lib/libc/locale: runetype_local.h

Log Message:
fix cross build breakage under linux box, reported by Andreas Gustafsson, 
thanks!

runetype_local.h: don't include ctype_local.h when toolchain build.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/locale/runetype_local.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-03-28 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sun Mar 28 14:05:09 UTC 2010

Modified Files:
src/lib/libc/locale: setlocale32.c

Log Message:
avoid mbrtowc/wcrtomb buffer overrun when CPUARCH=hppa and MB_CUR_MAX  6.
it is not usual case(merely used such mutibyte locale, eg. ja_JP.ISO-2022-JP).

[background]
before merging minoura-xpg4dl branch(2001), we argued and decided to increase
MB_LEN_MAX 1 - 32 all CPUARCH(*but* we forgot to change it MD to MI).

without knowing that NetBSD/hp700(mergeing -current 2002) incorrectly set
MB_LEN_MAX=6 (maybe this value taken from FreeBSD). but our setlocale(3)
assumes __mb_len_max_runtime as 32, so that mbrtowc/wcrtomb may overrun.

we have to increase hppa's MB_LEN_MAX upto 32, and change it MD to MI
next libc major bump(scheduled next release 6.0).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/setlocale32.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/setlocale32.c
diff -u src/lib/libc/locale/setlocale32.c:1.2 src/lib/libc/locale/setlocale32.c:1.3
--- src/lib/libc/locale/setlocale32.c:1.2	Tue Mar 11 17:23:07 2003
+++ src/lib/libc/locale/setlocale32.c	Sun Mar 28 14:05:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: setlocale32.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $	*/
+/*	$NetBSD: setlocale32.c,v 1.3 2010/03/28 14:05:09 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: setlocale32.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $);
+__RCSID($NetBSD: setlocale32.c,v 1.3 2010/03/28 14:05:09 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
@@ -44,6 +44,6 @@
 
 	/* locale may be NULL */
 
-	__mb_len_max_runtime = 32;
+	__mb_len_max_runtime = MB_LEN_MAX;
 	return __setlocale(category, locale);
 }



CVS commit: src/lib/libc/locale

2010-03-28 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sun Mar 28 18:19:52 UTC 2010

Modified Files:
src/lib/libc/locale: setlocale32.c

Log Message:
woops, fogot to include limits.h.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/setlocale32.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/setlocale32.c
diff -u src/lib/libc/locale/setlocale32.c:1.3 src/lib/libc/locale/setlocale32.c:1.4
--- src/lib/libc/locale/setlocale32.c:1.3	Sun Mar 28 14:05:09 2010
+++ src/lib/libc/locale/setlocale32.c	Sun Mar 28 18:19:52 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: setlocale32.c,v 1.3 2010/03/28 14:05:09 tnozaki Exp $	*/
+/*	$NetBSD: setlocale32.c,v 1.4 2010/03/28 18:19:52 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -28,12 +28,13 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: setlocale32.c,v 1.3 2010/03/28 14:05:09 tnozaki Exp $);
+__RCSID($NetBSD: setlocale32.c,v 1.4 2010/03/28 18:19:52 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include namespace.h
 #define __SETLOCALE_SOURCE__
 #include locale.h
+#include limits.h
 #include rune.h
 
 char *



CVS commit: src/lib/libc/locale

2010-01-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jan 17 23:12:30 UTC 2010

Modified Files:
src/lib/libc/locale: ctypeio.c

Log Message:
Close file handles in error cases. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/ctypeio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/libc/locale

2010-01-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jan 17 23:12:30 UTC 2010

Modified Files:
src/lib/libc/locale: ctypeio.c

Log Message:
Close file handles in error cases. Found by cppcheck.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/locale/ctypeio.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/ctypeio.c
diff -u src/lib/libc/locale/ctypeio.c:1.10 src/lib/libc/locale/ctypeio.c:1.11
--- src/lib/libc/locale/ctypeio.c:1.10	Wed Oct 21 01:07:45 2009
+++ src/lib/libc/locale/ctypeio.c	Sun Jan 17 23:12:30 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: ctypeio.c,v 1.10 2009/10/21 01:07:45 snj Exp $ */
+/* $NetBSD: ctypeio.c,v 1.11 2010/01/17 23:12:30 wiz Exp $ */
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -26,7 +26,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: ctypeio.c,v 1.10 2009/10/21 01:07:45 snj Exp $);
+__RCSID($NetBSD: ctypeio.c,v 1.11 2010/01/17 23:12:30 wiz Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/types.h
@@ -74,8 +74,10 @@
 
 	ptr = malloc(sizeof(*data) + ((sizeof(uint8_t) +
 	sizeof(int16_t) + sizeof(int16_t)) * (len + 1)));
-	if (ptr == NULL)
+	if (ptr == NULL) {
+		fclose(fp);
 		return ENOMEM;
+	}
 
 	data = (_BSDCTypeLocale *)(void *)ptr;
 	ptr += sizeof(*data);
@@ -117,5 +119,6 @@
 bad1:
 	free(data);
 bad0:
+	fclose(fp);
 	return EFTYPE;
 }



CVS commit: src/lib/libc/locale

2009-12-14 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Tue Dec 15 00:35:36 UTC 2009

Modified Files:
src/lib/libc/locale: nl_langinfo.3

Log Message:
Put space after comma in the C code example.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/locale/nl_langinfo.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/nl_langinfo.3
diff -u src/lib/libc/locale/nl_langinfo.3:1.17 src/lib/libc/locale/nl_langinfo.3:1.18
--- src/lib/libc/locale/nl_langinfo.3:1.17	Thu Mar 12 12:50:31 2009
+++ src/lib/libc/locale/nl_langinfo.3	Tue Dec 15 00:35:36 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: nl_langinfo.3,v 1.17 2009/03/12 12:50:31 joerg Exp $
+.\	$NetBSD: nl_langinfo.3,v 1.18 2009/12/15 00:35:36 enami Exp $
 .\
 .\ Written by J.T. Conklin j...@netbsd.org.
 .\ Public domain.
@@ -113,7 +113,7 @@
 	(void)setlocale(LC_ALL, );
 	ptr = nl_langinfo(D_T_FMT);
 	strftime(datestring, sizeof(datestring), ptr, tm);
-	printf(%s\en,datestring);
+	printf(%s\en, datestring);
 	return (0);
 }
 .Ed



CVS commit: src/lib/libc/locale

2009-12-02 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Wed Dec  2 08:53:03 UTC 2009

Modified Files:
src/lib/libc/locale: setlocale_local.h

Log Message:
struct _locale_time_t _global_locale is a datum.  Declare it as extern.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/setlocale_local.h

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_local.h
diff -u src/lib/libc/locale/setlocale_local.h:1.2 src/lib/libc/locale/setlocale_local.h:1.3
--- src/lib/libc/locale/setlocale_local.h:1.2	Sun Jan 11 02:46:29 2009
+++ src/lib/libc/locale/setlocale_local.h	Wed Dec  2 08:53:03 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: setlocale_local.h,v 1.2 2009/01/11 02:46:29 christos Exp $ */
+/* $NetBSD: setlocale_local.h,v 1.3 2009/12/02 08:53:03 uebayasi Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -67,7 +67,7 @@
 __BEGIN_DECLS
 _locale_category_t	*_find_category(int);
 const char		*_get_locale_env(const char *);
-struct _locale_impl_t	_global_locale;
+extern struct _locale_impl_t	_global_locale;
 struct _locale_impl_t	**_current_locale(void);
 __END_DECLS
 



CVS commit: src/lib/libc/locale

2009-11-09 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Mon Nov  9 14:17:47 UTC 2009

Modified Files:
src/lib/libc/locale: runetype_local.h

Log Message:
change _RUNTYPE_SW0 bit, mklocale(1) can't treat SWIDTH0 correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/runetype_local.h

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/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.2 src/lib/libc/locale/runetype_local.h:1.3
--- src/lib/libc/locale/runetype_local.h:1.2	Sun Jan 11 02:46:29 2009
+++ src/lib/libc/locale/runetype_local.h	Mon Nov  9 14:17:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.2 2009/01/11 02:46:29 christos Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.3 2009/11/09 14:17:47 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -39,6 +39,7 @@
 
 #include sys/cdefs.h
 #include sys/types.h
+#include ctype.h
 
 /* for cross host tools on older systems */
 #ifndef UINT32_C
@@ -54,27 +55,60 @@
 
 #define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)
 
+/* XXX FIXME */
+#if defined(__NetBSD__)  defined(_CTYPE_A)
+#define _NB_CTYPE_A	_CTYPE_A
+#define _NB_CTYPE_C	_CTYPE_C
+#define _NB_CTYPE_D	_CTYPE_D
+#define _NB_CTYPE_G	_CTYPE_G
+#define _NB_CTYPE_L	_CTYPE_L
+#define _NB_CTYPE_P	_CTYPE_P
+#define _NB_CTYPE_S	_CTYPE_S
+#define _NB_CTYPE_U	_CTYPE_U
+#define _NB_CTYPE_X	_CTYPE_X
+#define _NB_CTYPE_B	_CTYPE_B
+#define _NB_CTYPE_R	_CTYPE_R
+#define _NB_CTYPE_I	_CTYPE_I
+#define _NB_CTYPE_T	_CTYPE_T
+#define _NB_CTYPE_Q	_CTYPE_Q
+#else
+#define _NB_CTYPE_A	0x0001
+#define _NB_CTYPE_C	0x0002
+#define _NB_CTYPE_D	0x0004
+#define _NB_CTYPE_G	0x0008
+#define _NB_CTYPE_L	0x0010
+#define _NB_CTYPE_P	0x0020
+#define _NB_CTYPE_S	0x0040
+#define _NB_CTYPE_U	0x0080
+#define _NB_CTYPE_X	0x0100
+#define _NB_CTYPE_B	0x0200
+#define _NB_CTYPE_R	0x0400
+#define _NB_CTYPE_I	0x0800
+#define _NB_CTYPE_T	0x1000
+#define _NB_CTYPE_Q	0x2000
+#endif
+
 /*
  * The lower 8 bits of runetype[] contain the digit value of the rune.
  */
 typedef uint32_t _RuneType;
-#define	_RUNETYPE_A	UINT32_C(0x0100)	/* Alpha */
-#define	_RUNETYPE_C	UINT32_C(0x0200)	/* Control */
-#define	_RUNETYPE_D	UINT32_C(0x0400)	/* Digit */
-#define	_RUNETYPE_G	UINT32_C(0x0800)	/* Graph */
-#define	_RUNETYPE_L	UINT32_C(0x1000)	/* Lower */
-#define	_RUNETYPE_P	UINT32_C(0x2000)	/* Punct */
-#define	_RUNETYPE_S	UINT32_C(0x4000)	/* Space */
-#define	_RUNETYPE_U	UINT32_C(0x8000)	/* Upper */
-#define	_RUNETYPE_X	UINT32_C(0x0001)	/* X digit */
-#define	_RUNETYPE_B	UINT32_C(0x0002)	/* Blank */
-#define	_RUNETYPE_R	UINT32_C(0x0004)	/* Print */
-#define	_RUNETYPE_I	UINT32_C(0x0008)	/* Ideogram */
-#define	_RUNETYPE_T	UINT32_C(0x0010)	/* Special */
-#define	_RUNETYPE_Q	UINT32_C(0x0020)	/* Phonogram */
+#define	_RUNETYPE_A	UINT32_C(_NB_CTYPE_A  8) /* Alpha */
+#define	_RUNETYPE_C	UINT32_C(_NB_CTYPE_C  8) /* Control */
+#define	_RUNETYPE_D	UINT32_C(_NB_CTYPE_D  8) /* Digit */
+#define	_RUNETYPE_G	UINT32_C(_NB_CTYPE_G  8) /* Graph */
+#define	_RUNETYPE_L	UINT32_C(_NB_CTYPE_L  8) /* Lower */
+#define	_RUNETYPE_P	UINT32_C(_NB_CTYPE_P  8) /* Punct */
+#define	_RUNETYPE_S	UINT32_C(_NB_CTYPE_S  8) /* Space */
+#define	_RUNETYPE_U	UINT32_C(_NB_CTYPE_U  8) /* Upper */
+#define	_RUNETYPE_X	UINT32_C(_NB_CTYPE_X  8) /* X digit */
+#define	_RUNETYPE_B	UINT32_C(_NB_CTYPE_B  8) /* Blank */
+#define	_RUNETYPE_R	UINT32_C(_NB_CTYPE_R  8) /* Print */
+#define	_RUNETYPE_I	UINT32_C(_NB_CTYPE_I  8) /* Ideogram */
+#define	_RUNETYPE_T	UINT32_C(_NB_CTYPE_T  8) /* Special */
+#define	_RUNETYPE_Q	UINT32_C(_NB_CTYPE_Q  8) /* Phonogram */
 #define	_RUNETYPE_SWM	UINT32_C(0xc000)/* Mask to get screen width data */
 #define	_RUNETYPE_SWS	30		/* Bits to shift to get width */
-#define	_RUNETYPE_SW0	UINT32_C(0x)	/* 0 width character */
+#define	_RUNETYPE_SW0	UINT32_C(0x2000)	/* 0 width character */
 #define	_RUNETYPE_SW1	UINT32_C(0x4000)	/* 1 width character */
 #define	_RUNETYPE_SW2	UINT32_C(0x8000)	/* 2 width character */
 #define	_RUNETYPE_SW3	UINT32_C(0xc000)	/* 3 width character */
@@ -208,9 +242,16 @@
 	_WCTransEntry			rl_wctrans[_WCTRANS_NINDEXES];
 	_WCTypeEntry			rl_wctype[_WCTYPE_NINDEXES];
 
+#if defined(__LIBC13_SOURCE__)
+	const unsigned short		*rl_ctype_tab;
+#else
 	const unsigned char		*rl_ctype_tab;
+#endif
 	const short			*rl_tolower_tab;
 	const short			*rl_toupper_tab;
+#if !defined(__LIBC13_SOURCE__)
+	const unsigned short		*rl_ctype50_tab;
+#endif
 } _NBRuneLocale;
 
 



CVS commit: src/lib/libc/locale

2009-11-09 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Mon Nov  9 14:20:49 UTC 2009

Modified Files:
src/lib/libc/locale: runetype_local.h

Log Message:
revert previous change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/runetype_local.h

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/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.3 src/lib/libc/locale/runetype_local.h:1.4
--- src/lib/libc/locale/runetype_local.h:1.3	Mon Nov  9 14:17:47 2009
+++ src/lib/libc/locale/runetype_local.h	Mon Nov  9 14:20:49 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.3 2009/11/09 14:17:47 tnozaki Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.4 2009/11/09 14:20:49 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -39,7 +39,6 @@
 
 #include sys/cdefs.h
 #include sys/types.h
-#include ctype.h
 
 /* for cross host tools on older systems */
 #ifndef UINT32_C
@@ -55,60 +54,27 @@
 
 #define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)
 
-/* XXX FIXME */
-#if defined(__NetBSD__)  defined(_CTYPE_A)
-#define _NB_CTYPE_A	_CTYPE_A
-#define _NB_CTYPE_C	_CTYPE_C
-#define _NB_CTYPE_D	_CTYPE_D
-#define _NB_CTYPE_G	_CTYPE_G
-#define _NB_CTYPE_L	_CTYPE_L
-#define _NB_CTYPE_P	_CTYPE_P
-#define _NB_CTYPE_S	_CTYPE_S
-#define _NB_CTYPE_U	_CTYPE_U
-#define _NB_CTYPE_X	_CTYPE_X
-#define _NB_CTYPE_B	_CTYPE_B
-#define _NB_CTYPE_R	_CTYPE_R
-#define _NB_CTYPE_I	_CTYPE_I
-#define _NB_CTYPE_T	_CTYPE_T
-#define _NB_CTYPE_Q	_CTYPE_Q
-#else
-#define _NB_CTYPE_A	0x0001
-#define _NB_CTYPE_C	0x0002
-#define _NB_CTYPE_D	0x0004
-#define _NB_CTYPE_G	0x0008
-#define _NB_CTYPE_L	0x0010
-#define _NB_CTYPE_P	0x0020
-#define _NB_CTYPE_S	0x0040
-#define _NB_CTYPE_U	0x0080
-#define _NB_CTYPE_X	0x0100
-#define _NB_CTYPE_B	0x0200
-#define _NB_CTYPE_R	0x0400
-#define _NB_CTYPE_I	0x0800
-#define _NB_CTYPE_T	0x1000
-#define _NB_CTYPE_Q	0x2000
-#endif
-
 /*
  * The lower 8 bits of runetype[] contain the digit value of the rune.
  */
 typedef uint32_t _RuneType;
-#define	_RUNETYPE_A	UINT32_C(_NB_CTYPE_A  8) /* Alpha */
-#define	_RUNETYPE_C	UINT32_C(_NB_CTYPE_C  8) /* Control */
-#define	_RUNETYPE_D	UINT32_C(_NB_CTYPE_D  8) /* Digit */
-#define	_RUNETYPE_G	UINT32_C(_NB_CTYPE_G  8) /* Graph */
-#define	_RUNETYPE_L	UINT32_C(_NB_CTYPE_L  8) /* Lower */
-#define	_RUNETYPE_P	UINT32_C(_NB_CTYPE_P  8) /* Punct */
-#define	_RUNETYPE_S	UINT32_C(_NB_CTYPE_S  8) /* Space */
-#define	_RUNETYPE_U	UINT32_C(_NB_CTYPE_U  8) /* Upper */
-#define	_RUNETYPE_X	UINT32_C(_NB_CTYPE_X  8) /* X digit */
-#define	_RUNETYPE_B	UINT32_C(_NB_CTYPE_B  8) /* Blank */
-#define	_RUNETYPE_R	UINT32_C(_NB_CTYPE_R  8) /* Print */
-#define	_RUNETYPE_I	UINT32_C(_NB_CTYPE_I  8) /* Ideogram */
-#define	_RUNETYPE_T	UINT32_C(_NB_CTYPE_T  8) /* Special */
-#define	_RUNETYPE_Q	UINT32_C(_NB_CTYPE_Q  8) /* Phonogram */
+#define	_RUNETYPE_A	UINT32_C(0x0100)	/* Alpha */
+#define	_RUNETYPE_C	UINT32_C(0x0200)	/* Control */
+#define	_RUNETYPE_D	UINT32_C(0x0400)	/* Digit */
+#define	_RUNETYPE_G	UINT32_C(0x0800)	/* Graph */
+#define	_RUNETYPE_L	UINT32_C(0x1000)	/* Lower */
+#define	_RUNETYPE_P	UINT32_C(0x2000)	/* Punct */
+#define	_RUNETYPE_S	UINT32_C(0x4000)	/* Space */
+#define	_RUNETYPE_U	UINT32_C(0x8000)	/* Upper */
+#define	_RUNETYPE_X	UINT32_C(0x0001)	/* X digit */
+#define	_RUNETYPE_B	UINT32_C(0x0002)	/* Blank */
+#define	_RUNETYPE_R	UINT32_C(0x0004)	/* Print */
+#define	_RUNETYPE_I	UINT32_C(0x0008)	/* Ideogram */
+#define	_RUNETYPE_T	UINT32_C(0x0010)	/* Special */
+#define	_RUNETYPE_Q	UINT32_C(0x0020)	/* Phonogram */
 #define	_RUNETYPE_SWM	UINT32_C(0xc000)/* Mask to get screen width data */
 #define	_RUNETYPE_SWS	30		/* Bits to shift to get width */
-#define	_RUNETYPE_SW0	UINT32_C(0x2000)	/* 0 width character */
+#define	_RUNETYPE_SW0	UINT32_C(0x)	/* 0 width character */
 #define	_RUNETYPE_SW1	UINT32_C(0x4000)	/* 1 width character */
 #define	_RUNETYPE_SW2	UINT32_C(0x8000)	/* 2 width character */
 #define	_RUNETYPE_SW3	UINT32_C(0xc000)	/* 3 width character */
@@ -242,16 +208,9 @@
 	_WCTransEntry			rl_wctrans[_WCTRANS_NINDEXES];
 	_WCTypeEntry			rl_wctype[_WCTYPE_NINDEXES];
 
-#if defined(__LIBC13_SOURCE__)
-	const unsigned short		*rl_ctype_tab;
-#else
 	const unsigned char		*rl_ctype_tab;
-#endif
 	const short			*rl_tolower_tab;
 	const short			*rl_toupper_tab;
-#if !defined(__LIBC13_SOURCE__)
-	const unsigned short		*rl_ctype50_tab;
-#endif
 } _NBRuneLocale;
 
 



CVS commit: src/lib/libc/locale

2009-11-09 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Mon Nov  9 14:22:31 UTC 2009

Modified Files:
src/lib/libc/locale: runetype_local.h

Log Message:
redo: change _RUNTYPE_SW0 bit, mklocale(1) can't treat SWIDTH0 correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/locale/runetype_local.h

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/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.4 src/lib/libc/locale/runetype_local.h:1.5
--- src/lib/libc/locale/runetype_local.h:1.4	Mon Nov  9 14:20:49 2009
+++ src/lib/libc/locale/runetype_local.h	Mon Nov  9 14:22:31 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.4 2009/11/09 14:20:49 tnozaki Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.5 2009/11/09 14:22:31 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -74,7 +74,7 @@
 #define	_RUNETYPE_Q	UINT32_C(0x0020)	/* Phonogram */
 #define	_RUNETYPE_SWM	UINT32_C(0xc000)/* Mask to get screen width data */
 #define	_RUNETYPE_SWS	30		/* Bits to shift to get width */
-#define	_RUNETYPE_SW0	UINT32_C(0x)	/* 0 width character */
+#define	_RUNETYPE_SW0	UINT32_C(0x2000)	/* 0 width character */
 #define	_RUNETYPE_SW1	UINT32_C(0x4000)	/* 1 width character */
 #define	_RUNETYPE_SW2	UINT32_C(0x8000)	/* 2 width character */
 #define	_RUNETYPE_SW3	UINT32_C(0xc000)	/* 3 width character */



CVS commit: src/lib/libc/locale

2009-10-04 Thread Takehiko NOZAKI
Module Name:src
Committed By:   tnozaki
Date:   Sun Oct  4 21:05:18 UTC 2009

Modified Files:
src/lib/libc/locale: generic_lc_all.c

Log Message:
fix lib/42124: setlocale(3) never returns NULL with none existing locale.
reported by kambe-san, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/generic_lc_all.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/generic_lc_all.c
diff -u src/lib/libc/locale/generic_lc_all.c:1.2 src/lib/libc/locale/generic_lc_all.c:1.3
--- src/lib/libc/locale/generic_lc_all.c:1.2	Sun Jan 11 02:46:28 2009
+++ src/lib/libc/locale/generic_lc_all.c	Sun Oct  4 21:05:18 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: generic_lc_all.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: generic_lc_all.c,v 1.2 2009/01/11 02:46:28 christos Exp $);
+__RCSID($NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $);
 #endif /* LIBC_SCCS and not lint */
 
 #include sys/types.h
@@ -56,10 +56,11 @@
 	_locale_category_t *l;
 	char head[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)], *tail;
 	const char *tokens[_LC_LAST], *s, *t;
-	int i, j;
+	int load_locale_success, i, j;
 
 	l = _find_category(1);
 	_DIAGASSERT(l != NULL);
+	load_locale_success = 0;
 	if (name != NULL) {
 		strlcpy(head[0], name, sizeof(head));
 		tokens[1] = head[0];
@@ -78,10 +79,11 @@
 			}
 			tokens[_LC_LAST - 1] = (const char *)tail;
 			tail = strchr(tokens[i], '/');
-			if (tail == NULL)
+			if (tail != NULL)
 return NULL;
 		}
-		(*l-setlocale)(tokens[1], locale);
+		if ((*l-setlocale)(tokens[1], locale) != NULL)
+			load_locale_success = 1;
 	}
 	s = (*l-setlocale)(NULL, locale);
 	_DIAGASSERT(s != NULL);
@@ -89,8 +91,10 @@
 	for (i = 2, j = 0; i  _LC_LAST; ++i) {
 		l = _find_category(i);
 		_DIAGASSERT(l != NULL);
-		if (name != NULL)
-			(*l-setlocale)(tokens[1], locale);
+		if (name != NULL) {
+			if ((*l-setlocale)(tokens[i], locale) != NULL)
+load_locale_success = 1;
+		}
 		t = (*l-setlocale)(NULL, locale);
 		_DIAGASSERT(t != NULL);
 		if (j == 0) {
@@ -106,6 +110,8 @@
 		strlcat(locale-query[0], /, sizeof(locale-query));
 		strlcat(locale-query[0], t, sizeof(locale-query));
 	}
+	if (name != NULL  !load_locale_success)
+		return NULL;
 	return (const char *)locale-query[0];
 }
 



  1   2   >