Source-Changes-HG archive

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

[src/perseant-stdc-iso10646]: src Add a version of localedef(1), taken from F...



details:   https://anonhg.NetBSD.org/src/rev/705b16c8c2dd
branches:  perseant-stdc-iso10646
changeset: 850681:705b16c8c2dd
user:      perseant <perseant%NetBSD.org@localhost>
date:      Fri Aug 04 21:43:11 2017 +0000

description:
Add a version of localedef(1), taken from FreeBSD, which works with
NetBSD's binary format.  LC_CTYPE should be mostly compatible but is
still missing pieces; the LC_COLLATE format is in a similar situation,
since it makes different assumptions than UCA/DUCET.  The other, smaller,
LC_* types should all work, but have not been extensively tested.

diffstat:

 distrib/sets/lists/base/mi              |     3 +-
 distrib/sets/lists/debug/mi             |     3 +-
 distrib/sets/lists/man/mi               |     4 +-
 lib/libc/citrus/citrus_ctype_template.h |    22 +-
 lib/libc/locale/runetype_file.h         |     5 +-
 usr.bin/localedef/Makefile              |    47 +
 usr.bin/localedef/README                |    11 +
 usr.bin/localedef/charmap.c             |   372 ++++
 usr.bin/localedef/collate.c             |  1328 +++++++++++++++++
 usr.bin/localedef/ctype.c               |   581 +++++++
 usr.bin/localedef/iso2022.c             |    97 +
 usr.bin/localedef/localedef             |   Bin 
 usr.bin/localedef/localedef.1           |   267 +++
 usr.bin/localedef/localedef.c           |   348 ++++
 usr.bin/localedef/localedef.h           |   174 ++
 usr.bin/localedef/messages.c            |   137 +
 usr.bin/localedef/mklocaledb.c          |   300 +++
 usr.bin/localedef/mklocaledb.h          |    26 +
 usr.bin/localedef/monetary.c            |   227 ++
 usr.bin/localedef/numeric.c             |   135 +
 usr.bin/localedef/parser.c              |  2360 +++++++++++++++++++++++++++++++
 usr.bin/localedef/parser.h              |   125 +
 usr.bin/localedef/parser.y              |   712 +++++++++
 usr.bin/localedef/scanner.c             |   902 +++++++++++
 usr.bin/localedef/time.c                |   326 ++++
 usr.bin/localedef/wide.c                |   727 +++++++++
 26 files changed, 9231 insertions(+), 8 deletions(-)

diffs (truncated from 9396 to 300 lines):

diff -r 014e932627b2 -r 705b16c8c2dd distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Tue Aug 01 19:35:51 2017 +0000
+++ b/distrib/sets/lists/base/mi        Fri Aug 04 21:43:11 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1158 2017/05/27 21:02:54 bouyer Exp $
+# $NetBSD: mi,v 1.1158.4.1 2017/08/04 21:43:11 perseant Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -777,6 +777,7 @@
 ./usr/bin/lessecho                             base-util-bin
 ./usr/bin/lesskey                              base-util-bin
 ./usr/bin/locale                               base-locale-bin
+./usr/bin/localedef                            base-locale-bin
 ./usr/bin/locate                               base-util-bin
 ./usr/bin/lock                                 base-util-bin
 ./usr/bin/logger                               base-util-bin
diff -r 014e932627b2 -r 705b16c8c2dd distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Tue Aug 01 19:35:51 2017 +0000
+++ b/distrib/sets/lists/debug/mi       Fri Aug 04 21:43:11 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.220.2.1 2017/07/18 14:55:29 perseant Exp $
+# $NetBSD: mi,v 1.220.2.2 2017/08/04 21:43:11 perseant Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -616,6 +616,7 @@
 ./usr/libdata/debug/usr/bin/lkbib.debug                comp-groff-debug        groff,debug
 ./usr/libdata/debug/usr/bin/llvm-tblgen.debug  comp-c-debug            llvm,debug
 ./usr/libdata/debug/usr/bin/locale.debug       comp-locale-debug       debug
+./usr/libdata/debug/usr/bin/localedef.debug    comp-locale-debug       debug
 ./usr/libdata/debug/usr/bin/locate.debug       comp-util-debug         debug
 ./usr/libdata/debug/usr/bin/lock.debug         comp-util-debug         debug
 ./usr/libdata/debug/usr/bin/logger.debug       comp-util-debug         debug
diff -r 014e932627b2 -r 705b16c8c2dd distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Tue Aug 01 19:35:51 2017 +0000
+++ b/distrib/sets/lists/man/mi Fri Aug 04 21:43:11 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1559 2017/06/16 22:39:34 pgoyette Exp $
+# $NetBSD: mi,v 1.1559.2.1 2017/08/04 21:43:11 perseant Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3467,6 +3467,7 @@
 ./usr/share/man/html1/linkfarm.html            man-obsolete            obsolete
 ./usr/share/man/html1/ln.html                  man-util-htmlman        html
 ./usr/share/man/html1/locale.html              man-util-htmlman        html
