Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/perseant-stdc-iso10646]: src Use multilevel tables (tries) to convert ku...



details:   https://anonhg.NetBSD.org/src/rev/d35482135303
branches:  perseant-stdc-iso10646
changeset: 850684:d35482135303
user:      perseant <perseant%NetBSD.org@localhost>
date:      Sat Jan 20 19:36:29 2018 +0000

description:
Use multilevel tables (tries) to convert kuten <-> unicode.
Get rid of dchains, replace with chain/rchain conversions through keys
allocated from the PUA.

diffstat:

 include/wchar.h                              |      4 +-
 lib/libc/citrus/citrus_lc_collate.c          |      6 +-
 lib/libc/citrus/modules/citrus_big5.c        |     31 +-
 lib/libc/citrus/modules/citrus_big5_k2u.h    |    461 +
 lib/libc/citrus/modules/citrus_big5_u2k.h    |    712 +
 lib/libc/citrus/modules/citrus_euc.c         |     23 +-
 lib/libc/citrus/modules/citrus_euc_k2u.h     |    620 +
 lib/libc/citrus/modules/citrus_euc_u2k.h     |   1180 +
 lib/libc/citrus/modules/citrus_iso2022.c     |     24 +-
 lib/libc/citrus/modules/citrus_iso2022_k2u.h |    731 +
 lib/libc/citrus/modules/citrus_iso2022_u2k.h |   1049 +
 lib/libc/citrus/modules/citrus_mskanji.c     |     23 +-
 lib/libc/citrus/modules/citrus_mskanji_k2u.h |    247 +
 lib/libc/citrus/modules/citrus_mskanji_u2k.h |    709 +
 lib/libc/locale/collate.h                    |     11 +-
 lib/libc/locale/collate_locale.c             |     24 +-
 lib/libc/locale/ducet_collation_data.h       |  36869 ++++++++++++------------
 lib/libc/locale/unicode_ucd.c                |    103 +-
 tools/Makefile                               |      4 +-
 usr.bin/localedef/Makefile                   |      4 +-
 usr.bin/localedef/collate.c                  |      4 +-
 usr.bin/localedef/localedef                  |    Bin 
 usr.bin/localedef/parser.c                   |   2360 -
 usr.bin/localedef/parser.h                   |    125 -
 24 files changed, 24665 insertions(+), 20659 deletions(-)

diffs (truncated from 45755 to 300 lines):

diff -r 881f6f7bd058 -r d35482135303 include/wchar.h
--- a/include/wchar.h   Mon Aug 07 14:27:11 2017 +0000
+++ b/include/wchar.h   Sat Jan 20 19:36:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wchar.h,v 1.42.8.1 2017/07/14 15:53:07 perseant Exp $  */
+/*     $NetBSD: wchar.h,v 1.42.8.2 2018/01/20 19:36:29 perseant Exp $  */
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -67,7 +67,7 @@
 #include <stdio.h> /* for FILE* */
 
 /* We use ISO10646 for our wchar represenation */
-#define __STDC_ISO_10646__
+/* #define __STDC_ISO_10646__ */
 
 #if defined(_BSD_WCHAR_T_) && !defined(__cplusplus)
 typedef        _BSD_WCHAR_T_   wchar_t;
