Module Name:    src
Committed By:   tnozaki
Date:           Sat May 22 06:38:16 UTC 2010

Modified Files:
        src/include: ctype.h
        src/lib/libc/gen: Makefile.inc ctype_.c tolower_.c toupper_.c
        src/lib/libc/locale: bsdctype.c ctypeio.c global_locale.c rune.c rune.h
            runeglue.c runetable.c runetype_local.h
        src/usr.bin/mklocale: ldef.h yacc.y
        src/usr.sbin/chrtbl: Makefile ctypeio.c
Added Files:
        src/lib/libc/locale: ctype_local.h

Log Message:
1. hide _CTYPE_PRIVATE section in ctype.h, move them to private header 
ctype_local.h.
2. do not use _CTYPE_NUM_CHARS macro to read data from LC_CTYPE(old BSDCTYPE 
style) database.
   because 1<<CHAR_BIT is MD, so i added MI macro _CTYPE_CACHE_SIZE(1<<8).
3. remove _NB_CACHED_RUNE macro, use _CTYPE_CACHE_SIZE instead.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/include/ctype.h
cvs rdiff -u -r1.169 -r1.170 src/lib/libc/gen/Makefile.inc
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/gen/ctype_.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/tolower_.c \
    src/lib/libc/gen/toupper_.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/locale/bsdctype.c
cvs rdiff -u -r0 -r1.1 src/lib/libc/locale/ctype_local.h
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/locale/ctypeio.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/locale/global_locale.c \
    src/lib/libc/locale/runetype_local.h
cvs rdiff -u -r1.33 -r1.34 src/lib/libc/locale/rune.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/locale/rune.h
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/locale/runeglue.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/locale/runetable.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/mklocale/ldef.h
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/mklocale/yacc.y
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/chrtbl/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/chrtbl/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/include/ctype.h
diff -u src/include/ctype.h:1.29 src/include/ctype.h:1.30
--- src/include/ctype.h:1.29	Mon Dec 26 19:01:47 2005
+++ src/include/ctype.h	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctype.h,v 1.29 2005/12/26 19:01:47 perry Exp $	*/
+/*	$NetBSD: ctype.h,v 1.30 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*
  * Copyright (c) 1989 The Regents of the University of California.
@@ -118,17 +118,4 @@
 
 #endif
 
-#ifdef _CTYPE_PRIVATE
-#include <machine/limits.h>	/* for CHAR_BIT */
-
-#define _CTYPE_NUM_CHARS	(1 << CHAR_BIT)
-
-#define _CTYPE_ID	 	"BSDCTYPE"
-#define _CTYPE_REV		2
-
-extern const uint8_t _C_ctype_[];
-extern const int16_t _C_toupper_[];
-extern const int16_t _C_tolower_[];
-#endif
-
 #endif /* !_CTYPE_H_ */

Index: src/lib/libc/gen/Makefile.inc
diff -u src/lib/libc/gen/Makefile.inc:1.169 src/lib/libc/gen/Makefile.inc:1.170
--- src/lib/libc/gen/Makefile.inc:1.169	Thu May 13 17:48:50 2010
+++ src/lib/libc/gen/Makefile.inc	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.169 2010/05/13 17:48:50 jruoho Exp $
+#	$NetBSD: Makefile.inc,v 1.170 2010/05/22 06:38:15 tnozaki Exp $
 #	from: @(#)Makefile.inc	8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -158,4 +158,7 @@
 MLINKS+=vis.3 svis.3 vis.3 strvis.3 vis.3 strvisx.3 vis.3 strsvis.3 \
 	vis.3 strsvisx.3
 
+CPPFLAGS.ctype_.c+=	-I${LIBCDIR}/locale
 CPPFLAGS.isctype.c+=	-I${LIBCDIR}/locale
+CPPFLAGS.tolower_.c+=	-I${LIBCDIR}/locale
+CPPFLAGS.toupper_.c+=	-I${LIBCDIR}/locale

