Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/perseant-stdc-iso10646]: src/lib/libc Move Unicode <-> ku/ten mapping in...
details: https://anonhg.NetBSD.org/src/rev/5f239afcfdc3
branches: perseant-stdc-iso10646
changeset: 850675:5f239afcfdc3
user: perseant <perseant%NetBSD.org@localhost>
date: Fri Jul 21 20:22:29 2017 +0000
description:
Move Unicode <-> ku/ten mapping into the individual codec modules.
Mapping is based on existing iconv data for single-byte encodings,
and included for several, but not all, multibyte encodings.
diffstat:
lib/libc/citrus/citrus_ctype.c | 30 +-
lib/libc/citrus/citrus_ctype.h | 44 +-
lib/libc/citrus/citrus_ctype_fallback.c | 18 +-
lib/libc/citrus/citrus_ctype_fallback.h | 10 +-
lib/libc/citrus/citrus_ctype_local.h | 86 +-
lib/libc/citrus/citrus_ctype_template.h | 74 +-
lib/libc/citrus/citrus_iconv.h | 9 +-
lib/libc/citrus/citrus_iconv_local.h | 14 +-
lib/libc/citrus/citrus_namespace.h | 4 +-
lib/libc/citrus/citrus_none.c | 203 +-
lib/libc/citrus/citrus_stdenc.h | 35 +-
lib/libc/citrus/citrus_stdenc_local.h | 32 +-
lib/libc/citrus/citrus_stdenc_template.h | 6 +-
lib/libc/citrus/modules/citrus_big5.c | 88 +-
lib/libc/citrus/modules/citrus_big5_data.h | 26937 ++++++++++++++++++
lib/libc/citrus/modules/citrus_dechanyu.c | 40 +-
lib/libc/citrus/modules/citrus_euc.c | 82 +-
lib/libc/citrus/modules/citrus_euc_data.h | 34565 +++++++++++++++++++++++
lib/libc/citrus/modules/citrus_euctw.c | 28 +-
lib/libc/citrus/modules/citrus_gbk2k.c | 30 +-
lib/libc/citrus/modules/citrus_hz.c | 32 +-
lib/libc/citrus/modules/citrus_iconv_none.c | 9 +-
lib/libc/citrus/modules/citrus_iconv_std.c | 16 +-
lib/libc/citrus/modules/citrus_iso2022.c | 94 +-
lib/libc/citrus/modules/citrus_iso2022_data.h | 35678 +++++++++++++++++++++++
lib/libc/citrus/modules/citrus_johab.c | 25 +-
lib/libc/citrus/modules/citrus_mskanji.c | 89 +-
lib/libc/citrus/modules/citrus_mskanji_data.h | 13773 +++++++++
lib/libc/citrus/modules/citrus_ues.c | 46 +-
lib/libc/citrus/modules/citrus_utf1632.c | 44 +-
lib/libc/citrus/modules/citrus_utf7.c | 20 +-
lib/libc/citrus/modules/citrus_utf8.c | 27 +-
lib/libc/citrus/modules/citrus_viqr.c | 44 +-
lib/libc/citrus/modules/citrus_zw.c | 38 +-
lib/libc/locale/Makefile.inc | 10 +-
lib/libc/locale/_wctrans.c | 6 +-
lib/libc/locale/_wctrans_local.h | 19 +-
lib/libc/locale/_wctype.c | 13 +-
lib/libc/locale/iswctype_mb.c | 27 +-
lib/libc/locale/multibyte.h | 7 +-
lib/libc/locale/multibyte_amd1.c | 69 +-
lib/libc/locale/multibyte_c90.c | 59 +-
lib/libc/locale/rune.c | 20 +-
lib/libc/locale/rune_iso10646.c | 480 -
lib/libc/locale/rune_iso10646.h | 44 -
lib/libc/locale/u2k.h | 35712 ------------------------
46 files changed, 111941 insertions(+), 36795 deletions(-)
diffs (truncated from 151747 to 300 lines):
diff -r f06bb6326a17 -r 5f239afcfdc3 lib/libc/citrus/citrus_ctype.c
--- a/lib/libc/citrus/citrus_ctype.c Tue Jul 18 14:55:29 2017 +0000
+++ b/lib/libc/citrus/citrus_ctype.c Fri Jul 21 20:22:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_ctype.c,v 1.7.22.1 2017/07/14 15:53:07 perseant Exp $ */
+/* $NetBSD: citrus_ctype.c,v 1.7.22.2 2017/07/21 20:22:29 perseant Exp $ */
/*-
* Copyright (c)1999, 2000, 2001, 2002 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_ctype.c,v 1.7.22.1 2017/07/14 15:53:07 perseant Exp $");
+__RCSID("$NetBSD: citrus_ctype.c,v 1.7.22.2 2017/07/21 20:22:29 perseant Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -46,7 +46,6 @@
#include "citrus_ctype_fallback.h"
#include "citrus_none.h"
#include "runetype_local.h"
-#include "rune_iso10646.h"
#include _CITRUS_DEFAULT_CTYPE_HEADER
_citrus_ctype_rec_t _citrus_ctype_default = {
@@ -154,8 +153,9 @@
_DIAGASSERT(rcc != NULL);
if (!strcmp(encname, _CITRUS_DEFAULT_CTYPE_NAME)) {
- *rcc = &_citrus_ctype_default;
- return (0);
+ cc = *rcc = &_citrus_ctype_default;
+ ret = (*cc->cc_ops->co_init)(&cc->cc_closure, variable, lenvar, szpriv);
+ return ret;
}
ret = _citrus_load_module(&handle, encname);
if (ret)
@@ -216,3 +216,23 @@
}
#endif
+
+struct unicode2kuten_lookup *
+_citrus_uk_bsearch(wchar_t wc, struct unicode2kuten_lookup *base, int length) {
+ int l, r, m;
+ wchar_t u;
+
+ l = 0;
+ r = length - 1;
+ while (l <= r) {
+ m = (l + r) / 2;
+ u = base[m].key;
+ if (u == wc)
+ return base + m;
+ if (u < wc)
+ l = m + 1;
+ else
+ r = m - 1;
+ }
+ return NULL;
+}
diff -r f06bb6326a17 -r 5f239afcfdc3 lib/libc/citrus/citrus_ctype.h
--- a/lib/libc/citrus/citrus_ctype.h Tue Jul 18 14:55:29 2017 +0000
+++ b/lib/libc/citrus/citrus_ctype.h Fri Jul 21 20:22:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_ctype.h,v 1.3 2013/05/28 16:57:56 joerg Exp $ */
+/* $NetBSD: citrus_ctype.h,v 1.3.22.1 2017/07/21 20:22:29 perseant Exp $ */
/*-
* Copyright (c)2002 Citrus Project,
@@ -67,7 +67,7 @@
}
static __inline int
-_citrus_ctype_mbrtowc(_citrus_ctype_t cc, wchar_t *pwc, const char *s,
+_citrus_ctype_mbrtowc(_citrus_ctype_t cc, wchar_kuten_t *pwc, const char *s,
size_t n, void *pspriv, size_t *nresult)
{
@@ -85,7 +85,7 @@
}
static __inline int
-_citrus_ctype_mbsrtowcs(_citrus_ctype_t cc, wchar_t *pwcs, const char **s,
+_citrus_ctype_mbsrtowcs(_citrus_ctype_t cc, wchar_kuten_t *pwcs, const char **s,
size_t n, void *pspriv, size_t *nresult)
{
@@ -95,7 +95,7 @@
}
static __inline int
-_citrus_ctype_mbsnrtowcs(_citrus_ctype_t cc, wchar_t *pwcs, const char **s,
+_citrus_ctype_mbsnrtowcs(_citrus_ctype_t cc, wchar_kuten_t *pwcs, const char **s,
size_t in, size_t n, void *pspriv, size_t *nresult)
{
@@ -105,7 +105,7 @@
}
static __inline int
-_citrus_ctype_mbstowcs(_citrus_ctype_t cc, wchar_t *pwcs, const char *s,
+_citrus_ctype_mbstowcs(_citrus_ctype_t cc, wchar_kuten_t *pwcs, const char *s,
size_t n, size_t *nresult)
{
@@ -114,7 +114,7 @@
}
static __inline int
-_citrus_ctype_mbtowc(_citrus_ctype_t cc, wchar_t *pw, const char *s, size_t n,
+_citrus_ctype_mbtowc(_citrus_ctype_t cc, wchar_kuten_t *pw, const char *s, size_t n,
int *nresult)
{
@@ -123,7 +123,7 @@
}
static __inline int
-_citrus_ctype_wcrtomb(_citrus_ctype_t cc, char *s, wchar_t wc,
+_citrus_ctype_wcrtomb(_citrus_ctype_t cc, char *s, wchar_kuten_t wc,
void *pspriv, size_t *nresult)
{
@@ -133,7 +133,7 @@
}
static __inline int
-_citrus_ctype_wcsrtombs(_citrus_ctype_t cc, char *s, const wchar_t **ppwcs,
+_citrus_ctype_wcsrtombs(_citrus_ctype_t cc, char *s, const wchar_kuten_t **ppwcs,
size_t n, void *pspriv, size_t *nresult)
{
@@ -143,7 +143,7 @@
}
static __inline int
-_citrus_ctype_wcsnrtombs(_citrus_ctype_t cc, char *s, const wchar_t **ppwcs,
+_citrus_ctype_wcsnrtombs(_citrus_ctype_t cc, char *s, const wchar_kuten_t **ppwcs,
size_t in, size_t n, void *pspriv, size_t *nresult)
{
@@ -153,7 +153,7 @@
}
static __inline int
-_citrus_ctype_wcstombs(_citrus_ctype_t cc, char *s, const wchar_t *wcs,
+_citrus_ctype_wcstombs(_citrus_ctype_t cc, char *s, const wchar_kuten_t *wcs,
size_t n, size_t *nresult)
{
@@ -162,7 +162,7 @@
}
static __inline int
-_citrus_ctype_wctomb(_citrus_ctype_t cc, char *s, wchar_t wc, int *nresult)
+_citrus_ctype_wctomb(_citrus_ctype_t cc, char *s, wchar_kuten_t wc, int *nresult)
{
_DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wctomb && nresult);
@@ -170,7 +170,7 @@
}
static __inline int
-_citrus_ctype_btowc(_citrus_ctype_t cc, int c, wint_t *wcresult)
+_citrus_ctype_btowc(_citrus_ctype_t cc, int c, wint_kuten_t *wcresult)
{
_DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_btowc && wcresult);
@@ -178,13 +178,31 @@
}
static __inline int
-_citrus_ctype_wctob(_citrus_ctype_t cc, wint_t c, int *cresult)
+_citrus_ctype_wctob(_citrus_ctype_t cc, wint_kuten_t c, int *cresult)
{
_DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wctob && cresult);
return (*cc->cc_ops->co_wctob)(cc, c, cresult);
}
+static __inline int
+_citrus_ctype_ucs2kt(_citrus_ctype_t cc,
+ wchar_kuten_t * __restrict ktp,
+ wchar_ucs4_t wc)
+{
+ _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_ucs2kt);
+ return (*cc->cc_ops->co_ucs2kt)(cc->cc_closure, ktp, wc);
+}
+
+static __inline int
+_citrus_ctype_kt2ucs(_citrus_ctype_t cc,
+ wchar_ucs4_t * __restrict up,
+ wchar_kuten_t kt)
+{
+ _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_kt2ucs);
+ return (*cc->cc_ops->co_kt2ucs)(cc->cc_closure, up, kt);
+}
+
extern _citrus_ctype_rec_t _citrus_ctype_default;
#endif
diff -r f06bb6326a17 -r 5f239afcfdc3 lib/libc/citrus/citrus_ctype_fallback.c
--- a/lib/libc/citrus/citrus_ctype_fallback.c Tue Jul 18 14:55:29 2017 +0000
+++ b/lib/libc/citrus/citrus_ctype_fallback.c Fri Jul 21 20:22:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_ctype_fallback.c,v 1.3 2013/05/28 16:57:56 joerg Exp $ */
+/* $NetBSD: citrus_ctype_fallback.c,v 1.3.22.1 2017/07/21 20:22:29 perseant Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_ctype_fallback.c,v 1.3 2013/05/28 16:57:56 joerg Exp $");
+__RCSID("$NetBSD: citrus_ctype_fallback.c,v 1.3.22.1 2017/07/21 20:22:29 perseant Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -51,7 +51,7 @@
int
_citrus_ctype_btowc_fallback(_citrus_ctype_rec_t * __restrict cc,
- int c, wint_t * __restrict wcresult)
+ int c, wint_kuten_t * __restrict wcresult)
{
char mb;
/*
@@ -59,7 +59,7 @@
* and we know that it's smaller than sizeof(mbstate_t).
*/
char pspriv[sizeof(mbstate_t)];
- wchar_t wc;
+ wchar_kuten_t wc;
size_t nr;
int err;
@@ -83,7 +83,7 @@
int
_citrus_ctype_wctob_fallback(_citrus_ctype_rec_t * __restrict cc,
- wint_t wc, int * __restrict cresult)
+ wint_kuten_t wc, int * __restrict cresult)
{
/*
* what we need is _PRIVSIZE
@@ -101,7 +101,7 @@
return 0;
}
memset(&pspriv, 0, sizeof(pspriv));
- err = _citrus_ctype_wcrtomb(cc, buf, (wchar_t)wc, (void *)&pspriv, &nr);
+ err = _citrus_ctype_wcrtomb(cc, buf, (wchar_kuten_t)wc, (void *)&pspriv, &nr);
if (!err && nr == 1)
*cresult = buf[0];
else
@@ -116,7 +116,7 @@
int
_citrus_ctype_mbsnrtowcs_fallback(_citrus_ctype_rec_t * __restrict cc,
- wchar_t * __restrict pwcs, const char ** __restrict s, size_t in,
+ wchar_kuten_t * __restrict pwcs, const char ** __restrict s, size_t in,
size_t n, void * __restrict psenc, size_t * __restrict nresult)
{
int err;
@@ -177,14 +177,14 @@
int
_citrus_ctype_wcsnrtombs_fallback(_citrus_ctype_rec_t * __restrict cc,
- char * __restrict s, const wchar_t ** __restrict pwcs, size_t in,
+ char * __restrict s, const wchar_kuten_t ** __restrict pwcs, size_t in,
size_t n, void * __restrict psenc, size_t * __restrict nresult)
{
size_t cnt = 0;
int err;
char buf[MB_LEN_MAX];
size_t siz;
- const wchar_t* pwcs0;
+ const wchar_kuten_t* pwcs0;
mbstate_t state;
pwcs0 = *pwcs;
diff -r f06bb6326a17 -r 5f239afcfdc3 lib/libc/citrus/citrus_ctype_fallback.h
--- a/lib/libc/citrus/citrus_ctype_fallback.h Tue Jul 18 14:55:29 2017 +0000
+++ b/lib/libc/citrus/citrus_ctype_fallback.h Fri Jul 21 20:22:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_ctype_fallback.h,v 1.2 2013/05/28 16:57:56 joerg Exp $ */
+/* $NetBSD: citrus_ctype_fallback.h,v 1.2.22.1 2017/07/21 20:22:29 perseant Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@@ -31,19 +31,19 @@
/* fallback functions for 0x00000002 */
int _citrus_ctype_btowc_fallback(_citrus_ctype_rec_t * __restrict,
- int, wint_t * __restrict);
+ int, wint_kuten_t * __restrict);
int _citrus_ctype_wctob_fallback(_citrus_ctype_rec_t * __restrict,
- wint_t, int * __restrict);
Home |
Main Index |
Thread Index |
Old Index