diff -r 881f6f7bd058 -r d35482135303 lib/libc/citrus/citrus_lc_collate.c
--- a/lib/libc/citrus/citrus_lc_collate.c       Mon Aug 07 14:27:11 2017 +0000
+++ b/lib/libc/citrus/citrus_lc_collate.c       Sat Jan 20 19:36:29 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_lc_collate.c,v 1.1.2.2 2017/07/31 04:29:50 perseant Exp $ */
+/* $NetBSD: citrus_lc_collate.c,v 1.1.2.3 2018/01/20 19:36:29 perseant Exp $ */
 
 /*-
  * Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_lc_collate.c,v 1.1.2.2 2017/07/31 04:29:50 perseant Exp $");
+__RCSID("$NetBSD: citrus_lc_collate.c,v 1.1.2.3 2018/01/20 19:36:29 perseant Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "reentrant.h"
@@ -84,6 +84,8 @@
        snprintf(path, sizeof(path),
            "%s/%s/LC_COLLATE", root, name);
        ret = _citrus_map_file(&r, path);
+       if (ret) 
+               perror(path);
        if (!ret) {
                ret = _collate_load((const char *)r.r_head, r.r_size, pdata);
                _citrus_unmap_file(&r);
diff -r 881f6f7bd058 -r d35482135303 lib/libc/citrus/modules/citrus_big5.c
--- a/lib/libc/citrus/modules/citrus_big5.c     Mon Aug 07 14:27:11 2017 +0000
+++ b/lib/libc/citrus/modules/citrus_big5.c     Sat Jan 20 19:36:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: citrus_big5.c,v 1.15.18.3 2017/07/31 04:23:35 perseant Exp $   */
+/*     $NetBSD: citrus_big5.c,v 1.15.18.4 2018/01/20 19:36:29 perseant Exp $   */
 
 /*-
  * Copyright (c)2002, 2006 Citrus Project,
@@ -60,7 +60,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_big5.c,v 1.15.18.3 2017/07/31 04:23:35 perseant Exp $");
+__RCSID("$NetBSD: citrus_big5.c,v 1.15.18.4 2018/01/20 19:36:29 perseant Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/queue.h>
@@ -135,14 +135,14 @@
 #define _STATE_NEEDS_EXPLICIT_INIT(_ps_)       0
 
 #ifdef __STDC_ISO_10646__
-#include "citrus_big5_data.h"
+#include "citrus_big5_k2u.h"
+#include "citrus_big5_u2k.h"
 
 static __inline int
 /*ARGSUSED*/
 _FUNCNAME(ucs2kt)(_ENCODING_INFO * __restrict ei,
                  wchar_kuten_t * __restrict ktp, wchar_ucs4_t wc)
 {
-       struct unicode2kuten_lookup *uk;
 
        _DIAGASSERT(ktp != NULL);
 
@@ -152,13 +152,7 @@
                return 0;
        }
 
-       uk = _citrus_uk_bsearch(wc, __big5_table__unicode2kuten_lookup, _BIG5_TABLE__U2K_LIST_LENGTH);
-
-       if (uk == NULL)
-               *ktp = WEOF;
-       else
-               *ktp = uk->value;
-
+       *ktp = citrus_trie_lookup(&__big5_u2k_header, wc);
        return 0;
 }
 
@@ -167,26 +161,15 @@
 _FUNCNAME(kt2ucs)(_ENCODING_INFO * __restrict ei,
                  wchar_ucs4_t * __restrict up, wchar_kuten_t kt)
 {
-       _csid_t csid;
-       _index_t idx;
-       struct unicode2kuten_lookup *uk, *table;
-
        _DIAGASSERT(up != NULL);
 
-       table = NULL;
-
+       /* ASCII values are not in the table */
        if (kt < 0x80) {
                *up = kt;
                return 0;
        }
 
-       uk = _citrus_uk_bsearch(kt, __big5_table__kuten2unicode_lookup, _BIG5_TABLE__K2U_LIST_LENGTH);
-
-       if (uk == NULL)
-               *up = WEOF;
-       else
-               *up = uk->value;
-
+       *up = citrus_trie_lookup(&__big5_k2u_header, kt);
        return 0;
 }
 #else
diff -r 881f6f7bd058 -r d35482135303 lib/libc/citrus/modules/citrus_big5_k2u.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/citrus/modules/citrus_big5_k2u.h Sat Jan 20 19:36:29 2018 +0000
@@ -0,0 +1,461 @@
+#include "citrus_trie.h"
+
+struct citrus_trie_header __big5_k2u_header = {  0, 5, 31, 0, 3, 0 };
+struct citrus_trie_node __big5_k2u_nodes[] = {
+ { 32, NULL },
+ { 31, NULL },
+ { 30, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },
+ { 31, NULL },
+ { 32, NULL },
+ { 32, NULL },



Home | Main Index | Thread Index | Old Index