+./usr/share/man/html1/localedef.html           man-util-htmlman        html
 ./usr/share/man/html1/locate.html              man-util-htmlman        html
 ./usr/share/man/html1/lock.html                        man-util-htmlman        html
 ./usr/share/man/html1/logger.html              man-util-htmlman        html
@@ -6290,6 +6291,7 @@
 ./usr/share/man/man1/linkfarm.1                        man-obsolete            obsolete
 ./usr/share/man/man1/ln.1                      man-util-man            .man
 ./usr/share/man/man1/locale.1                  man-util-man            .man
+./usr/share/man/man1/localedef.1               man-util-man            .man
 ./usr/share/man/man1/locate.1                  man-util-man            .man
 ./usr/share/man/man1/lock.1                    man-util-man            .man
 ./usr/share/man/man1/logger.1                  man-util-man            .man
diff -r 014e932627b2 -r 705b16c8c2dd lib/libc/citrus/citrus_ctype_template.h
--- a/lib/libc/citrus/citrus_ctype_template.h   Tue Aug 01 19:35:51 2017 +0000
+++ b/lib/libc/citrus/citrus_ctype_template.h   Fri Aug 04 21:43:11 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: citrus_ctype_template.h,v 1.36.22.2 2017/07/31 04:23:35 perseant Exp $ */
+/*     $NetBSD: citrus_ctype_template.h,v 1.36.22.3 2017/08/04 21:43:11 perseant Exp $ */
 
 /*-
  * Copyright (c)2002 Citrus Project,
@@ -956,7 +956,21 @@
        return _FUNCNAME(kt2ucs)(_CEI_TO_EI(_TO_CEI(cl)), up, kt);
 }
 #else
-/* Define away the calls to these functions */
-#define _FUNCNAME(ctype_ucs2kt)(cl, ktp, wc) do {} while (0)
-#define _FUNCNAME(ctype_kt2ucs)(cl, up, kt) do {} while (0)
+static __inline int
+/*ARGSUSED*/
+_FUNCNAME(ctype_ucs2kt)(void * __restrict cl,
+                       wchar_kuten_t * __restrict ktp, wchar_ucs4_t wc)
+{
+       *ktp = wc;
+       return 0;
+}
+
+static __inline int
+/*ARGSUSED*/
+_FUNCNAME(ctype_kt2ucs)(void * __restrict cl,
+                        wchar_ucs4_t * __restrict up, wchar_kuten_t kt)
+{
+       *up = kt;
+       return 0;
+}
 #endif
diff -r 014e932627b2 -r 705b16c8c2dd lib/libc/locale/runetype_file.h
--- a/lib/libc/locale/runetype_file.h   Tue Aug 01 19:35:51 2017 +0000
+++ b/lib/libc/locale/runetype_file.h   Fri Aug 04 21:43:11 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: runetype_file.h,v 1.3 2010/06/20 02:23:15 tnozaki Exp $ */
+/* $NetBSD: runetype_file.h,v 1.3.40.1 2017/08/04 21:43:11 perseant Exp $ */
 
 /*-
  * Copyright (c) 1993
@@ -71,6 +71,9 @@
 #define        _RUNETYPE_I     UINT32_C(0x00080000)    /* Ideogram */
 #define        _RUNETYPE_T     UINT32_C(0x00100000)    /* Special */
 #define        _RUNETYPE_Q     UINT32_C(0x00200000)    /* Phonogram */
+#if 0
+# define _RUNETYPE_N   UINT32_C(0x00400000)    /* Number (superset of digit) */
+#endif
 #define        _RUNETYPE_SWM   UINT32_C(0xc0000000)/* Mask to get screen width data */
 #define        _RUNETYPE_SWS   30              /* Bits to shift to get width */
 #define        _RUNETYPE_SW0   UINT32_C(0x20000000)    /* 0 width character */
