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/locale Add files missing from last...



details:   https://anonhg.NetBSD.org/src/rev/014e932627b2
branches:  perseant-stdc-iso10646
changeset: 850680:014e932627b2
user:      perseant <perseant%NetBSD.org@localhost>
date:      Tue Aug 01 19:35:51 2017 +0000

description:
Add files missing from last commit (commitid: 7B1ZL3FMi0tUSk1A):

Support loading collation data from file.  Began with FreeBSD's
xlocale_collate, but had to change it somewhat to accommodate the
requirements of the Unicode Collation Algorithm (in particular,
there are maps from single-character collation elements to
multiple collation weight vectors, and multiple-to-multiple
mappings as well).

diffstat:

 lib/libc/locale/collate.h              |    154 +
 lib/libc/locale/ducet_collation_data.h |  31320 +++++++++++++++++++++++++++++++
 lib/libc/locale/unicode_dm_data.h      |  16905 ++++++++++++++++
 3 files changed, 48379 insertions(+), 0 deletions(-)

diffs (truncated from 48391 to 300 lines):

diff -r 88b641e341ad -r 014e932627b2 lib/libc/locale/collate.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/locale/collate.h Tue Aug 01 19:35:51 2017 +0000
@@ -0,0 +1,154 @@
+/*-
+ * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright (c) 1995 Alex Tatmanjants <alex%elvisti.kiev.ua@localhost>
+ *             at Electronni Visti IA, Kiev, Ukraine.
+ *                     All rights reserved.
+ *
+ * Copyright (c) 2011 The FreeBSD Foundation
+ * All rights reserved.
+ * Portions of this software were developed 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 AUTHOR ``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 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/collate.h 302824 2016-07-14 09:07:25Z ache $
+ */
+
+#ifndef _COLLATE_H_
+#define        _COLLATE_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <limits.h>
+
+/*
+ * Work around buildworld bootstrapping from older systems whose limits.h
+ * sets COLL_WEIGHTS_MAX to 0.
+ */
+#if COLL_WEIGHTS_MAX < 3
+#undef COLL_WEIGHTS_MAX
+#define COLL_WEIGHTS_MAX 10
+#endif
+
+#define        COLLATE_STR_LEN         24              /* should be 64-bit multiple */
+#define        COLLATE_VERSION         "BSD 1.0\n"
+
+#define        COLLATE_MAX_PRIORITY    (0x7fffffff)    /* max signed value */
+#define        COLLATE_SUBST_PRIORITY  (0x40000000)    /* bit indicates subst table */
+
+#define        DIRECTIVE_UNDEF         0x00
+#define        DIRECTIVE_FORWARD       0x01
+#define        DIRECTIVE_BACKWARD      0x02
+#define        DIRECTIVE_POSITION      0x04
+#define        DIRECTIVE_UNDEFINED     0x08    /* special last weight for UNDEFINED */
+
+#define        DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD)
+
+/*
+ * The collate file format is as follows:
+ *
+ * char                version[COLLATE_STR_LEN];       // must be COLLATE_VERSION
+ * collate_info_t      info;                   // see below, includes padding
+ * collate_char_pri_t  char_data[256];         // 8 bit char values
+ * collate_subst_t     subst[*];               // 0 or more substitutions
+ * collate_chain_pri_t chains[*];              // 0 or more chains
+ * collate_large_pri_t large[*];               // extended char priorities
+ *
+ * Note that all structures must be 32-bit aligned, as each structure
+ * contains 32-bit member fields.  The entire file is mmap'd, so its
+ * critical that alignment be observed.  It is not generally safe to
+ * use any 64-bit values in the structures.
+ */
+
+typedef int32_t weight_t;
+
+typedef struct collate_info {
+       uint8_t directive_count;
+       uint8_t directive[COLL_WEIGHTS_MAX];
+       weight_t pri_count[COLL_WEIGHTS_MAX];
+       int32_t flags;
+       int32_t chain_count;
+       int32_t large_count;
+       int32_t subst_count[COLL_WEIGHTS_MAX];
+       int32_t undef_pri[COLL_WEIGHTS_MAX];
+       int32_t rchain_count;
+       int32_t dchain_count;
+} collate_info_t;
+
+typedef struct collate_char {
+       weight_t pri[COLL_WEIGHTS_MAX];
+} collate_char_t;
+
+typedef struct collate_chain {
+       wchar_t str[COLLATE_STR_LEN];
+       weight_t pri[COLL_WEIGHTS_MAX];
+} collate_chain_t;
+
+typedef struct collate_large {
+       int32_t val;
+       weight_t pri[COLL_WEIGHTS_MAX];
+} collate_large_t;
+
+typedef struct collate_rchain {
+       int32_t val;
+       weight_t pri[COLLATE_STR_LEN][COLL_WEIGHTS_MAX];
+} collate_rchain_t;
+
+typedef struct collate_dchain {
+       wchar_t str[COLLATE_STR_LEN];
+       weight_t pri[COLLATE_STR_LEN][COLL_WEIGHTS_MAX];
+} collate_dchain_t;
+
+typedef struct collate_subst {
+       int32_t key;
+       weight_t pri[COLLATE_STR_LEN];
+} collate_subst_t;
+
+struct xlocale_collate {
+       /* struct xlocale_component header; */
+       int __collate_load_error;
+       char * map;
+       size_t maplen;
+
+       const collate_info_t    *info;
+       const collate_char_t    *char_pri_table;
+       const collate_large_t   *large_pri_table;
+       const collate_chain_t   *chain_pri_table;
+       const collate_rchain_t  *rchain_pri_table;
+       const collate_dchain_t  *dchain_pri_table;
+       const collate_subst_t   *subst_table[COLL_WEIGHTS_MAX];
+};
+
+__BEGIN_DECLS
+int    __collate_load_tables(const char *);
+int    __collate_equiv_value(locale_t, const wchar_t *, size_t);
+void   _collate_lookup(struct xlocale_collate *,const wchar_t *, int *, int *,
+       int, const int **);
+int    __collate_range_cmp(char, char);
+int    __wcollate_range_cmp(wchar_t, wchar_t);
+size_t _collate_wxfrm(struct xlocale_collate *, const wchar_t *, wchar_t *,
+       size_t);
+size_t _collate_sxfrm(struct xlocale_collate *, const wchar_t *, char *,
+       size_t);
+__END_DECLS
+
+#endif /* !_COLLATE_H_ */
diff -r 88b641e341ad -r 014e932627b2 lib/libc/locale/ducet_collation_data.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/locale/ducet_collation_data.h    Tue Aug 01 19:35:51 2017 +0000
@@ -0,0 +1,31320 @@
+static struct collate_char ducet_collate_chars[0x80] = {
+/* 0000  */ { 0x0000, 0x0000, 0x0000 },
+/* 0001  */ { 0x0000, 0x0000, 0x0000 },
+/* 0002  */ { 0x0000, 0x0000, 0x0000 },
+/* 0003  */ { 0x0000, 0x0000, 0x0000 },
+/* 0004  */ { 0x0000, 0x0000, 0x0000 },
+/* 0005  */ { 0x0000, 0x0000, 0x0000 },
+/* 0006  */ { 0x0000, 0x0000, 0x0000 },
+/* 0007  */ { 0x0000, 0x0000, 0x0000 },
+/* 0008  */ { 0x0000, 0x0000, 0x0000 },
+/* 0009  */ { 0x0201, 0x0020, 0x0002 },
+/* 000A  */ { 0x0202, 0x0020, 0x0002 },
+/* 000B  */ { 0x0203, 0x0020, 0x0002 },
+/* 000C  */ { 0x0204, 0x0020, 0x0002 },
+/* 000D  */ { 0x0205, 0x0020, 0x0002 },
+/* 000E  */ { 0x0000, 0x0000, 0x0000 },
+/* 000F  */ { 0x0000, 0x0000, 0x0000 },
+/* 0010  */ { 0x0000, 0x0000, 0x0000 },
+/* 0011  */ { 0x0000, 0x0000, 0x0000 },
+/* 0012  */ { 0x0000, 0x0000, 0x0000 },
+/* 0013  */ { 0x0000, 0x0000, 0x0000 },
+/* 0014  */ { 0x0000, 0x0000, 0x0000 },
+/* 0015  */ { 0x0000, 0x0000, 0x0000 },
+/* 0016  */ { 0x0000, 0x0000, 0x0000 },
+/* 0017  */ { 0x0000, 0x0000, 0x0000 },
+/* 0018  */ { 0x0000, 0x0000, 0x0000 },
+/* 0019  */ { 0x0000, 0x0000, 0x0000 },
+/* 001A  */ { 0x0000, 0x0000, 0x0000 },
+/* 001B  */ { 0x0000, 0x0000, 0x0000 },
+/* 001C  */ { 0x0000, 0x0000, 0x0000 },
+/* 001D  */ { 0x0000, 0x0000, 0x0000 },
+/* 001E  */ { 0x0000, 0x0000, 0x0000 },
+/* 001F  */ { 0x0000, 0x0000, 0x0000 },
+/* 0020  */ { 0x0209, 0x0020, 0x0002 },
+/* 0021  */ { 0x0261, 0x0020, 0x0002 },
+/* 0022  */ { 0x030D, 0x0020, 0x0002 },
+/* 0023  */ { 0x0399, 0x0020, 0x0002 },
+/* 0024  */ { 0x1C77, 0x0020, 0x0002 },
+/* 0025  */ { 0x039A, 0x0020, 0x0002 },
+/* 0026  */ { 0x0397, 0x0020, 0x0002 },
+/* 0027  */ { 0x0306, 0x0020, 0x0002 },
+/* 0028  */ { 0x0318, 0x0020, 0x0002 },
+/* 0029  */ { 0x0319, 0x0020, 0x0002 },
+/* 002A  */ { 0x0390, 0x0020, 0x0002 },
+/* 002B  */ { 0x062C, 0x0020, 0x0002 },
+/* 002C  */ { 0x0222, 0x0020, 0x0002 },
+/* 002D  */ { 0x020D, 0x0020, 0x0002 },
+/* 002E  */ { 0x0278, 0x0020, 0x0002 },
+/* 002F  */ { 0x0395, 0x0020, 0x0002 },
+/* 0030  */ { 0x1CA3, 0x0020, 0x0002 },
+/* 0031  */ { 0x1CA4, 0x0020, 0x0002 },
+/* 0032  */ { 0x1CA5, 0x0020, 0x0002 },
+/* 0033  */ { 0x1CA6, 0x0020, 0x0002 },
+/* 0034  */ { 0x1CA7, 0x0020, 0x0002 },
+/* 0035  */ { 0x1CA8, 0x0020, 0x0002 },
+/* 0036  */ { 0x1CA9, 0x0020, 0x0002 },
+/* 0037  */ { 0x1CAA, 0x0020, 0x0002 },
+/* 0038  */ { 0x1CAB, 0x0020, 0x0002 },
+/* 0039  */ { 0x1CAC, 0x0020, 0x0002 },
+/* 003A  */ { 0x023A, 0x0020, 0x0002 },
+/* 003B  */ { 0x0234, 0x0020, 0x0002 },
+/* 003C  */ { 0x0630, 0x0020, 0x0002 },
+/* 003D  */ { 0x0631, 0x0020, 0x0002 },
+/* 003E  */ { 0x0632, 0x0020, 0x0002 },
+/* 003F  */ { 0x0267, 0x0020, 0x0002 },
+/* 0040  */ { 0x038F, 0x0020, 0x0002 },
+/* 0041  */ { 0x1CAD, 0x0020, 0x0008 },
+/* 0042  */ { 0x1CC6, 0x0020, 0x0008 },
+/* 0043  */ { 0x1CE0, 0x0020, 0x0008 },
+/* 0044  */ { 0x1CF5, 0x0020, 0x0008 },
+/* 0045  */ { 0x1D10, 0x0020, 0x0008 },
+/* 0046  */ { 0x1D4B, 0x0020, 0x0008 },
+/* 0047  */ { 0x1D5A, 0x0020, 0x0008 },
+/* 0048  */ { 0x1D7E, 0x0020, 0x0008 },
+/* 0049  */ { 0x1D98, 0x0020, 0x0008 },
+/* 004A  */ { 0x1DB2, 0x0020, 0x0008 },
+/* 004B  */ { 0x1DCB, 0x0020, 0x0008 },
+/* 004C  */ { 0x1DDD, 0x0020, 0x0008 },
+/* 004D  */ { 0x1E10, 0x0020, 0x0008 },
+/* 004E  */ { 0x1E1F, 0x0020, 0x0008 },
+/* 004F  */ { 0x1E43, 0x0020, 0x0008 },
+/* 0050  */ { 0x1E72, 0x0020, 0x0008 },
+/* 0051  */ { 0x1E87, 0x0020, 0x0008 },
+/* 0052  */ { 0x1E99, 0x0020, 0x0008 },
+/* 0053  */ { 0x1ED7, 0x0020, 0x0008 },
+/* 0054  */ { 0x1EFB, 0x0020, 0x0008 },
+/* 0055  */ { 0x1F1B, 0x0020, 0x0008 },
+/* 0056  */ { 0x1F49, 0x0020, 0x0008 },
+/* 0057  */ { 0x1F5B, 0x0020, 0x0008 },
+/* 0058  */ { 0x1F65, 0x0020, 0x0008 },
+/* 0059  */ { 0x1F71, 0x0020, 0x0008 },
+/* 005A  */ { 0x1F87, 0x0020, 0x0008 },
+/* 005B  */ { 0x031A, 0x0020, 0x0002 },
+/* 005C  */ { 0x0396, 0x0020, 0x0002 },
+/* 005D  */ { 0x031B, 0x0020, 0x0002 },
+/* 005E  */ { 0x049B, 0x0020, 0x0002 },
+/* 005F  */ { 0x020B, 0x0020, 0x0002 },
+/* 0060  */ { 0x0498, 0x0020, 0x0002 },
+/* 0061  */ { 0x1CAD, 0x0020, 0x0002 },
+/* 0062  */ { 0x1CC6, 0x0020, 0x0002 },
+/* 0063  */ { 0x1CE0, 0x0020, 0x0002 },
+/* 0064  */ { 0x1CF5, 0x0020, 0x0002 },
+/* 0065  */ { 0x1D10, 0x0020, 0x0002 },
+/* 0066  */ { 0x1D4B, 0x0020, 0x0002 },
+/* 0067  */ { 0x1D5A, 0x0020, 0x0002 },
+/* 0068  */ { 0x1D7E, 0x0020, 0x0002 },
+/* 0069  */ { 0x1D98, 0x0020, 0x0002 },
+/* 006A  */ { 0x1DB2, 0x0020, 0x0002 },
+/* 006B  */ { 0x1DCB, 0x0020, 0x0002 },
+/* 006C  */ { 0x1DDD, 0x0020, 0x0002 },
+/* 006D  */ { 0x1E10, 0x0020, 0x0002 },
+/* 006E  */ { 0x1E1F, 0x0020, 0x0002 },
+/* 006F  */ { 0x1E43, 0x0020, 0x0002 },
+/* 0070  */ { 0x1E72, 0x0020, 0x0002 },
+/* 0071  */ { 0x1E87, 0x0020, 0x0002 },
+/* 0072  */ { 0x1E99, 0x0020, 0x0002 },
+/* 0073  */ { 0x1ED7, 0x0020, 0x0002 },
+/* 0074  */ { 0x1EFB, 0x0020, 0x0002 },
+/* 0075  */ { 0x1F1B, 0x0020, 0x0002 },
+/* 0076  */ { 0x1F49, 0x0020, 0x0002 },
+/* 0077  */ { 0x1F5B, 0x0020, 0x0002 },
+/* 0078  */ { 0x1F65, 0x0020, 0x0002 },
+/* 0079  */ { 0x1F71, 0x0020, 0x0002 },
+/* 007A  */ { 0x1F87, 0x0020, 0x0002 },
+/* 007B  */ { 0x031C, 0x0020, 0x0002 },
+/* 007C  */ { 0x0634, 0x0020, 0x0002 },
+/* 007D  */ { 0x031D, 0x0020, 0x0002 },
+/* 007E  */ { 0x0636, 0x0020, 0x0002 },
+/* 007F  */ { 0x0000, 0x0000, 0x0000 },
+};
+#define DUCET_COLLATE_CHARS_LENGTH 0x80
+static struct collate_chain ducet_collate_chains[] = {
+ {{0x00418, 0x00306}, {0x020F3, 0x00020, 0x00008}}, 
+ {{0x00438, 0x00306}, {0x020F3, 0x00020, 0x00002}}, 
+ {{0x00627, 0x00653}, {0x02364, 0x00020, 0x00002}}, 
+ {{0x00627, 0x00654}, {0x02365, 0x00020, 0x00002}}, 
+ {{0x00627, 0x00655}, {0x02369, 0x00020, 0x00002}}, 
+ {{0x00648, 0x00654}, {0x02368, 0x00020, 0x00002}}, 



Home | Main Index | Thread Index | Old Index