Index: src/lib/libc/gen/ctype_.c
diff -u src/lib/libc/gen/ctype_.c:1.16 src/lib/libc/gen/ctype_.c:1.17
--- src/lib/libc/gen/ctype_.c:1.16	Thu Aug  7 16:42:46 2003
+++ src/lib/libc/gen/ctype_.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctype_.c,v 1.16 2003/08/07 16:42:46 agc Exp $	*/
+/*	$NetBSD: ctype_.c,v 1.17 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*
  * Copyright (c) 1989 The Regents of the University of California.
@@ -39,15 +39,17 @@
 #if 0
 /*static char *sccsid = "from: @(#)ctype_.c	5.6 (Berkeley) 6/1/90";*/
 #else
-__RCSID("$NetBSD: ctype_.c,v 1.16 2003/08/07 16:42:46 agc Exp $");
+__RCSID("$NetBSD: ctype_.c,v 1.17 2010/05/22 06:38:15 tnozaki Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
-#define _CTYPE_PRIVATE
-
-#include <sys/types.h>
-#include <limits.h>
 #include <ctype.h>
+#include <stdio.h>
+#include "ctype_local.h"
+
+#if EOF != -1
+#error "EOF != -1"
+#endif
 
 const unsigned char _C_ctype_[1 + _CTYPE_NUM_CHARS] = {
 	0,
@@ -69,4 +71,4 @@
 	_L,	_L,	_L,	_P,	_P,	_P,	_P,	_C
 };
 
-const unsigned char *_ctype_ = _C_ctype_;
+const unsigned char *_ctype_ = &_C_ctype_[0];

Index: src/lib/libc/gen/tolower_.c
diff -u src/lib/libc/gen/tolower_.c:1.11 src/lib/libc/gen/tolower_.c:1.12
--- src/lib/libc/gen/tolower_.c:1.11	Sun Jan 11 02:46:27 2009
+++ src/lib/libc/gen/tolower_.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: tolower_.c,v 1.11 2009/01/11 02:46:27 christos Exp $	*/
+/*	$NetBSD: tolower_.c,v 1.12 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*
  * Written by J.T. Conklin <j...@netbsd.org>.
@@ -7,17 +7,18 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_RCS) && !defined(lint)
-__RCSID("$NetBSD: tolower_.c,v 1.11 2009/01/11 02:46:27 christos Exp $");
+__RCSID("$NetBSD: tolower_.c,v 1.12 2010/05/22 06:38:15 tnozaki Exp $");
 #endif /* LIBC_RCS and not lint */
 
-#include <stdio.h>
 #include <ctype.h>
+#include <stdio.h>
+#include "ctype_local.h"
 
 #if EOF != -1
 #error "EOF != -1"
 #endif
 
-const short _C_tolower_[1 + 256] = {
+const short _C_tolower_[1 + _CTYPE_NUM_CHARS] = {
 	EOF,
 	0x00,	0x01,	0x02,	0x03,	0x04,	0x05,	0x06,	0x07,
 	0x08,	0x09,	0x0a,	0x0b,	0x0c,	0x0d,	0x0e,	0x0f,
@@ -53,4 +54,4 @@
 	0xf8,	0xf9,	0xfa,	0xfb,	0xfc,	0xfd,	0xfe,	0xff
 };
 
-const short *_tolower_tab_ = _C_tolower_;
+const short *_tolower_tab_ = &_C_tolower_[0];
Index: src/lib/libc/gen/toupper_.c
diff -u src/lib/libc/gen/toupper_.c:1.11 src/lib/libc/gen/toupper_.c:1.12
--- src/lib/libc/gen/toupper_.c:1.11	Sun Jan 11 02:46:27 2009
+++ src/lib/libc/gen/toupper_.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: toupper_.c,v 1.11 2009/01/11 02:46:27 christos Exp $	*/
+/*	$NetBSD: toupper_.c,v 1.12 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*
  * Written by J.T. Conklin <j...@netbsd.org>.
@@ -7,17 +7,18 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_RCS) && !defined(lint)
-__RCSID("$NetBSD: toupper_.c,v 1.11 2009/01/11 02:46:27 christos Exp $");
+__RCSID("$NetBSD: toupper_.c,v 1.12 2010/05/22 06:38:15 tnozaki Exp $");
 #endif /* LIBC_RCS and not lint */
 
-#include <stdio.h>
 #include <ctype.h>
+#include <stdio.h>
+#include "ctype_local.h"
 
 #if EOF != -1
 #error "EOF != -1"
 #endif
 
-const short _C_toupper_[1 + 256] = {
+const short _C_toupper_[1 + _CTYPE_NUM_CHARS] = {
 	EOF,
 	0x00,	0x01,	0x02,	0x03,	0x04,	0x05,	0x06,	0x07,
 	0x08,	0x09,	0x0a,	0x0b,	0x0c,	0x0d,	0x0e,	0x0f,
@@ -53,4 +54,4 @@
 	0xf8,	0xf9,	0xfa,	0xfb,	0xfc,	0xfd,	0xfe,	0xff
 };
 
-const short *_toupper_tab_ = _C_toupper_;
+const short *_toupper_tab_ = &_C_toupper_[0];

Index: src/lib/libc/locale/bsdctype.c
diff -u src/lib/libc/locale/bsdctype.c:1.2 src/lib/libc/locale/bsdctype.c:1.3
--- src/lib/libc/locale/bsdctype.c:1.2	Sun Jan 11 02:46:28 2009
+++ src/lib/libc/locale/bsdctype.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: bsdctype.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: bsdctype.c,v 1.3 2010/05/22 06:38:15 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,11 +28,10 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: bsdctype.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
+__RCSID("$NetBSD: bsdctype.c,v 1.3 2010/05/22 06:38:15 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
-#define _CTYPE_PRIVATE
 #include <ctype.h>
 
 #include "bsdctype.h"

Index: src/lib/libc/locale/ctypeio.c
diff -u src/lib/libc/locale/ctypeio.c:1.11 src/lib/libc/locale/ctypeio.c:1.12
--- src/lib/libc/locale/ctypeio.c:1.11	Sun Jan 17 23:12:30 2010
+++ src/lib/libc/locale/ctypeio.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: ctypeio.c,v 1.11 2010/01/17 23:12:30 wiz Exp $ */
+/* $NetBSD: ctypeio.c,v 1.12 2010/05/22 06:38:15 tnozaki Exp $ */
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -26,12 +26,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ctypeio.c,v 1.11 2010/01/17 23:12:30 wiz Exp $");
+__RCSID("$NetBSD: ctypeio.c,v 1.12 2010/05/22 06:38:15 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #include <assert.h>
-#define _CTYPE_PRIVATE
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
@@ -69,11 +68,11 @@
 		goto bad0;
 
 	if (fread(&len, sizeof(uint32_t), 1, fp) != 1 ||
-	    (len = ntohl(len)) != _CTYPE_NUM_CHARS)
+	    (len = ntohl(len)) != _CTYPE_CACHE_SIZE)
 		goto bad0;
 
 	ptr = malloc(sizeof(*data) + ((sizeof(uint8_t) +
-	    sizeof(int16_t) + sizeof(int16_t)) * (len + 1)));
+	    sizeof(int16_t) + sizeof(int16_t)) * (_CTYPE_NUM_CHARS + 1)));
 	if (ptr == NULL) {
 		fclose(fp);
 		return ENOMEM;
@@ -86,13 +85,13 @@
 	ptr += sizeof(uint8_t);
 	if (fread((void *)ptr, sizeof(uint8_t), len, fp) != len)
 		goto bad1;
-	ptr += sizeof(uint8_t) * len;
+	ptr += sizeof(uint8_t) * _CTYPE_NUM_CHARS;
 
 	(new_toupper = (void *)ptr)[0] = (int16_t)EOF;
 	ptr += sizeof(int16_t);
 	if (fread((void *)ptr, sizeof(int16_t), len, fp) != len)
 		goto bad1;
-	ptr += sizeof(int16_t) * len;
+	ptr += sizeof(int16_t) * _CTYPE_NUM_CHARS;
 
 	(new_tolower = (void *)ptr)[0] = (int16_t)EOF;
 	ptr += sizeof(int16_t);
@@ -105,6 +104,11 @@
 		new_tolower[i] = ntohs(new_tolower[i]);
 	}
 #endif
+	for (i = _CTYPE_CACHE_SIZE + 1; i <= _CTYPE_NUM_CHARS; i++) {
+		new_ctype[i] = 0;
+		new_toupper[i] = i;
+		new_tolower[i] = i;
+	}
 
 	fclose(fp);
 

Index: src/lib/libc/locale/global_locale.c
diff -u src/lib/libc/locale/global_locale.c:1.5 src/lib/libc/locale/global_locale.c:1.6
--- src/lib/libc/locale/global_locale.c:1.5	Sat Mar 27 16:47:05 2010
+++ src/lib/libc/locale/global_locale.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: global_locale.c,v 1.5 2010/03/27 16:47:05 christos Exp $ */
+/* $NetBSD: global_locale.c,v 1.6 2010/05/22 06:38:15 tnozaki Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,12 +28,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: global_locale.c,v 1.5 2010/03/27 16:47:05 christos Exp $");
+__RCSID("$NetBSD: global_locale.c,v 1.6 2010/05/22 06:38:15 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #include <sys/localedef.h>
-#define _CTYPE_PRIVATE
 #include <ctype.h>
 #include <langinfo.h>
 #include <limits.h>
Index: src/lib/libc/locale/runetype_local.h
diff -u src/lib/libc/locale/runetype_local.h:1.5 src/lib/libc/locale/runetype_local.h:1.6
--- src/lib/libc/locale/runetype_local.h:1.5	Mon Nov  9 14:22:31 2009
+++ src/lib/libc/locale/runetype_local.h	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetype_local.h,v 1.5 2009/11/09 14:22:31 tnozaki Exp $	*/
+/*	$NetBSD: runetype_local.h,v 1.6 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -39,6 +39,7 @@
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
+#include "ctype_local.h"
 
 /* for cross host tools on older systems */
 #ifndef UINT32_C
@@ -49,8 +50,7 @@
 typedef uint32_t	__nbrune_t;
 typedef uint64_t	__runepad_t;
 
-#define	_NB_CACHED_RUNES	(1 << 8)	/* Must be a power of 2 */
-#define _NB_RUNE_ISCACHED(c)	((c)>=0 && (c)<_CACHED_RUNES)
+#define _NB_RUNE_ISCACHED(c)	((c)>=0 && (c)<_CTYPE_CACHE_SIZE)
 
 #define _NB_DEFAULT_INVALID_RUNE ((__nbrune_t)-3)
 
@@ -108,12 +108,12 @@
 	int32_t		frl_invalid_rune;
 	uint32_t	frl_pad3;	/* backward compatibility */
 
-	_RuneType	frl_runetype[_NB_CACHED_RUNES];
-	int32_t		frl_maplower[_NB_CACHED_RUNES];
-	int32_t		frl_mapupper[_NB_CACHED_RUNES];
+	_RuneType	frl_runetype[_CTYPE_CACHE_SIZE];
+	int32_t		frl_maplower[_CTYPE_CACHE_SIZE];
+	int32_t		frl_mapupper[_CTYPE_CACHE_SIZE];
 
 	/*
-	 * The following are to deal with Runes larger than _CACHED_RUNES - 1.
+	 * The following are to deal with Runes larger than _CTYPE_CACHE_SIZE - 1.
 	 * Their data is actually contiguous with this structure so as to make
 	 * it easier to read/write from/to disk.
 	 */
@@ -190,9 +190,9 @@
 	char		rl_magic[8];	/* Magic saying what version we are */
 	char		rl_encoding[32];/* ASCII name of this encoding */
 	__nbrune_t	rl_invalid_rune;
-	_RuneType	rl_runetype[_NB_CACHED_RUNES];
-	__nbrune_t	rl_maplower[_NB_CACHED_RUNES];
-	__nbrune_t	rl_mapupper[_NB_CACHED_RUNES];
+	_RuneType	rl_runetype[_CTYPE_CACHE_SIZE];
+	__nbrune_t	rl_maplower[_CTYPE_CACHE_SIZE];
+	__nbrune_t	rl_mapupper[_CTYPE_CACHE_SIZE];
 	_NBRuneRange	rl_runetype_ext;
 	_NBRuneRange	rl_maplower_ext;
 	_NBRuneRange	rl_mapupper_ext;

Index: src/lib/libc/locale/rune.c
diff -u src/lib/libc/locale/rune.c:1.33 src/lib/libc/locale/rune.c:1.34
--- src/lib/libc/locale/rune.c:1.33	Thu Feb 12 05:00:46 2009
+++ src/lib/libc/locale/rune.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune.c,v 1.33 2009/02/12 05:00:46 lukem Exp $	*/
+/*	$NetBSD: rune.c,v 1.34 2010/05/22 06:38:15 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.33 2009/02/12 05:00:46 lukem Exp $");
+__RCSID("$NetBSD: rune.c,v 1.34 2010/05/22 06:38:15 tnozaki Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -273,7 +273,7 @@
 	rl->rl_invalid_rune = ntohl((u_int32_t)frl.frl_invalid_rune);
 	rl->rl_variable_len = ntohl((u_int32_t)frl.frl_variable_len);
 
-	for (x = 0; x < _CACHED_RUNES; ++x) {
+	for (x = 0; x < _CTYPE_CACHE_SIZE; ++x) {
 		rl->rl_runetype[x] = ntohl(frl.frl_runetype[x]);
 
 		/* XXX assumes rune_t = u_int32_t */
@@ -352,7 +352,6 @@
 /*
  * read in old LC_CTYPE declaration file, convert into runelocale info
  */
-#define _CTYPE_PRIVATE
 #include <limits.h>
 #include <ctype.h>
 
@@ -395,7 +394,7 @@
 
 	if (fread(&len, sizeof(u_int32_t), 1, fp) != 1)
 		goto bad;
-	if ((len = ntohl(len)) != _CTYPE_NUM_CHARS)
+	if ((len = ntohl(len)) != _CTYPE_CACHE_SIZE)
 		goto bad;
 
 	if ((new_ctype = malloc(sizeof(u_int8_t) * (1 + len))) == NULL ||
@@ -426,7 +425,7 @@
 	rl->rl_invalid_rune = _DefaultRuneLocale.rl_invalid_rune;	/*XXX*/
 	rl->rl_variable_len = 0;
 
-	for (x = 0; x < _CACHED_RUNES; ++x) {
+	for (x = 0; x < _CTYPE_CACHE_SIZE; ++x) {
 		if ((uint32_t) x > len)
 			continue;
 

Index: src/lib/libc/locale/rune.h
diff -u src/lib/libc/locale/rune.h:1.17 src/lib/libc/locale/rune.h:1.18
--- src/lib/libc/locale/rune.h:1.17	Sun Jan 18 22:03:19 2009
+++ src/lib/libc/locale/rune.h	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rune.h,v 1.17 2009/01/18 22:03:19 tnozaki Exp $	*/
+/*	$NetBSD: rune.h,v 1.18 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -74,7 +74,6 @@
  */
 
 #define _RUNE_ISCACHED		_NB_RUNE_ISCACHED
-#define _CACHED_RUNES		_NB_CACHED_RUNES
 #define _DEFAULT_INVALID_RUNE	_NB_DEFAULT_INVALID_RUNE
 #define _RuneEntry		_NBRuneEntry
 #define _RuneRange		_NBRuneRange

Index: src/lib/libc/locale/runeglue.c
diff -u src/lib/libc/locale/runeglue.c:1.15 src/lib/libc/locale/runeglue.c:1.16
--- src/lib/libc/locale/runeglue.c:1.15	Sun Jan 11 02:46:29 2009
+++ src/lib/libc/locale/runeglue.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: runeglue.c,v 1.15 2009/01/11 02:46:29 christos Exp $	*/
+/*	$NetBSD: runeglue.c,v 1.16 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -35,29 +35,27 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: runeglue.c,v 1.15 2009/01/11 02:46:29 christos Exp $");
+__RCSID("$NetBSD: runeglue.c,v 1.16 2010/05/22 06:38:15 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
-#define _CTYPE_PRIVATE
+#include <sys/types.h>
 #include <assert.h>
+#include <ctype.h>
 #include <limits.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
+
 #include "citrus_module.h"
 #include "citrus_ctype.h"
+
 #include "rune.h"
 #include "rune_local.h"
 
 #if EOF != -1
 #error "EOF != -1"
 #endif
-#if _CACHED_RUNES != 256
-#error "_CACHED_RUNES != 256"
-#endif
 
 int
 __runetable_to_netbsd_ctype(rl)
@@ -72,12 +70,12 @@
 	new_ctype = malloc(sizeof(*new_ctype) * (1 + _CTYPE_NUM_CHARS));
 	if (!new_ctype)
 		return -1;
-	new_toupper = malloc(sizeof(*new_toupper) * (1 + 256));
+	new_toupper = malloc(sizeof(*new_toupper) * (1 + _CTYPE_NUM_CHARS));
 	if (!new_toupper) {
 		free(new_ctype);
 		return -1;
 	}
-	new_tolower = malloc(sizeof(*new_tolower) * (1 + 256));
+	new_tolower = malloc(sizeof(*new_tolower) * (1 + _CTYPE_NUM_CHARS));
 	if (!new_tolower) {
 		free(new_ctype);
 		free(new_toupper);
@@ -85,13 +83,13 @@
 	}
 
 	memset(new_ctype, 0, sizeof(*new_ctype) * (1 + _CTYPE_NUM_CHARS));
-	memset(new_toupper, 0, sizeof(*new_toupper) * (1 + 256));
-	memset(new_tolower, 0, sizeof(*new_tolower) * (1 + 256));
+	memset(new_toupper, 0, sizeof(*new_toupper) * (1 + _CTYPE_NUM_CHARS));
+	memset(new_tolower, 0, sizeof(*new_tolower) * (1 + _CTYPE_NUM_CHARS));
 
 	new_ctype[0] = 0;
 	new_toupper[0] = EOF;
 	new_tolower[0] = EOF;
-	for (i = 0; i < _CTYPE_NUM_CHARS; i++) {
+	for (i = 0; i < _CTYPE_CACHE_SIZE; i++) {
 		new_ctype[i + 1] = 0;
 		new_toupper[i + 1] = i;
 		new_tolower[i + 1] = i;

Index: src/lib/libc/locale/runetable.c
diff -u src/lib/libc/locale/runetable.c:1.21 src/lib/libc/locale/runetable.c:1.22
--- src/lib/libc/locale/runetable.c:1.21	Sun Jan 18 22:03:19 2009
+++ src/lib/libc/locale/runetable.c	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: runetable.c,v 1.21 2009/01/18 22:03:19 tnozaki Exp $	*/
+/*	$NetBSD: runetable.c,v 1.22 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -39,18 +39,19 @@
 #if 0
 static char sccsid[] = "@(#)table.c	8.1 (Berkeley) 6/27/93";
 #else
-__RCSID("$NetBSD: runetable.c,v 1.21 2009/01/18 22:03:19 tnozaki Exp $");
+__RCSID("$NetBSD: runetable.c,v 1.22 2010/05/22 06:38:15 tnozaki Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
-#include <stdlib.h>
-#define _CTYPE_PRIVATE
+#include <assert.h>
 #include <ctype.h>
 #include <locale.h>
-#include <assert.h>
+#include <stdlib.h>
 #include <wchar.h>
+
 #include "citrus_module.h"
 #include "citrus_ctype.h"
+
 #include "rune.h"
 #include "rune_local.h"
 

Index: src/usr.bin/mklocale/ldef.h
diff -u src/usr.bin/mklocale/ldef.h:1.4 src/usr.bin/mklocale/ldef.h:1.5
--- src/usr.bin/mklocale/ldef.h:1.4	Thu Aug  7 11:15:14 2003
+++ src/usr.bin/mklocale/ldef.h	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldef.h,v 1.4 2003/08/07 11:15:14 agc Exp $	*/
+/*	$NetBSD: ldef.h,v 1.5 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -46,6 +46,6 @@
 } rune_list;
 
 typedef struct rune_map {
-    u_int32_t		map[_NB_CACHED_RUNES];
+    u_int32_t		map[_CTYPE_NUM_CHARS];
     rune_list		*root;
 } rune_map;

Index: src/usr.bin/mklocale/yacc.y
diff -u src/usr.bin/mklocale/yacc.y:1.27 src/usr.bin/mklocale/yacc.y:1.28
--- src/usr.bin/mklocale/yacc.y:1.27	Mon Jan  5 06:11:43 2009
+++ src/usr.bin/mklocale/yacc.y	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: yacc.y,v 1.27 2009/01/05 06:11:43 tnozaki Exp $	*/
+/*	$NetBSD: yacc.y,v 1.28 2010/05/22 06:38:15 tnozaki Exp $	*/
 
 %{
 /*-
@@ -43,7 +43,7 @@
 static char sccsid[] = "@(#)yacc.y	8.1 (Berkeley) 6/6/93";
 static char rcsid[] = "$FreeBSD$";
 #else
-__RCSID("$NetBSD: yacc.y,v 1.27 2009/01/05 06:11:43 tnozaki Exp $");
+__RCSID("$NetBSD: yacc.y,v 1.28 2010/05/22 06:38:15 tnozaki Exp $");
 #endif
 #endif /* not lint */
 
@@ -303,7 +303,7 @@
 	return 0;
     }
 
-    for (x = 0; x < _NB_CACHED_RUNES; ++x) {
+    for (x = 0; x < _CTYPE_NUM_CHARS; ++x) {
 	mapupper.map[x] = x;
 	maplower.map[x] = x;
     }
@@ -421,7 +421,7 @@
     rune_list *r;
     __nbrune_t run;
 
-    while (list->min < _NB_CACHED_RUNES && list->min <= list->max) {
+    while (list->min < _CTYPE_NUM_CHARS && list->min <= list->max) {
 	if (flag)
 	    map->map[list->min++] |= flag;
 	else
@@ -655,7 +655,7 @@
      * (Machines like Crays cannot share with little machines due to
      *  word size.  Sigh.  We tried.)
      */
-    for (x = 0; x < _NB_CACHED_RUNES; ++x) {
+    for (x = 0; x < _CTYPE_NUM_CHARS; ++x) {
 	file_new_locale.frl_runetype[x] = htonl(types.map[x]);
 	file_new_locale.frl_maplower[x] = htonl(maplower.map[x]);
 	file_new_locale.frl_mapupper[x] = htonl(mapupper.map[x]);
@@ -778,7 +778,7 @@
 
     fprintf(stderr, "\nMAPLOWER:\n\n");
 
-    for (x = 0; x < _NB_CACHED_RUNES; ++x) {
+    for (x = 0; x < _CTYPE_NUM_CHARS; ++x) {
 	if (isprint(maplower.map[x]))
 	    fprintf(stderr, " '%c'", (int)maplower.map[x]);
 	else if (maplower.map[x])
@@ -797,7 +797,7 @@
 
     fprintf(stderr, "\nMAPUPPER:\n\n");
 
-    for (x = 0; x < _NB_CACHED_RUNES; ++x) {
+    for (x = 0; x < _CTYPE_NUM_CHARS; ++x) {
 	if (isprint(mapupper.map[x]))
 	    fprintf(stderr, " '%c'", (int)mapupper.map[x]);
 	else if (mapupper.map[x])
@@ -817,7 +817,7 @@
 
     fprintf(stderr, "\nTYPES:\n\n");
 
-    for (x = 0; x < _NB_CACHED_RUNES; ++x) {
+    for (x = 0; x < _CTYPE_NUM_CHARS; ++x) {
 	u_int32_t r = types.map[x];
 
 	if (r) {

Index: src/usr.sbin/chrtbl/Makefile
diff -u src/usr.sbin/chrtbl/Makefile:1.8 src/usr.sbin/chrtbl/Makefile:1.9
--- src/usr.sbin/chrtbl/Makefile:1.8	Fri Jan  2 00:20:23 2009
+++ src/usr.sbin/chrtbl/Makefile	Sat May 22 06:38:15 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2009/01/02 00:20:23 tnozaki Exp $
+#	$NetBSD: Makefile,v 1.9 2010/05/22 06:38:15 tnozaki Exp $
 
 .include <bsd.own.mk>
 
@@ -7,6 +7,8 @@
 
 SRCS=	chrtbl.c ctypeio.c
 
+CPPFLAGS+=	-I${NETBSDSRCDIR}/lib/libc/locale
+
 .include <bsd.prog.mk>
 
 .if (defined(HAVE_GCC) && ${HAVE_GCC} == 4) || defined(HAVE_PCC)

Index: src/usr.sbin/chrtbl/ctypeio.c
diff -u src/usr.sbin/chrtbl/ctypeio.c:1.2 src/usr.sbin/chrtbl/ctypeio.c:1.3
--- src/usr.sbin/chrtbl/ctypeio.c:1.2	Wed Oct 21 01:07:47 2009
+++ src/usr.sbin/chrtbl/ctypeio.c	Sat May 22 06:38:16 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: ctypeio.c,v 1.2 2009/10/21 01:07:47 snj Exp $ */
+/* $NetBSD: ctypeio.c,v 1.3 2010/05/22 06:38:16 tnozaki Exp $ */
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -26,12 +26,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ctypeio.c,v 1.2 2009/10/21 01:07:47 snj Exp $");
+__RCSID("$NetBSD: ctypeio.c,v 1.3 2010/05/22 06:38:16 tnozaki Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #include <assert.h>
-#define _CTYPE_PRIVATE
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
@@ -39,6 +38,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "ctype_local.h"
 #include "ctypeio.h"
 
 int

Added files:

Index: src/lib/libc/locale/ctype_local.h
diff -u /dev/null src/lib/libc/locale/ctype_local.h:1.1
--- /dev/null	Sat May 22 06:38:16 2010
+++ src/lib/libc/locale/ctype_local.h	Sat May 22 06:38:15 2010
@@ -0,0 +1,47 @@
+/* $NetBSD: ctype_local.h,v 1.1 2010/05/22 06:38:15 tnozaki Exp $ */
+
+/*-
+ * Copyright (c) 2010 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.
+ */
+#ifndef _CTYPE_LOCAL_H_
+#define _CTYPE_LOCAL_H_
+
+#include <machine/limits.h>
+
+#define _CTYPE_NUM_CHARS	(1 << CHAR_BIT)
+#define _CTYPE_CACHE_SIZE	(1 << 8)
+
+#define _CTYPE_ID		"BSDCTYPE"
+#define _CTYPE_REV		2
+
+extern const unsigned char _C_ctype_[];
+extern const short _C_toupper_[];
+extern const short _C_tolower_[];
+
+#endif
+#ifndef _CTYPE_LOCAL_H_
+#define _CTYPE_LOCAL_H_
+
+#endif /*_CTYPE_LOCAL_H_*/

Reply via email to