diff -r 014e932627b2 -r 705b16c8c2dd usr.bin/localedef/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/localedef/Makefile        Fri Aug 04 21:43:11 2017 +0000
@@ -0,0 +1,47 @@
+# $NetBSD: Makefile,v 1.1.2.1 2017/08/04 21:43:11 perseant Exp $
+# $FreeBSD: head/usr.bin/localedef/Makefile 290562 2015-11-08 22:23:21Z bapt $
+
+.ifndef HOSTPROG
+.include <bsd.own.mk>
+.endif
+
+.PATH: ${NETBSDSRCDIR}/lib/libc/locale ${NETBSDSRCDIR}/lib/libc/citrus ${NETBSDSRCDIR}/lib/libc/stdio
+
+PROG=  localedef
+SRCS+= parser.y \
+       charmap.c \
+       collate.c \
+       ctype.c \
+       localedef.c \
+       messages.c \
+       monetary.c \
+       numeric.c \
+       scanner.c \
+       time.c \
+       wide.c
+SRCS+= iso2022.c mklocaledb.c citrus_db_factory.c
+
+WARNS= 3
+YHEADER=1
+
+parser.h: parser.y
+
+IGNORE_PRAGMA= yes
+
+CPPFLAGS+=     -I. -I${.CURDIR}
+CPPFLAGS+=     -I${NETBSDSRCDIR}/lib/libc/locale
+CPPFLAGS+=     -I${NETBSDSRCDIR}/lib/libc/citrus
+CPPFLAGS+=     -I${NETBSDSRCDIR}/lib/libc/stdtime
+#CPPFLAGS+=    -I${NETBSDSRCDIR}/include
+#CPPFLAGS+=    -I${NETBSDSRCDIR}/sys
+CPPFLAGS+=     -DHOSTPROG
+
+CPPFLAGS.iso2022.c+= -I../../lib/libc/citrus -I../../lib/libc/locale -Wno-cast-qual -Wno-pointer-sign
+CPPFLAGS.mklocaledb.c+= -I../../lib/libc/citrus -I../../lib/libc/locale -Wno-cast-qual -Wno-pointer-sign
+CPPFLAGS.messages.c+= -I../../lib/libc/locale
+
+CLEANFILES+=   parser.c parser.h
+
+.ifndef HOSTPROG
+.include <bsd.prog.mk>
+.endif
diff -r 014e932627b2 -r 705b16c8c2dd usr.bin/localedef/README
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/localedef/README  Fri Aug 04 21:43:11 2017 +0000
@@ -0,0 +1,11 @@
+While there are tools called "localedef" in Solaris and Linux, this
+tool does not share heritage with any other implementation.  It was
+written independently by Garrett D'Amore while employed at Nexenta
+Systems, and thus carries the Nexenta Copyright.
+
+It was initially released under the CDDL license, but on 4 July 2014,
+Nexenta reissued the source under the BSD 2-clause license.  This
+code is part of the Illumos project.
+
+see:
+https://github.com/Nexenta/illumos-nexenta/commit/cf17542a37fc83d0ae093777e30d480423858c29
diff -r 014e932627b2 -r 705b16c8c2dd usr.bin/localedef/charmap.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/localedef/charmap.c       Fri Aug 04 21:43:11 2017 +0000
@@ -0,0 +1,372 @@
+/*
+ * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2015 John Marino <draco%marino.st@localhost>
+ *
+ * This source code is derived from the illumos localedef command, and
+ * provided under BSD-style license terms by Nexenta Systems, Inc.
+ *
+ * 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
+ */
+
+/*
+ * CHARMAP file handling for localedef.
+ */
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+#if 0
+__FBSDID("$FreeBSD: head/usr.bin/localedef/charmap.c 298878 2016-05-01 16:10:56Z pfg $");
+#endif
+
+#include <sys/types.h>
+#if HAVE_NBTOOL_CONFIG_H
+# include "../../sys/sys/tree.h"
+#else
+# include <sys/tree.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <unistd.h>
+#include "localedef.h"
+#include "parser.h"
+
+
+typedef struct charmap {
+       const char *name;
+       wchar_t wc;
+       RB_ENTRY(charmap) rb_sym;
+       RB_ENTRY(charmap) rb_wc;
+} charmap_t;
+
+static int cmap_compare_sym(const void *n1, const void *n2);
+static int cmap_compare_wc(const void *n1, const void *n2);
+
+static RB_HEAD(cmap_sym, charmap) cmap_sym;
+static RB_HEAD(cmap_wc, charmap) cmap_wc;
+
+RB_GENERATE_STATIC(cmap_sym, charmap, rb_sym, cmap_compare_sym);
+RB_GENERATE_STATIC(cmap_wc, charmap, rb_wc, cmap_compare_wc);
+
+/*
+ * Array of POSIX specific portable characters.
+ */
+
+static const struct {
+       const char *name;
+       int     ch;
+} portable_chars[] = {
+       { "NUL",                '\0' },
+       { "alert",              '\a' },
+       { "backspace",          '\b' },
+       { "tab",                '\t' },
+       { "carriage-return",    '\r' },
+       { "newline",            '\n' },
+       { "vertical-tab",       '\v' },
+       { "form-feed",          '\f' },
+       { "space",              ' ' },
+       { "exclamation-mark",   '!' },
+       { "quotation-mark",     '"' },
+       { "number-sign",        '#' },
+       { "dollar-sign",        '$' },
+       { "percent-sign",       '%' },
+       { "ampersand",          '&' },
+       { "apostrophe",         '\'' },
+       { "left-parenthesis",   '(' },
+       { "right-parenthesis",  '(' },
+       { "asterisk",           '*' },
+       { "plus-sign",          '+' },
+       { "comma",               ','},
+       { "hyphen-minus",       '-' },
+       { "hyphen",             '-' },
+       { "full-stop",          '.' },
+       { "period",             '.' },
+       { "slash",              '/' },
+       { "solidus",            '/' },
+       { "zero",               '0' },
+       { "one",                '1' },
+       { "two",                '2' },
+       { "three",              '3' },
+       { "four",               '4' },
+       { "five",               '5' },
+       { "six",                '6' },



Home | Main Index | Thread Index | Old Index