Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src 1. hide _CTYPE_PRIVATE section in ctype.h, move them to priv...
details: https://anonhg.NetBSD.org/src/rev/2d05f316d90e
branches: trunk
changeset: 755074:2d05f316d90e
user: tnozaki <tnozaki%NetBSD.org@localhost>
date: Sat May 22 06:38:15 2010 +0000
description:
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.
diffstat:
include/ctype.h | 15 +-----------
lib/libc/gen/Makefile.inc | 5 +++-
lib/libc/gen/ctype_.c | 16 +++++++-----
lib/libc/gen/tolower_.c | 11 +++++----
lib/libc/gen/toupper_.c | 11 +++++----
lib/libc/locale/bsdctype.c | 5 +--
lib/libc/locale/ctype_local.h | 47 ++++++++++++++++++++++++++++++++++++++++
lib/libc/locale/ctypeio.c | 18 +++++++++-----
lib/libc/locale/global_locale.c | 5 +--
lib/libc/locale/rune.c | 11 ++++-----
lib/libc/locale/rune.h | 3 +-
lib/libc/locale/runeglue.c | 24 +++++++++-----------
lib/libc/locale/runetable.c | 11 +++++----
lib/libc/locale/runetype_local.h | 20 ++++++++--------
usr.bin/mklocale/ldef.h | 4 +-
usr.bin/mklocale/yacc.y | 16 ++++++------
usr.sbin/chrtbl/Makefile | 4 ++-
usr.sbin/chrtbl/ctypeio.c | 6 ++--
18 files changed, 137 insertions(+), 95 deletions(-)
diffs (truncated from 691 to 300 lines):
diff -r 2619399b7745 -r 2d05f316d90e include/ctype.h
--- a/include/ctype.h Sat May 22 06:21:05 2010 +0000
+++ b/include/ctype.h Sat May 22 06:38:15 2010 +0000
@@ -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_ */
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/gen/Makefile.inc Sat May 22 06:38:15 2010 +0000
@@ -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
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/gen/ctype_.c
--- a/lib/libc/gen/ctype_.c Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/gen/ctype_.c Sat May 22 06:38:15 2010 +0000
@@ -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 <ctype.h>
+#include <stdio.h>
+#include "ctype_local.h"
-#include <sys/types.h>
-#include <limits.h>
-#include <ctype.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];
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/gen/tolower_.c
--- a/lib/libc/gen/tolower_.c Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/gen/tolower_.c Sat May 22 06:38:15 2010 +0000
@@ -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 <jtc%NetBSD.org@localhost>.
@@ -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 <ctype.h>
#include <stdio.h>
-#include <ctype.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];
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/gen/toupper_.c
--- a/lib/libc/gen/toupper_.c Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/gen/toupper_.c Sat May 22 06:38:15 2010 +0000
@@ -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 <jtc%NetBSD.org@localhost>.
@@ -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 <ctype.h>
#include <stdio.h>
-#include <ctype.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];
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/locale/bsdctype.c
--- a/lib/libc/locale/bsdctype.c Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/locale/bsdctype.c Sat May 22 06:38:15 2010 +0000
@@ -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"
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/locale/ctype_local.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/locale/ctype_local.h Sat May 22 06:38:15 2010 +0000
@@ -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_*/
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/locale/ctypeio.c
--- a/lib/libc/locale/ctypeio.c Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/locale/ctypeio.c Sat May 22 06:38:15 2010 +0000
@@ -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);
diff -r 2619399b7745 -r 2d05f316d90e lib/libc/locale/global_locale.c
--- a/lib/libc/locale/global_locale.c Sat May 22 06:21:05 2010 +0000
+++ b/lib/libc/locale/global_locale.c Sat May 22 06:38:15 2010 +0000
@@ -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 $ */
Home |
Main Index |
Thread Index |
Old Index