[Midnightbsd-cvs] src [9688] trunk/lib: Update libiconv implementation from NetBSD & FreeBSD.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Dec 16 12:24:43 EST 2017


Revision: 9688
          http://svnweb.midnightbsd.org/src/?rev=9688
Author:   laffer1
Date:     2017-12-16 12:24:42 -0500 (Sat, 16 Dec 2017)
Log Message:
-----------
Update libiconv implementation from NetBSD & FreeBSD.

Add compatiblity shim for old binaries (libc_nonshared hack).

Introduce ldscript for libc to allow us to use stack protector on i386 later.

Modified Paths:
--------------
    trunk/Makefile.inc1
    trunk/include/iconv.h
    trunk/lib/libc/Makefile
    trunk/lib/libc/iconv/Makefile.inc
    trunk/lib/libc/iconv/Symbol.map
    trunk/lib/libc/iconv/__iconv_get_list.3
    trunk/lib/libc/iconv/_strtol.h
    trunk/lib/libc/iconv/_strtoul.h
    trunk/lib/libc/iconv/citrus_aliasname_local.h
    trunk/lib/libc/iconv/citrus_bcs.c
    trunk/lib/libc/iconv/citrus_bcs.h
    trunk/lib/libc/iconv/citrus_bcs_strtol.c
    trunk/lib/libc/iconv/citrus_bcs_strtoul.c
    trunk/lib/libc/iconv/citrus_csmapper.c
    trunk/lib/libc/iconv/citrus_csmapper.h
    trunk/lib/libc/iconv/citrus_db.c
    trunk/lib/libc/iconv/citrus_db.h
    trunk/lib/libc/iconv/citrus_db_factory.c
    trunk/lib/libc/iconv/citrus_db_factory.h
    trunk/lib/libc/iconv/citrus_db_file.h
    trunk/lib/libc/iconv/citrus_db_hash.c
    trunk/lib/libc/iconv/citrus_db_hash.h
    trunk/lib/libc/iconv/citrus_esdb.c
    trunk/lib/libc/iconv/citrus_esdb.h
    trunk/lib/libc/iconv/citrus_esdb_file.h
    trunk/lib/libc/iconv/citrus_fix_grouping.h
    trunk/lib/libc/iconv/citrus_hash.c
    trunk/lib/libc/iconv/citrus_hash.h
    trunk/lib/libc/iconv/citrus_iconv.c
    trunk/lib/libc/iconv/citrus_iconv.h
    trunk/lib/libc/iconv/citrus_iconv_local.h
    trunk/lib/libc/iconv/citrus_lock.h
    trunk/lib/libc/iconv/citrus_lookup.c
    trunk/lib/libc/iconv/citrus_lookup.h
    trunk/lib/libc/iconv/citrus_lookup_factory.c
    trunk/lib/libc/iconv/citrus_lookup_factory.h
    trunk/lib/libc/iconv/citrus_lookup_file.h
    trunk/lib/libc/iconv/citrus_mapper.c
    trunk/lib/libc/iconv/citrus_mapper.h
    trunk/lib/libc/iconv/citrus_mapper_local.h
    trunk/lib/libc/iconv/citrus_memstream.c
    trunk/lib/libc/iconv/citrus_memstream.h
    trunk/lib/libc/iconv/citrus_mmap.c
    trunk/lib/libc/iconv/citrus_mmap.h
    trunk/lib/libc/iconv/citrus_module.c
    trunk/lib/libc/iconv/citrus_module.h
    trunk/lib/libc/iconv/citrus_namespace.h
    trunk/lib/libc/iconv/citrus_none.c
    trunk/lib/libc/iconv/citrus_none.h
    trunk/lib/libc/iconv/citrus_pivot_factory.c
    trunk/lib/libc/iconv/citrus_pivot_factory.h
    trunk/lib/libc/iconv/citrus_pivot_file.h
    trunk/lib/libc/iconv/citrus_prop.c
    trunk/lib/libc/iconv/citrus_prop.h
    trunk/lib/libc/iconv/citrus_region.h
    trunk/lib/libc/iconv/citrus_stdenc.c
    trunk/lib/libc/iconv/citrus_stdenc.h
    trunk/lib/libc/iconv/citrus_stdenc_local.h
    trunk/lib/libc/iconv/citrus_stdenc_template.h
    trunk/lib/libc/iconv/citrus_types.h
    trunk/lib/libc/iconv/iconv.3
    trunk/lib/libc/iconv/iconv.c
    trunk/lib/libc/iconv/iconv_canonicalize.3
    trunk/lib/libc/iconv/iconvctl.3
    trunk/lib/libc/iconv/iconvlist.3

Added Paths:
-----------
    trunk/lib/libc/iconv/__iconv.c
    trunk/lib/libc/iconv/__iconv_free_list.c
    trunk/lib/libc/iconv/__iconv_get_list.c
    trunk/lib/libc/iconv/bsd_iconv.c
    trunk/lib/libc/iconv/iconv-internal.h
    trunk/lib/libc/iconv/iconv_canonicalize.c
    trunk/lib/libc/iconv/iconv_close.c
    trunk/lib/libc/iconv/iconv_compat.c
    trunk/lib/libc/iconv/iconv_open.c
    trunk/lib/libc/iconv/iconv_open_into.c
    trunk/lib/libc/iconv/iconv_set_relocation_prefix.c
    trunk/lib/libc/iconv/iconvctl.c
    trunk/lib/libc/iconv/iconvlist.c
    trunk/lib/libc/libc.ldscript
    trunk/lib/libc_nonshared/
    trunk/lib/libc_nonshared/Makefile
    trunk/lib/libc_nonshared/Makefile.iconv
    trunk/lib/libc_nonshared/__stub.c

Property Changed:
----------------
    trunk/lib/libc/iconv/Makefile.inc
    trunk/lib/libc/iconv/Symbol.map
    trunk/lib/libc/iconv/__iconv_get_list.3
    trunk/lib/libc/iconv/iconv.3
    trunk/lib/libc/iconv/iconv_canonicalize.3
    trunk/lib/libc/iconv/iconvctl.3
    trunk/lib/libc/iconv/iconvlist.3

Modified: trunk/Makefile.inc1
===================================================================
--- trunk/Makefile.inc1	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/Makefile.inc1	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1339,6 +1339,7 @@
 _startup_libs+=	gnu/lib/libgcc
 _startup_libs+=	lib/libcompiler_rt
 _startup_libs+=	lib/libc
+_startup_libs+=	lib/libc_nonshared
 .if ${MK_LIBCPLUSPLUS} != "no"
 _startup_libs+=	lib/libcxxrt
 .endif

Modified: trunk/include/iconv.h
===================================================================
--- trunk/include/iconv.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/include/iconv.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/*	$MidnightBSD$ */
+/*	$FreeBSD: stable/10/include/iconv.h 282275 2015-04-30 16:08:47Z tijl $	*/
 /*	$NetBSD: iconv.h,v 1.6 2005/02/03 04:39:32 perry Exp $	*/
 
 /*-
@@ -35,30 +36,32 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
-#include <stdbool.h>
 #include <wchar.h>
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
-#define iconv_open		libiconv_open
-#define iconv_close		libiconv_close
-#define iconv(cd, in, insize, out, outsize)	libiconv(cd, __DECONST(char **, in), insize, out, outsize)
-#define iconv_t			libiconv_t
+#ifdef __cplusplus
+typedef	bool	__iconv_bool;
+#elif __STDC_VERSION__ >= 199901L
+typedef	_Bool	__iconv_bool;
+#else
+typedef	int	__iconv_bool;
+#endif
 
 struct __tag_iconv_t;
 typedef	struct __tag_iconv_t	*iconv_t;
 
 __BEGIN_DECLS
-iconv_t	libiconv_open(const char *, const char *);
-size_t	libiconv(iconv_t, char ** __restrict,
-		     size_t * __restrict, char ** __restrict,
-		     size_t * __restrict);
-int	libiconv_close(iconv_t);
+iconv_t	iconv_open(const char *, const char *);
+size_t	iconv(iconv_t, char ** __restrict,
+	      size_t * __restrict, char ** __restrict,
+	      size_t * __restrict);
+int	iconv_close(iconv_t);
 /*
  * non-portable interfaces for iconv
  */
-int	__iconv_get_list(char ***, size_t *, bool);
+int	__iconv_get_list(char ***, size_t *, __iconv_bool);
 void	__iconv_free_list(char **, size_t);
 size_t	__iconv(iconv_t, char **, size_t *, char **,
 		     size_t *, __uint32_t, size_t *);
@@ -67,21 +70,12 @@
 /*
  * GNU interfaces for iconv
  */
-#define iconv_open_into		libiconv_open_into
-#define iconvctl		libiconvctl
-#define iconvlist		libiconvlist
-
-/* We have iconvctl() */
-#define _LIBICONV_VERSION	0x0108
-extern int _libiconv_version;
-
 typedef struct {
 	void	*spaceholder[64];
 } iconv_allocation_t;
 
 int	 iconv_open_into(const char *, const char *, iconv_allocation_t *);
-void	 libiconv_set_relocation_prefix (const char *orig_prefix,
-	     const char *curr_prefix);
+void	 iconv_set_relocation_prefix(const char *, const char *);
 
 /*
  * iconvctl() request macros
@@ -93,6 +87,8 @@
 #define ICONV_SET_DISCARD_ILSEQ	4
 #define ICONV_SET_HOOKS		5
 #define ICONV_SET_FALLBACKS	6
+#define ICONV_GET_ILSEQ_INVALID	128
+#define ICONV_SET_ILSEQ_INVALID	129
 
 typedef void (*iconv_unicode_char_hook) (unsigned int mbr, void *data);
 typedef void (*iconv_wide_char_hook) (wchar_t wc, void *data);

Modified: trunk/lib/libc/Makefile
===================================================================
--- trunk/lib/libc/Makefile	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/Makefile	2017-12-16 17:24:42 UTC (rev 9688)
@@ -24,6 +24,7 @@
 # to CFLAGS below.  -DSYSLIBC_SCCS affects just the system call stubs.
 LIB=c
 SHLIB_MAJOR= 7
+SHLIB_LDSCRIPT=libc.ldscript
 WARNS?=	2
 CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include
 CFLAGS+=-I${.CURDIR}/${LIBC_ARCH}

Modified: trunk/lib/libc/iconv/Makefile.inc
===================================================================
--- trunk/lib/libc/iconv/Makefile.inc	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/Makefile.inc	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/lib/libc/iconv/Makefile.inc 258750 2013-11-29 19:44:30Z gjb $
 
 # iconv sources
 .PATH: ${.CURDIR}/iconv
@@ -14,5 +15,9 @@
 	citrus_esdb.c citrus_hash.c citrus_iconv.c citrus_lookup.c \
 	citrus_lookup_factory.c citrus_mapper.c citrus_memstream.c \
 	citrus_mmap.c citrus_module.c citrus_none.c citrus_pivot_factory.c \
-	citrus_prop.c citrus_stdenc.c iconv.c
+	citrus_prop.c citrus_stdenc.c bsd_iconv.c iconv_compat.c
 SYM_MAPS+= ${.CURDIR}/iconv/Symbol.map
+
+.if ${MK_ICONV} == yes
+.include "${.CURDIR}/../libc_nonshared/Makefile.iconv"
+.endif


Property changes on: trunk/lib/libc/iconv/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/iconv/Symbol.map
===================================================================
--- trunk/lib/libc/iconv/Symbol.map	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/Symbol.map	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,20 +1,20 @@
 /*
  * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/iconv/Symbol.map 258398 2013-11-20 20:24:59Z peter $
  */
 
-FBSD_1.2 {
-	__iconv;
-	__iconv_free_list;
-	__iconv_get_list;
-	_libiconv_version;
-	iconv_canonicalize;
-	libiconv;
-	libiconv_close;
-	libiconv_open;
-	libiconv_open_into;
-	libiconv_set_relocation_prefix;
-	libiconvctl;
-	libiconvlist;
+FBSD_1.3 {
+	__bsd___iconv;
+	__bsd___iconv_free_list;
+	__bsd___iconv_get_list;
+	__bsd_iconv;
+	__bsd_iconv_canonicalize;
+	__bsd_iconv_close;
+	__bsd_iconv_open;
+	__bsd_iconv_open_into;
+	__bsd_iconv_set_relocation_prefix;
+	__bsd_iconvctl;
+	__bsd_iconvlist;
 };
 
 FBSDprivate_1.0 {
@@ -39,6 +39,7 @@
 	_citrus_bcs_strtoul;
 	_citrus_bcs_tolower;
 	_citrus_bcs_toupper;
+	_citrus_bcs_trunc_rws_len;
 	_citrus_bcs_trunc_ws_len;
 	_citrus_csmapper_open;
 	_citrus_csmapper_close;


Property changes on: trunk/lib/libc/iconv/Symbol.map
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/iconv/__iconv.c
===================================================================
--- trunk/lib/libc/iconv/__iconv.c	                        (rev 0)
+++ trunk/lib/libc/iconv/__iconv.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,39 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/__iconv.c 282275 2015-04-30 16:08:47Z tijl $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+size_t
+__iconv(iconv_t a, char **b, size_t *c, char **d,
+     size_t *e, __uint32_t f, size_t *g)
+{
+	return __bsd___iconv(a, b, c, d, e, f, g);
+}


Property changes on: trunk/lib/libc/iconv/__iconv.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/iconv/__iconv_free_list.c
===================================================================
--- trunk/lib/libc/iconv/__iconv_free_list.c	                        (rev 0)
+++ trunk/lib/libc/iconv/__iconv_free_list.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/__iconv_free_list.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+void
+__iconv_free_list(char **a, size_t b)
+{
+	__bsd___iconv_free_list(a, b);
+}


Property changes on: trunk/lib/libc/iconv/__iconv_free_list.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/iconv/__iconv_get_list.3
===================================================================
--- trunk/lib/libc/iconv/__iconv_get_list.3	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/__iconv_get_list.3	2017-12-16 17:24:42 UTC (rev 9688)
@@ -32,13 +32,14 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"	http://www.opengroup.org/unix/online.html.
 .\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/iconv/__iconv_get_list.3 321155 2017-07-18 18:35:41Z ngie $
+.\" $MidnightBSD$
 .\"
 .Dd October 20, 2009
 .Dt __ICONV_GET_LIST 3
 .Os
 .Sh NAME
-.Nm __iconv_get_list
+.Nm __iconv_get_list ,
 .Nm __iconv_free_list
 .Nd retrieving a list of character encodings supported by
 .Xr iconv 3


Property changes on: trunk/lib/libc/iconv/__iconv_get_list.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/iconv/__iconv_get_list.c
===================================================================
--- trunk/lib/libc/iconv/__iconv_get_list.c	                        (rev 0)
+++ trunk/lib/libc/iconv/__iconv_get_list.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/__iconv_get_list.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+int
+__iconv_get_list(char ***a, size_t *b, __iconv_bool c)
+{
+	return __bsd___iconv_get_list(a, b, c);
+}


Property changes on: trunk/lib/libc/iconv/__iconv_get_list.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/iconv/_strtol.h
===================================================================
--- trunk/lib/libc/iconv/_strtol.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/_strtol.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/_strtol.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: _strtol.h,v 1.2 2009/05/20 22:03:29 christos Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/_strtoul.h
===================================================================
--- trunk/lib/libc/iconv/_strtoul.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/_strtoul.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/_strtoul.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: _strtoul.h,v 1.1 2008/08/20 12:42:26 joerg Exp $ */
 
 /*-

Added: trunk/lib/libc/iconv/bsd_iconv.c
===================================================================
--- trunk/lib/libc/iconv/bsd_iconv.c	                        (rev 0)
+++ trunk/lib/libc/iconv/bsd_iconv.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,318 @@
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/bsd_iconv.c 309482 2016-12-03 16:52:40Z ngie $ */
+/* $NetBSD: iconv.c,v 1.11 2009/03/03 16:22:33 explorer Exp $ */
+
+/*-
+ * Copyright (c) 2003 Citrus Project,
+ * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor at FreeBSD.org>,
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <iconv.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "citrus_types.h"
+#include "citrus_module.h"
+#include "citrus_esdb.h"
+#include "citrus_hash.h"
+#include "citrus_iconv.h"
+
+#include "iconv-internal.h"
+
+#define ISBADF(_h_)	(!(_h_) || (_h_) == (iconv_t)-1)
+
+static iconv_t
+__bsd___iconv_open(const char *out, const char *in, struct _citrus_iconv *handle)
+{
+	const char *out_slashes;
+	char *out_noslashes;
+	int ret;
+
+	/*
+	 * Remove anything following a //, as these are options (like
+	 * //ignore, //translate, etc) and we just don't handle them.
+	 * This is for compatibility with software that uses these
+	 * blindly.
+	 */
+	out_slashes = strstr(out, "//");
+	if (out_slashes != NULL) {
+		out_noslashes = strndup(out, out_slashes - out);
+		if (out_noslashes == NULL) {
+			errno = ENOMEM;
+			return ((iconv_t)-1);
+		}
+		ret = _citrus_iconv_open(&handle, in, out_noslashes);
+		free(out_noslashes);
+	} else {
+		ret = _citrus_iconv_open(&handle, in, out);
+	}
+
+	if (ret) {
+		errno = ret == ENOENT ? EINVAL : ret;
+		return ((iconv_t)-1);
+	}
+
+	handle->cv_shared->ci_discard_ilseq = strcasestr(out, "//IGNORE");
+	handle->cv_shared->ci_ilseq_invalid = false;
+	handle->cv_shared->ci_hooks = NULL;
+
+	return ((iconv_t)(void *)handle);
+}
+
+iconv_t
+__bsd_iconv_open(const char *out, const char *in)
+{
+
+	return (__bsd___iconv_open(out, in, NULL));
+}
+
+int
+__bsd_iconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr)
+{
+	struct _citrus_iconv *handle;
+
+	handle = (struct _citrus_iconv *)ptr;
+	return ((__bsd___iconv_open(out, in, handle) == (iconv_t)-1) ? -1 : 0);
+}
+
+int
+__bsd_iconv_close(iconv_t handle)
+{
+
+	if (ISBADF(handle)) {
+		errno = EBADF;
+		return (-1);
+	}
+
+	_citrus_iconv_close((struct _citrus_iconv *)(void *)handle);
+
+	return (0);
+}
+
+size_t
+__bsd_iconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout)
+{
+	size_t ret;
+	int err;
+
+	if (ISBADF(handle)) {
+		errno = EBADF;
+		return ((size_t)-1);
+	}
+
+	err = _citrus_iconv_convert((struct _citrus_iconv *)(void *)handle,
+	    in, szin, out, szout, 0, &ret);
+	if (err) {
+		errno = err;
+		ret = (size_t)-1;
+	}
+
+	return (ret);
+}
+
+size_t
+__bsd___iconv(iconv_t handle, char **in, size_t *szin, char **out,
+    size_t *szout, uint32_t flags, size_t *invalids)
+{
+	size_t ret;
+	int err;
+
+	if (ISBADF(handle)) {
+		errno = EBADF;
+		return ((size_t)-1);
+	}
+
+	err = _citrus_iconv_convert((struct _citrus_iconv *)(void *)handle,
+	    in, szin, out, szout, flags, &ret);
+	if (invalids)
+		*invalids = ret;
+	if (err) {
+		errno = err;
+		ret = (size_t)-1;
+	}
+
+	return (ret);
+}
+
+int
+__bsd___iconv_get_list(char ***rlist, size_t *rsz, bool sorted)
+{
+	int ret;
+
+	ret = _citrus_esdb_get_list(rlist, rsz, sorted);
+	if (ret) {
+		errno = ret;
+		return (-1);
+	}
+
+	return (0);
+}
+
+void
+__bsd___iconv_free_list(char **list, size_t sz)
+{
+
+	_citrus_esdb_free_list(list, sz);
+}
+
+/*
+ * GNU-compatibile non-standard interfaces.
+ */
+static int
+qsort_helper(const void *first, const void *second)
+{
+	const char * const *s1;
+	const char * const *s2;
+
+	s1 = first;
+	s2 = second;
+	return (strcmp(*s1, *s2));
+}
+
+void
+__bsd_iconvlist(int (*do_one) (unsigned int, const char * const *,
+    void *), void *data)
+{
+	char **list, **names;
+	const char * const *np;
+	char *curitem, *curkey, *slashpos;
+	size_t sz;
+	unsigned int i, j;
+
+	i = 0;
+
+	if (__bsd___iconv_get_list(&list, &sz, true))
+		list = NULL;
+	qsort((void *)list, sz, sizeof(char *), qsort_helper);
+	while (i < sz) {
+		j = 0;
+		slashpos = strchr(list[i], '/');
+		curkey = (char *)malloc(slashpos - list[i] + 2);
+		names = (char **)malloc(sz * sizeof(char *));
+		if ((curkey == NULL) || (names == NULL)) {
+			__bsd___iconv_free_list(list, sz);
+			return;
+		}
+		strlcpy(curkey, list[i], slashpos - list[i] + 1);
+		names[j++] = curkey;
+		for (; (i < sz) && (memcmp(curkey, list[i], strlen(curkey)) == 0); i++) {
+			slashpos = strchr(list[i], '/');
+			curitem = (char *)malloc(strlen(slashpos) + 1);
+			if (curitem == NULL) {
+				__bsd___iconv_free_list(list, sz);
+				return;
+			}
+			strlcpy(curitem, &slashpos[1], strlen(slashpos) + 1);
+			if (strcmp(curkey, curitem) == 0) {
+				continue;
+			}
+			names[j++] = curitem;
+		}
+		np = (const char * const *)names;
+		do_one(j, np, data);
+		free(names);
+	}
+
+	__bsd___iconv_free_list(list, sz);
+}
+
+__inline const char *
+__bsd_iconv_canonicalize(const char *name)
+{
+
+	return (_citrus_iconv_canonicalize(name));
+}
+
+int
+__bsd_iconvctl(iconv_t cd, int request, void *argument)
+{
+	struct _citrus_iconv *cv;
+	struct iconv_hooks *hooks;
+	const char *convname;
+	char *dst;
+	int *i;
+	size_t srclen;
+
+	cv = (struct _citrus_iconv *)(void *)cd;
+	hooks = (struct iconv_hooks *)argument;
+	i = (int *)argument;
+
+	if (ISBADF(cd)) {
+		errno = EBADF;
+		return (-1);
+	}
+
+	switch (request) {
+	case ICONV_TRIVIALP:
+		convname = cv->cv_shared->ci_convname;
+		dst = strchr(convname, '/');
+		srclen = dst - convname;
+		dst++;
+		*i = (srclen == strlen(dst)) && !memcmp(convname, dst, srclen);
+		return (0);
+	case ICONV_GET_TRANSLITERATE:
+		*i = 1;
+		return (0);
+	case ICONV_SET_TRANSLITERATE:
+		return  ((*i == 1) ? 0 : -1);
+	case ICONV_GET_DISCARD_ILSEQ:
+		*i = cv->cv_shared->ci_discard_ilseq ? 1 : 0;
+		return (0);
+	case ICONV_SET_DISCARD_ILSEQ:
+		cv->cv_shared->ci_discard_ilseq = *i;
+		return (0);
+	case ICONV_SET_HOOKS:
+		cv->cv_shared->ci_hooks = hooks;
+		return (0);
+	case ICONV_SET_FALLBACKS:
+		errno = EOPNOTSUPP;
+		return (-1);
+	case ICONV_GET_ILSEQ_INVALID:
+		*i = cv->cv_shared->ci_ilseq_invalid ? 1 : 0;
+		return (0);
+	case ICONV_SET_ILSEQ_INVALID:
+		cv->cv_shared->ci_ilseq_invalid = *i;
+		return (0);
+	default:
+		errno = EINVAL;
+		return (-1);
+	}
+}
+
+void
+__bsd_iconv_set_relocation_prefix(const char *orig_prefix __unused,
+    const char *curr_prefix __unused)
+{
+
+}


Property changes on: trunk/lib/libc/iconv/bsd_iconv.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/iconv/citrus_aliasname_local.h
===================================================================
--- trunk/lib/libc/iconv/citrus_aliasname_local.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_aliasname_local.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_aliasname_local.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_aliasname_local.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_bcs.c
===================================================================
--- trunk/lib/libc/iconv/citrus_bcs.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_bcs.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_bcs.c 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_bcs.c,v 1.5 2005/05/14 17:55:42 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_bcs.h
===================================================================
--- trunk/lib/libc/iconv/citrus_bcs.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_bcs.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_bcs.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_bcs.h,v 1.6 2009/01/11 02:46:24 christos Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_bcs_strtol.c
===================================================================
--- trunk/lib/libc/iconv/citrus_bcs_strtol.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_bcs_strtol.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_bcs_strtol.c,v 1.2 2009/01/11 02:46:24 christos Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_bcs_strtol.c 264497 2014-04-15 09:49:44Z tijl $ */
+/* $NetBSD: citrus_bcs_strtol.c,v 1.4 2013/04/26 21:20:47 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.

Modified: trunk/lib/libc/iconv/citrus_bcs_strtoul.c
===================================================================
--- trunk/lib/libc/iconv/citrus_bcs_strtoul.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_bcs_strtoul.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_bcs_strtoul.c,v 1.3 2009/01/11 02:46:24 christos Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_bcs_strtoul.c 264497 2014-04-15 09:49:44Z tijl $ */
+/* $NetBSD: citrus_bcs_strtoul.c,v 1.5 2013/04/26 21:20:48 joerg Exp $ */
 
 /*-
  * Copyright (c) 2005 The DragonFly Project.  All rights reserved.

Modified: trunk/lib/libc/iconv/citrus_csmapper.c
===================================================================
--- trunk/lib/libc/iconv/citrus_csmapper.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_csmapper.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_csmapper.c,v 1.10 2009/01/11 02:46:24 christos Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_csmapper.c 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_csmapper.c,v 1.11 2011/11/20 07:43:52 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -58,6 +59,8 @@
 
 static struct _citrus_mapper_area	*maparea = NULL;
 
+static pthread_rwlock_t			ma_lock = PTHREAD_RWLOCK_INITIALIZER;
+
 #define CS_ALIAS	_PATH_CSMAPPER "/charset.alias"
 #define CS_PIVOT	_PATH_CSMAPPER "/charset.pivot"
 
@@ -138,6 +141,7 @@
 		if (ret)
 			goto quit3;
 		if (_db_lookup_by_s(db3, dst, &r2, NULL) != 0)
+			/* don't break the loop, test all src/dst pairs. */
 			goto quit4;
 		/* r2: norm among pivot and dst */
 		ret = get32(&r2, &val32);
@@ -314,7 +318,7 @@
 {
 	int ret;
 
-	WLOCK;
+	WLOCK(&ma_lock);
 	if (csm_none) {
 		*rcsm = csm_none;
 		ret = 0;
@@ -329,7 +333,7 @@
 	*rcsm = csm_none;
 	ret = 0;
 quit:
-	UNLOCK;
+	UNLOCK(&ma_lock);
 	return (ret);
 }
 

Modified: trunk/lib/libc/iconv/citrus_csmapper.h
===================================================================
--- trunk/lib/libc/iconv/citrus_csmapper.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_csmapper.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
 /* $MidnightBSD$ */
-/* $NetBSD: citrus_csmapper.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_csmapper.h 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_csmapper.h,v 1.3 2013/06/24 17:28:35 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: trunk/lib/libc/iconv/citrus_db.c
===================================================================
--- trunk/lib/libc/iconv/citrus_db.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db.c 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_db.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_db.h
===================================================================
--- trunk/lib/libc/iconv/citrus_db.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_db.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_db_factory.c
===================================================================
--- trunk/lib/libc/iconv/citrus_db_factory.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db_factory.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_db_factory.c,v 1.9 2008/02/09 14:56:20 junyoung Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db_factory.c 267665 2014-06-20 07:32:03Z tijl $ */
+/*	$NetBSD: citrus_db_factory.c,v 1.10 2013/09/14 13:05:51 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -228,15 +229,6 @@
 }
 
 static __inline void
-put16(struct _region *r, size_t *rofs, uint16_t val)
-{
-
-	val = htons(val);
-	memcpy(_region_offset(r, *rofs), &val, 2);
-	*rofs += 2;
-}
-
-static __inline void
 put32(struct _region *r, size_t *rofs, uint32_t val)
 {
 
@@ -279,11 +271,9 @@
 		return (0);
 	}
 	/* allocate hash table */
-	depp = malloc(sizeof(*depp) * df->df_num_entries);
+	depp = calloc(df->df_num_entries, sizeof(*depp));
 	if (depp == NULL)
 		return (-1);
-	for (i = 0; i < df->df_num_entries; i++)
-		depp[i] = NULL;
 
 	/* step1: store the entries which are not conflicting */
 	STAILQ_FOREACH(de, &df->df_entries, de_entry) {

Modified: trunk/lib/libc/iconv/citrus_db_factory.h
===================================================================
--- trunk/lib/libc/iconv/citrus_db_factory.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db_factory.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db_factory.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_db_factory.h,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_db_file.h
===================================================================
--- trunk/lib/libc/iconv/citrus_db_file.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db_file.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db_file.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_db_file.h,v 1.4 2008/02/10 05:58:22 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_db_hash.c
===================================================================
--- trunk/lib/libc/iconv/citrus_db_hash.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db_hash.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db_hash.c 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_db_hash.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_db_hash.h
===================================================================
--- trunk/lib/libc/iconv/citrus_db_hash.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_db_hash.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_db_hash.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_db_hash.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_esdb.c
===================================================================
--- trunk/lib/libc/iconv/citrus_esdb.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_esdb.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_esdb.c 291799 2015-12-04 18:24:47Z bdrewery $ */
 /* $NetBSD: citrus_esdb.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-
@@ -328,7 +329,7 @@
 			    (int)_region_size(&data),
 			    (const char *)_region_head(&data));
 			if ((p = strchr(buf1, '/')) != NULL)
-				memcpy(buf1, p + 1, strlen(p) - 1);
+				memmove(buf1, p + 1, strlen(p) - 1);
 			if ((p = strstr(buf1, ".esdb")) != NULL)
 				*p = '\0';
 			snprintf(buf, sizeof(buf), "%s/%.*s", buf1,

Modified: trunk/lib/libc/iconv/citrus_esdb.h
===================================================================
--- trunk/lib/libc/iconv/citrus_esdb.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_esdb.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_esdb.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_esdb.h,v 1.1 2003/06/25 09:51:32 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_esdb_file.h
===================================================================
--- trunk/lib/libc/iconv/citrus_esdb_file.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_esdb_file.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_esdb_file.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_esdb_file.h,v 1.1 2003/06/25 09:51:32 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_fix_grouping.h
===================================================================
--- trunk/lib/libc/iconv/citrus_fix_grouping.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_fix_grouping.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_fix_grouping.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_fix_grouping.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_hash.c
===================================================================
--- trunk/lib/libc/iconv/citrus_hash.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_hash.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_hash.c 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_hash.c,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_hash.h
===================================================================
--- trunk/lib/libc/iconv/citrus_hash.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_hash.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_hash.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_hash.h,v 1.3 2004/01/02 21:49:35 itojun Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_iconv.c
===================================================================
--- trunk/lib/libc/iconv/citrus_iconv.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_iconv.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
 /* $MidnightBSD$ */
-/* $NetBSD: citrus_iconv.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_iconv.c 267665 2014-06-20 07:32:03Z tijl $ */
+/*	$NetBSD: citrus_iconv.c,v 1.10 2011/11/19 18:34:21 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -68,11 +69,13 @@
 static _CITRUS_HASH_HEAD(, _citrus_iconv_shared, CI_HASH_SIZE) shared_pool;
 static TAILQ_HEAD(, _citrus_iconv_shared) shared_unused;
 
+static pthread_rwlock_t		 ci_lock = PTHREAD_RWLOCK_INITIALIZER;
+
 static __inline void
 init_cache(void)
 {
 
-	WLOCK;
+	WLOCK(&ci_lock);
 	if (!isinit) {
 		_CITRUS_HASH_INIT(&shared_pool, CI_HASH_SIZE);
 		TAILQ_INIT(&shared_unused);
@@ -83,7 +86,7 @@
 			shared_max_reuse = CI_INITIAL_MAX_REUSE;
 		isinit = true;
 	}
-	UNLOCK;
+	UNLOCK(&ci_lock);
 }
 
 static __inline void
@@ -114,10 +117,20 @@
 	size_t len_convname;
 	int ret;
 
- 	/* incompatible with GNU iconv due to gettext 0.18.3+
-        module = (strcmp(src, dst) != 0) ? "iconv_std" : "iconv_none";
-	*/
+#ifdef INCOMPATIBLE_WITH_GNU_ICONV
+	/*
+	 * Sadly, the gnu tools expect iconv to actually parse the
+	 * byte stream and don't allow for a pass-through when
+	 * the (src,dest) encodings are the same.
+	 * See gettext-0.18.3+ NEWS:
+	 *   msgfmt now checks PO file headers more strictly with less
+	 *   false-positives.
+	 * NetBSD don't do this either.
+	 */
+	module = (strcmp(src, dst) != 0) ? "iconv_std" : "iconv_none";
+#else
 	module = "iconv_std";
+#endif
 
 	/* initialize iconv handle */
 	len_convname = strlen(convname);
@@ -157,8 +170,10 @@
 	    ci->ci_ops->io_uninit_shared == NULL ||
 	    ci->ci_ops->io_init_context == NULL ||
 	    ci->ci_ops->io_uninit_context == NULL ||
-	    ci->ci_ops->io_convert == NULL)
+	    ci->ci_ops->io_convert == NULL) {
+		ret = EINVAL;
 		goto err;
+	}
 
 	/* initialize the converter */
 	ret = (*ci->ci_ops->io_init_shared)(ci, src, dst);
@@ -198,7 +213,7 @@
 
 	snprintf(convname, sizeof(convname), "%s/%s", src, dst);
 
-	WLOCK;
+	WLOCK(&ci_lock);
 
 	/* lookup alread existing entry */
 	hashval = hash_func(convname);
@@ -225,7 +240,7 @@
 	*rci = ci;
 
 quit:
-	UNLOCK;
+	UNLOCK(&ci_lock);
 
 	return (ret);
 }
@@ -234,7 +249,7 @@
 release_shared(struct _citrus_iconv_shared * __restrict ci)
 {
 
-	WLOCK;
+	WLOCK(&ci_lock);
 	ci->ci_used_count--;
 	if (ci->ci_used_count == 0) {
 		/* put it into unused list */
@@ -250,7 +265,7 @@
 		}
 	}
 
-	UNLOCK;
+	UNLOCK(&ci_lock);
 }
 
 /*
@@ -261,7 +276,7 @@
 _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
     const char * __restrict src, const char * __restrict dst)
 {
-	struct _citrus_iconv *cv;
+	struct _citrus_iconv *cv = NULL;
 	struct _citrus_iconv_shared *ci = NULL;
 	char realdst[PATH_MAX], realsrc[PATH_MAX];
 	char buf[PATH_MAX], path[PATH_MAX];
@@ -304,7 +319,7 @@
 	ret = (*ci->ci_ops->io_init_context)(*rcv);
 	if (ret) {
 		release_shared(ci);
-		free(*rcv);
+		free(cv);
 		return (ret);
 	}
 	return (0);
@@ -330,9 +345,8 @@
 {
 	char *buf;
 
-	if ((buf = malloc((size_t)PATH_MAX)) == NULL)
+	if ((buf = calloc((size_t)PATH_MAX, sizeof(*buf))) == NULL)
 		return (NULL);
-	memset((void *)buf, 0, (size_t)PATH_MAX);
 	_citrus_esdb_alias(name, buf, (size_t)PATH_MAX);
 	return (buf);
 }

Modified: trunk/lib/libc/iconv/citrus_iconv.h
===================================================================
--- trunk/lib/libc/iconv/citrus_iconv.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_iconv.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_iconv.h 282275 2015-04-30 16:08:47Z tijl $ */
 /* $NetBSD: citrus_iconv.h,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_iconv_local.h
===================================================================
--- trunk/lib/libc/iconv/citrus_iconv_local.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_iconv_local.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_iconv_local.h 282275 2015-04-30 16:08:47Z tijl $ */
 /* $NetBSD: citrus_iconv_local.h,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-
@@ -31,6 +32,7 @@
 #define _CITRUS_ICONV_LOCAL_H_
 
 #include <iconv.h>
+#include <stdbool.h>
 
 #define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_)				\
     int _n_(struct _citrus_iconv_ops *)
@@ -57,6 +59,7 @@
 
 
 #define _CITRUS_ICONV_DEF_OPS(_m_)					\
+extern struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops;		\
 struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = {			\
 	/* io_init_shared */	&_citrus_##_m_##_iconv_init_shared,	\
 	/* io_uninit_shared */	&_citrus_##_m_##_iconv_uninit_shared,	\
@@ -97,6 +100,7 @@
 	char						*ci_convname;
 	bool						 ci_discard_ilseq;
 	struct iconv_hooks				*ci_hooks;
+	bool						 ci_ilseq_invalid;
 };
 
 struct _citrus_iconv {

Modified: trunk/lib/libc/iconv/citrus_lock.h
===================================================================
--- trunk/lib/libc/iconv/citrus_lock.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_lock.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_lock.h 252584 2013-07-03 18:35:21Z peter $ */
 /*-
  * Copyright (C) 2010 Gabor Kovesdan <gabor at FreeBSD.org>
  * All rights reserved.
@@ -27,9 +28,7 @@
 
 #include <pthread.h>
 
-static pthread_rwlock_t	lock;
-
-#define WLOCK	if (__isthreaded)		\
-		    pthread_rwlock_wrlock(&lock);
-#define UNLOCK	if (__isthreaded)		\
-		    pthread_rwlock_unlock(&lock);
+#define WLOCK(lock)	if (__isthreaded)		\
+			    pthread_rwlock_wrlock(lock);
+#define UNLOCK(lock)	if (__isthreaded)		\
+			    pthread_rwlock_unlock(lock);

Modified: trunk/lib/libc/iconv/citrus_lookup.c
===================================================================
--- trunk/lib/libc/iconv/citrus_lookup.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_lookup.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_lookup.c,v 1.6 2009/02/03 04:58:38 lukem Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_lookup.c 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_lookup.c,v 1.7 2012/05/04 16:45:05 joerg Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,

Modified: trunk/lib/libc/iconv/citrus_lookup.h
===================================================================
--- trunk/lib/libc/iconv/citrus_lookup.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_lookup.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_lookup.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_lookup.h,v 1.2 2004/07/21 14:16:34 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_lookup_factory.c
===================================================================
--- trunk/lib/libc/iconv/citrus_lookup_factory.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_lookup_factory.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_lookup_factory.c 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_lookup_factory.c,v 1.4 2003/10/27 00:12:42 lukem Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_lookup_factory.h
===================================================================
--- trunk/lib/libc/iconv/citrus_lookup_factory.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_lookup_factory.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_lookup_factory.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_lookup_factory.h,v 1.1 2003/06/25 09:51:35 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_lookup_file.h
===================================================================
--- trunk/lib/libc/iconv/citrus_lookup_file.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_lookup_file.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_lookup_file.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_lookup_file.h,v 1.1 2003/06/25 09:51:36 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_mapper.c
===================================================================
--- trunk/lib/libc/iconv/citrus_mapper.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_mapper.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_mapper.c,v 1.7 2008/07/25 14:05:25 christos Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_mapper.c 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_mapper.c,v 1.10 2012/06/08 07:49:42 martin Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -55,6 +56,8 @@
 #define CM_HASH_SIZE 101
 #define REFCOUNT_PERSISTENT	-1
 
+static pthread_rwlock_t		cm_lock = PTHREAD_RWLOCK_INITIALIZER;
+
 struct _citrus_mapper_area {
 	_CITRUS_HASH_HEAD(, _citrus_mapper, CM_HASH_SIZE)	 ma_cache;
 	char							*ma_dir;
@@ -75,7 +78,7 @@
 	char path[PATH_MAX];
 	int ret;
 
-	WLOCK;
+	WLOCK(&cm_lock);
 
 	if (*rma != NULL) {
 		ret = 0;
@@ -96,7 +99,7 @@
 	ma->ma_dir = strdup(area);
 	if (ma->ma_dir == NULL) {
 		ret = errno;
-		free(ma->ma_dir);
+		free(ma);
 		goto quit;
 	}
 	_CITRUS_HASH_INIT(&ma->ma_cache, CM_HASH_SIZE);
@@ -104,7 +107,7 @@
 	*rma = ma;
 	ret = 0;
 quit:
-	UNLOCK;
+	UNLOCK(&cm_lock);
 
 	return (ret);
 }
@@ -242,8 +245,10 @@
 	if (!cm->cm_ops->mo_init ||
 	    !cm->cm_ops->mo_uninit ||
 	    !cm->cm_ops->mo_convert ||
-	    !cm->cm_ops->mo_init_state)
+	    !cm->cm_ops->mo_init_state) {
+		ret = EINVAL;
 		goto err;
+	}
 
 	/* allocate traits structure */
 	cm->cm_traits = malloc(sizeof(*cm->cm_traits));
@@ -316,7 +321,7 @@
 
 	variable = NULL;
 
-	WLOCK;
+	WLOCK(&cm_lock);
 
 	/* search in the cache */
 	hashval = hash_func(mapname);
@@ -337,9 +342,9 @@
 		goto quit;
 
 	/* open mapper */
-	UNLOCK;
+	UNLOCK(&cm_lock);
 	ret = mapper_open(ma, &cm, module, variable);
-	WLOCK;
+	WLOCK(&cm_lock);
 	if (ret)
 		goto quit;
 	cm->cm_key = strdup(mapname);
@@ -356,7 +361,7 @@
 	*rcm = cm;
 	ret = 0;
 quit:
-	UNLOCK;
+	UNLOCK(&cm_lock);
 
 	return (ret);
 }
@@ -370,7 +375,7 @@
 {
 
 	if (cm) {
-		WLOCK;
+		WLOCK(&cm_lock);
 		if (cm->cm_refcount == REFCOUNT_PERSISTENT)
 			goto quit;
 		if (cm->cm_refcount > 0) {
@@ -379,9 +384,11 @@
 			_CITRUS_HASH_REMOVE(cm, cm_entry);
 			free(cm->cm_key);
 		}
+		UNLOCK(&cm_lock);
 		mapper_close(cm);
+		return;
 quit:
-		UNLOCK;
+		UNLOCK(&cm_lock);
 	}
 }
 
@@ -393,7 +400,7 @@
 _citrus_mapper_set_persistent(struct _citrus_mapper * __restrict cm)
 {
 
-	WLOCK;
+	WLOCK(&cm_lock);
 	cm->cm_refcount = REFCOUNT_PERSISTENT;
-	UNLOCK;
+	UNLOCK(&cm_lock);
 }

Modified: trunk/lib/libc/iconv/citrus_mapper.h
===================================================================
--- trunk/lib/libc/iconv/citrus_mapper.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_mapper.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_mapper.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_mapper.h,v 1.3 2003/07/12 15:39:19 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_mapper_local.h
===================================================================
--- trunk/lib/libc/iconv/citrus_mapper_local.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_mapper_local.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_mapper_local.h 250938 2013-05-23 18:07:01Z ed $ */
 /* $NetBSD: citrus_mapper_local.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-
@@ -52,6 +53,7 @@
 		    (void);
 
 #define _CITRUS_MAPPER_DEF_OPS(_m_)					\
+extern struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops;		\
 struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = {		\
 	/* mo_init */		&_citrus_##_m_##_mapper_init,		\
 	/* mo_uninit */		&_citrus_##_m_##_mapper_uninit,		\

Modified: trunk/lib/libc/iconv/citrus_memstream.c
===================================================================
--- trunk/lib/libc/iconv/citrus_memstream.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_memstream.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_memstream.c 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -44,8 +45,7 @@
     size_t * __restrict rlen)
 {
 	const uint8_t *h, *p;
-	size_t ret;
-	int i;
+	size_t i, ret;
 
 	if (ms->ms_pos>=_region_size(&ms->ms_region))
 		return (NULL);

Modified: trunk/lib/libc/iconv/citrus_memstream.h
===================================================================
--- trunk/lib/libc/iconv/citrus_memstream.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_memstream.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_memstream.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_memstream.h,v 1.3 2005/05/14 17:55:42 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_mmap.c
===================================================================
--- trunk/lib/libc/iconv/citrus_mmap.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_mmap.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_mmap.c,v 1.3 2005/01/19 00:52:37 mycroft Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_mmap.c 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -57,12 +58,8 @@
 
 	_region_init(r, NULL, 0);
 
-	if ((fd = open(path, O_RDONLY)) == -1)
+	if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1)
 		return (errno);
-	if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
-		ret = errno;
-		goto error;
-	}
 
 	if (fstat(fd, &st)  == -1) {
 		ret = errno;

Modified: trunk/lib/libc/iconv/citrus_mmap.h
===================================================================
--- trunk/lib/libc/iconv/citrus_mmap.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_mmap.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_mmap.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_mmap.h,v 1.1 2003/06/25 09:51:38 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_module.c
===================================================================
--- trunk/lib/libc/iconv/citrus_module.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_module.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_module.c 228843 2011-12-23 15:00:37Z cperciva $ */
 /* $NetBSD: citrus_module.c,v 1.9 2009/01/11 02:46:24 christos Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_module.h
===================================================================
--- trunk/lib/libc/iconv/citrus_module.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_module.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_module.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_module.h,v 1.1 2002/03/17 22:14:20 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_namespace.h
===================================================================
--- trunk/lib/libc/iconv/citrus_namespace.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_namespace.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_namespace.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_namespace.h,v 1.8 2009/01/11 02:46:24 christos Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_none.c
===================================================================
--- trunk/lib/libc/iconv/citrus_none.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_none.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_none.c 282275 2015-04-30 16:08:47Z tijl $ */
 /* $NetBSD: citrus_none.c,v 1.18 2008/06/14 16:01:07 tnozaki Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_none.h
===================================================================
--- trunk/lib/libc/iconv/citrus_none.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_none.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_none.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_none.h,v 1.3 2003/06/25 09:51:38 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_pivot_factory.c
===================================================================
--- trunk/lib/libc/iconv/citrus_pivot_factory.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_pivot_factory.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_pivot_factory.c 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_pivot_factory.c,v 1.7 2009/04/12 14:20:19 lukem Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_pivot_factory.h
===================================================================
--- trunk/lib/libc/iconv/citrus_pivot_factory.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_pivot_factory.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_pivot_factory.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_pivot_factory.h,v 1.1 2003/06/25 09:51:39 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_pivot_file.h
===================================================================
--- trunk/lib/libc/iconv/citrus_pivot_file.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_pivot_file.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_pivot_file.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_pivot_file.h,v 1.1 2003/06/25 09:51:39 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_prop.c
===================================================================
--- trunk/lib/libc/iconv/citrus_prop.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_prop.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_prop.c 264497 2014-04-15 09:49:44Z tijl $ */
+/* $NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -339,7 +340,7 @@
 
 static int
 _citrus_prop_parse_element(struct _memstream * __restrict ms,
-    const _citrus_prop_hint_t * __restrict hints, void ** __restrict context)
+    const _citrus_prop_hint_t * __restrict hints, void * __restrict context)
 {
 	int ch, errnum;
 #define _CITRUS_PROP_HINT_NAME_LEN_MAX	255
@@ -435,8 +436,7 @@
 		if (ch == EOF || ch == '\0')
 			break;
 		_memstream_ungetc(&ms, ch);
-		errnum = _citrus_prop_parse_element(
-		    &ms, hints, (void ** __restrict)context);
+		errnum = _citrus_prop_parse_element(&ms, hints, context);
 		if (errnum != 0)
 			return (errnum);
 	}

Modified: trunk/lib/libc/iconv/citrus_prop.h
===================================================================
--- trunk/lib/libc/iconv/citrus_prop.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_prop.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_prop.h,v 1.3 2006/11/23 13:59:03 tnozaki Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_prop.h 264497 2014-04-15 09:49:44Z tijl $ */
+/* $NetBSD: citrus_prop.h,v 1.5 2011/05/23 14:52:32 joerg Exp $ */
 
 /*-
  * Copyright (c)2006 Citrus Project,
@@ -42,7 +43,7 @@
 
 #define _CITRUS_PROP_CB0_T(_func_, _type_) \
 typedef int (*_citrus_prop_##_func_##_cb_func_t) \
-    (void ** __restrict, const char *, _type_); \
+    (void * __restrict, const char *, _type_); \
 typedef struct { \
 	_citrus_prop_##_func_##_cb_func_t func; \
 } _citrus_prop_##_func_##_cb_t;
@@ -52,7 +53,7 @@
 
 #define _CITRUS_PROP_CB1_T(_func_, _type_) \
 typedef int (*_citrus_prop_##_func_##_cb_func_t) \
-    (void ** __restrict, const char *, _type_, _type_); \
+    (void * __restrict, const char *, _type_, _type_); \
 typedef struct { \
 	_citrus_prop_##_func_##_cb_func_t func; \
 } _citrus_prop_##_func_##_cb_t;
@@ -82,7 +83,7 @@
 #define _CITRUS_PROP_HINT_NUM(name, cb) \
     { name, _CITRUS_PROP_NUM, { .num = { cb } } }
 #define _CITRUS_PROP_HINT_END \
-    { NULL, _CITRUS_PROP_NUM, { .num = { 0 } } }
+    { .name = NULL }
 
 __BEGIN_DECLS
 int	 _citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict,

Modified: trunk/lib/libc/iconv/citrus_region.h
===================================================================
--- trunk/lib/libc/iconv/citrus_region.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_region.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_region.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_region.h,v 1.7 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_stdenc.c
===================================================================
--- trunk/lib/libc/iconv/citrus_stdenc.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_stdenc.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,5 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: citrus_stdenc.c,v 1.3 2005/10/29 18:02:04 tshiozak Exp $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_stdenc.c 264497 2014-04-15 09:49:44Z tijl $ */
+/*	$NetBSD: citrus_stdenc.c,v 1.4 2011/11/19 18:39:58 tnozaki Exp $	*/
 
 /*-
  * Copyright (c)2003 Citrus Project,
@@ -102,8 +103,10 @@
 	    ce->ce_ops->eo_cstomb == NULL ||
 	    ce->ce_ops->eo_mbtowc == NULL ||
 	    ce->ce_ops->eo_wctomb == NULL ||
-	    ce->ce_ops->eo_get_state_desc == NULL)
+	    ce->ce_ops->eo_get_state_desc == NULL) {
+		ret = EINVAL;
 		goto bad;
+	}
 
 	/* allocate traits */
 	ce->ce_traits = malloc(sizeof(*ce->ce_traits));

Modified: trunk/lib/libc/iconv/citrus_stdenc.h
===================================================================
--- trunk/lib/libc/iconv/citrus_stdenc.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_stdenc.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_stdenc.h 282275 2015-04-30 16:08:47Z tijl $ */
 /* $NetBSD: citrus_stdenc.h,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_stdenc_local.h
===================================================================
--- trunk/lib/libc/iconv/citrus_stdenc_local.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_stdenc_local.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_stdenc_local.h 282275 2015-04-30 16:08:47Z tijl $ */
 /* $NetBSD: citrus_stdenc_local.h,v 1.4 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-
@@ -84,6 +85,7 @@
 		    struct _citrus_stdenc_state_desc * __restrict)
 
 #define _CITRUS_STDENC_DEF_OPS(_e_)					\
+extern struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops;		\
 struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = {		\
 	/* eo_init */		&_citrus_##_e_##_stdenc_init,		\
 	/* eo_uninit */		&_citrus_##_e_##_stdenc_uninit,		\

Modified: trunk/lib/libc/iconv/citrus_stdenc_template.h
===================================================================
--- trunk/lib/libc/iconv/citrus_stdenc_template.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_stdenc_template.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_stdenc_template.h 282275 2015-04-30 16:08:47Z tijl $ */
 /* $NetBSD: citrus_stdenc_template.h,v 1.4 2008/02/09 14:56:20 junyoung Exp $ */
 
 /*-

Modified: trunk/lib/libc/iconv/citrus_types.h
===================================================================
--- trunk/lib/libc/iconv/citrus_types.h	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/citrus_types.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-/* $FreeBSD$ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/iconv/citrus_types.h 219019 2011-02-25 00:04:39Z gabor $ */
 /* $NetBSD: citrus_types.h,v 1.3 2003/10/27 00:12:42 lukem Exp $ */
 
 /*-

Added: trunk/lib/libc/iconv/iconv-internal.h
===================================================================
--- trunk/lib/libc/iconv/iconv-internal.h	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv-internal.h	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,46 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv-internal.h 282275 2015-04-30 16:08:47Z tijl $
+ */
+
+/*
+ * Interal prototypes for our back-end functions.
+ */
+size_t	__bsd___iconv(iconv_t, char **, size_t *, char **,
+		size_t *, __uint32_t, size_t *);
+void	__bsd___iconv_free_list(char **, size_t);
+int	__bsd___iconv_get_list(char ***, size_t *, __iconv_bool);
+size_t	__bsd_iconv(iconv_t, char ** __restrict,
+		    size_t * __restrict, char ** __restrict,
+		    size_t * __restrict);
+const char *__bsd_iconv_canonicalize(const char *);
+int	__bsd_iconv_close(iconv_t);
+iconv_t	__bsd_iconv_open(const char *, const char *);
+int	__bsd_iconv_open_into(const char *, const char *, iconv_allocation_t *);
+void	__bsd_iconv_set_relocation_prefix(const char *, const char *);
+int	__bsd_iconvctl(iconv_t, int, void *);
+void	__bsd_iconvlist(int (*) (unsigned int, const char * const *, void *), void *);


Property changes on: trunk/lib/libc/iconv/iconv-internal.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/iconv/iconv.3
===================================================================
--- trunk/lib/libc/iconv/iconv.3	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/iconv.3	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,4 +1,5 @@
-.\" $FreeBSD$
+.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/iconv/iconv.3 282275 2015-04-30 16:08:47Z tijl $
 .\" $NetBSD: iconv.3,v 1.12 2004/08/02 13:38:21 tshiozak Exp $
 .\"
 .\" Copyright (c) 2003 Citrus Project,
@@ -26,7 +27,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd Juny 16, 2010
+.Dd June 16, 2010
 .Dt ICONV 3
 .Os
 .Sh NAME
@@ -48,7 +49,7 @@
 .Ft size_t
 .Fn iconv "iconv_t cd" "char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft"
 .Ft size_t
-.Fn __iconv "iconv_t cd" "const char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft" "uint32_t flags" "size_t invalids"
+.Fn __iconv "iconv_t cd" "char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft" "uint32_t flags" "size_t * invalids"
 .Sh DESCRIPTION
 The
 .Fn iconv_open


Property changes on: trunk/lib/libc/iconv/iconv.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/iconv/iconv.c
===================================================================
--- trunk/lib/libc/iconv/iconv.c	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/iconv.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -1,9 +1,6 @@
-/* $FreeBSD$ */
-/* $NetBSD: iconv.c,v 1.11 2009/03/03 16:22:33 explorer Exp $ */
-
+/* $MidnightBSD$ */
 /*-
- * Copyright (c) 2003 Citrus Project,
- * Copyright (c) 2009, 2010 Gabor Kovesdan <gabor at FreeBSD.org>,
+ * Copyright (c) 2013 Peter Wemm
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -26,307 +23,18 @@
  * 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: stable/10/lib/libc/iconv/iconv.c 282275 2015-04-30 16:08:47Z tijl $
  */
 
-#include <sys/cdefs.h>
-#include <sys/queue.h>
 #include <sys/types.h>
-
-#include <assert.h>
-#include <errno.h>
 #include <iconv.h>
-#include <limits.h>
-#include <paths.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
+#include "iconv-internal.h"
 
-#include "citrus_types.h"
-#include "citrus_module.h"
-#include "citrus_esdb.h"
-#include "citrus_hash.h"
-#include "citrus_iconv.h"
-
-#ifdef __weak_alias
-__weak_alias(libiconv, _iconv)
-__weak_alias(libiconv_open, _iconv_open)
-__weak_alias(libiconv_open_into, _iconv_open_into)
-__weak_alias(libiconv_close, _iconv_close)
-__weak_alias(libiconvlist, _iconvlist)
-__weak_alias(libiconvctl, _iconvctl)
-__weak_alias(libiconv_set_relocation_prefix, _iconv_set_relocation_prefix)
-__weak_alias(iconv_canonicalize, _iconv_canonicalize)
-#endif
-
-#define ISBADF(_h_)	(!(_h_) || (_h_) == (iconv_t)-1)
-
-int _libiconv_version = _LIBICONV_VERSION;
-
-iconv_t		 _iconv_open(const char *out, const char *in,
-		    struct _citrus_iconv *prealloc);
-
-iconv_t
-_iconv_open(const char *out, const char *in, struct _citrus_iconv *prealloc)
-{
-	struct _citrus_iconv *handle;
-	char *out_truncated, *p;
-	int ret;
-
-	handle = prealloc;
-
-	/*
-	 * Remove anything following a //, as these are options (like
-	 * //ignore, //translate, etc) and we just don't handle them.
-	 * This is for compatibilty with software that uses thees
-	 * blindly.
-	 */
-	out_truncated = strdup(out);
-	if (out_truncated == NULL) {
-		errno = ENOMEM;
-		return ((iconv_t)-1);
-	}
-
-	p = out_truncated;
-        while (*p != 0) {
-                if (p[0] == '/' && p[1] == '/') {
-                        *p = '\0';
-                        break;
-                }
-                p++;
-        }
-
-	ret = _citrus_iconv_open(&handle, in, out_truncated);
-	free(out_truncated);
-	if (ret) {
-		errno = ret == ENOENT ? EINVAL : ret;
-		return ((iconv_t)-1);
-	}
-
-	handle->cv_shared->ci_discard_ilseq = strcasestr(out, "//IGNORE");
-	handle->cv_shared->ci_hooks = NULL;
-
-	return ((iconv_t)(void *)handle);
-}
-
-iconv_t
-libiconv_open(const char *out, const char *in)
-{
-
-	return (_iconv_open(out, in, NULL));
-}
-
-int
-libiconv_open_into(const char *out, const char *in, iconv_allocation_t *ptr)
-{
-	struct _citrus_iconv *handle;
-
-	handle = (struct _citrus_iconv *)ptr;
-	return ((_iconv_open(out, in, handle) == (iconv_t)-1) ? -1 : 0);
-}
-
-int
-libiconv_close(iconv_t handle)
-{
-
-	if (ISBADF(handle)) {
-		errno = EBADF;
-		return (-1);
-	}
-
-	_citrus_iconv_close((struct _citrus_iconv *)(void *)handle);
-
-	return (0);
-}
-
 size_t
-libiconv(iconv_t handle, char **in, size_t *szin, char **out, size_t *szout)
+iconv(iconv_t a, char ** __restrict b,
+      size_t * __restrict c, char ** __restrict d,
+      size_t * __restrict e)
 {
-	size_t ret;
-	int err;
-
-	if (ISBADF(handle)) {
-		errno = EBADF;
-		return ((size_t)-1);
-	}
-
-	err = _citrus_iconv_convert((struct _citrus_iconv *)(void *)handle,
-	    in, szin, out, szout, 0, &ret);
-	if (err) {
-		errno = err;
-		ret = (size_t)-1;
-	}
-
-	return (ret);
+	return __bsd_iconv(a, b, c, d, e);
 }
-
-size_t
-__iconv(iconv_t handle, char **in, size_t *szin, char **out,
-    size_t *szout, uint32_t flags, size_t *invalids)
-{
-	size_t ret;
-	int err;
-
-	if (ISBADF(handle)) {
-		errno = EBADF;
-		return ((size_t)-1);
-	}
-
-	err = _citrus_iconv_convert((struct _citrus_iconv *)(void *)handle,
-	    in, szin, out, szout, flags, &ret);
-	if (invalids)
-		*invalids = ret;
-	if (err) {
-		errno = err;
-		ret = (size_t)-1;
-	}
-
-	return (ret);
-}
-
-int
-__iconv_get_list(char ***rlist, size_t *rsz, bool sorted)
-{
-	int ret;
-
-	ret = _citrus_esdb_get_list(rlist, rsz, sorted);
-	if (ret) {
-		errno = ret;
-		return (-1);
-	}
-
-	return (0);
-}
-
-void
-__iconv_free_list(char **list, size_t sz)
-{
-
-	_citrus_esdb_free_list(list, sz);
-}
-
-/*
- * GNU-compatibile non-standard interfaces.
- */
-static int
-qsort_helper(const void *first, const void *second)
-{
-	const char * const *s1;
-	const char * const *s2;
-
-	s1 = first;
-	s2 = second;
-	return (strcmp(*s1, *s2));
-}
-
-void
-libiconvlist(int (*do_one) (unsigned int, const char * const *,
-    void *), void *data)
-{
-	char **list, **names;
-	const char * const *np;
-	char *curitem, *curkey, *slashpos;
-	size_t sz;
-	unsigned int i, j;
-
-	i = 0;
-
-	if (__iconv_get_list(&list, &sz, true))
-		list = NULL;
-	qsort((void *)list, sz, sizeof(char *), qsort_helper);
-	while (i < sz) {
-		j = 0;
-		slashpos = strchr(list[i], '/');
-		curkey = (char *)malloc(slashpos - list[i] + 2);
-		names = (char **)malloc(sz * sizeof(char *));
-		if ((curkey == NULL) || (names == NULL)) {
-			__iconv_free_list(list, sz);
-			return;
-		}
-		strlcpy(curkey, list[i], slashpos - list[i] + 1);
-		names[j++] = strdup(curkey);
-		for (; (i < sz) && (memcmp(curkey, list[i], strlen(curkey)) == 0); i++) {
-			slashpos = strchr(list[i], '/');
-			curitem = (char *)malloc(strlen(slashpos) + 1);
-			if (curitem == NULL) {
-				__iconv_free_list(list, sz);
-				return;
-			}
-			strlcpy(curitem, &slashpos[1], strlen(slashpos) + 1);
-			if (strcmp(curkey, curitem) == 0) {
-				continue;
-			}
-			names[j++] = strdup(curitem);
-		}
-		np = (const char * const *)names;
-		do_one(j, np, data);
-		free(names);
-	}
-
-	__iconv_free_list(list, sz);
-}
-
-__inline const char
-*iconv_canonicalize(const char *name)
-{
-
-	return (_citrus_iconv_canonicalize(name));
-}
-
-int
-libiconvctl(iconv_t cd, int request, void *argument)
-{
-	struct _citrus_iconv *cv;
-	struct iconv_hooks *hooks;
-	const char *convname;
-	char src[PATH_MAX], *dst;
-	int *i;
-
-	cv = (struct _citrus_iconv *)(void *)cd;
-	hooks = (struct iconv_hooks *)argument;
-	i = (int *)argument;
-
-	if (ISBADF(cd)) {
-		errno = EBADF;
-		return (-1);
-	}
-
-	switch (request) {
-	case ICONV_TRIVIALP:
-		convname = cv->cv_shared->ci_convname;
-		dst = strchr(convname, '/');
-
-		strlcpy(src, convname, dst - convname + 1);
-		dst++;
-		if ((convname == NULL) || (src == NULL) || (dst == NULL))
-			return (-1);
-		*i = strcmp(src, dst) == 0 ? 1 : 0;
-		return (0);
-	case ICONV_GET_TRANSLITERATE:
-		*i = 1;
-		return (0);
-	case ICONV_SET_TRANSLITERATE:
-		return  ((*i == 1) ? 0 : -1);
-	case ICONV_GET_DISCARD_ILSEQ:
-		*i = cv->cv_shared->ci_discard_ilseq ? 1 : 0;
-		return (0);
-	case ICONV_SET_DISCARD_ILSEQ:
-		cv->cv_shared->ci_discard_ilseq = *i;
-		return (0);
-	case ICONV_SET_HOOKS:
-		cv->cv_shared->ci_hooks = hooks;
-		return (0);
-	case ICONV_SET_FALLBACKS:
-		errno = EOPNOTSUPP;
-		return (-1);
-	default:
-		errno = EINVAL;
-		return (-1);
-	}
-}
-
-void
-libiconv_set_relocation_prefix(const char *orig_prefix __unused,
-    const char *curr_prefix __unused)
-{
-
-}

Modified: trunk/lib/libc/iconv/iconv_canonicalize.3
===================================================================
--- trunk/lib/libc/iconv/iconv_canonicalize.3	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/iconv_canonicalize.3	2017-12-16 17:24:42 UTC (rev 9688)
@@ -32,7 +32,8 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"	http://www.opengroup.org/unix/online.html.
 .\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/iconv/iconv_canonicalize.3 219019 2011-02-25 00:04:39Z gabor $
+.\" $MidnightBSD$
 .\"
 .Dd October 20, 2009
 .Dt ICONV_CANONICALIZE 3


Property changes on: trunk/lib/libc/iconv/iconv_canonicalize.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconv_canonicalize.c
===================================================================
--- trunk/lib/libc/iconv/iconv_canonicalize.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv_canonicalize.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv_canonicalize.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+const char *
+iconv_canonicalize(const char *a)
+{
+	return __bsd_iconv_canonicalize(a);
+}


Property changes on: trunk/lib/libc/iconv/iconv_canonicalize.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconv_close.c
===================================================================
--- trunk/lib/libc/iconv/iconv_close.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv_close.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv_close.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+int
+iconv_close(iconv_t a)
+{
+	return __bsd_iconv_close(a);
+}


Property changes on: trunk/lib/libc/iconv/iconv_close.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconv_compat.c
===================================================================
--- trunk/lib/libc/iconv/iconv_compat.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv_compat.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,122 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv_compat.c 282275 2015-04-30 16:08:47Z tijl $
+ */
+
+/*
+ * These are ABI implementations for when the raw iconv_* symbol
+ * space was exposed via libc.so.7 in its early life.  This is
+ * a transition aide, these wrappers will not normally ever be
+ * executed except via __sym_compat() references.
+ */
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+size_t
+__iconv_compat(iconv_t a, char ** b, size_t * c, char ** d,
+     size_t * e, __uint32_t f, size_t *g)
+{
+	return __bsd___iconv(a, b, c, d, e, f, g);
+}
+
+void
+__iconv_free_list_compat(char ** a, size_t b)
+{
+	__bsd___iconv_free_list(a, b);
+}
+
+int
+__iconv_get_list_compat(char ***a, size_t *b, __iconv_bool c)
+{
+	return __bsd___iconv_get_list(a, b, c);
+}
+
+size_t
+iconv_compat(iconv_t a, char ** __restrict b,
+      size_t * __restrict c, char ** __restrict d,
+      size_t * __restrict e)
+{
+	return __bsd_iconv(a, b, c, d, e);
+}
+
+const char *
+iconv_canonicalize_compat(const char *a)
+{
+	return __bsd_iconv_canonicalize(a);
+}
+
+int
+iconv_close_compat(iconv_t a)
+{
+	return __bsd_iconv_close(a);
+}
+
+iconv_t
+iconv_open_compat(const char *a, const char *b)
+{
+	return __bsd_iconv_open(a, b);
+}
+
+int
+iconv_open_into_compat(const char *a, const char *b, iconv_allocation_t *c)
+{
+	return __bsd_iconv_open_into(a, b, c);
+}
+
+void
+iconv_set_relocation_prefix_compat(const char *a, const char *b)
+{
+	return __bsd_iconv_set_relocation_prefix(a, b);
+}
+
+int
+iconvctl_compat(iconv_t a, int b, void *c)
+{
+	return __bsd_iconvctl(a, b, c);
+}
+
+void
+iconvlist_compat(int (*a) (unsigned int, const char * const *, void *), void *b)
+{
+	return __bsd_iconvlist(a, b);
+}
+
+int _iconv_version_compat = 0x0108;	/* Magic - not used */
+
+__sym_compat(__iconv, __iconv_compat, FBSD_1.2);
+__sym_compat(__iconv_free_list, __iconv_free_list_compat, FBSD_1.2);
+__sym_compat(__iconv_get_list, __iconv_get_list_compat, FBSD_1.2);
+__sym_compat(_iconv_version, _iconv_version_compat, FBSD_1.3);
+__sym_compat(iconv, iconv_compat, FBSD_1.3);
+__sym_compat(iconv_canonicalize, iconv_canonicalize_compat, FBSD_1.2);
+__sym_compat(iconv_close, iconv_close_compat, FBSD_1.3);
+__sym_compat(iconv_open, iconv_open_compat, FBSD_1.3);
+__sym_compat(iconv_open_into, iconv_open_into_compat, FBSD_1.3);
+__sym_compat(iconv_set_relocation_prefix, iconv_set_relocation_prefix_compat, FBSD_1.3);
+__sym_compat(iconvctl, iconvctl_compat, FBSD_1.3);
+__sym_compat(iconvlist, iconvlist_compat, FBSD_1.3);


Property changes on: trunk/lib/libc/iconv/iconv_compat.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconv_open.c
===================================================================
--- trunk/lib/libc/iconv/iconv_open.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv_open.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv_open.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+iconv_t
+iconv_open(const char *a, const char *b)
+{
+	return __bsd_iconv_open(a, b);
+}


Property changes on: trunk/lib/libc/iconv/iconv_open.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconv_open_into.c
===================================================================
--- trunk/lib/libc/iconv/iconv_open_into.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv_open_into.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv_open_into.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+int
+iconv_open_into(const char *a, const char *b, iconv_allocation_t *c)
+{
+	return __bsd_iconv_open_into(a, b, c);
+}


Property changes on: trunk/lib/libc/iconv/iconv_open_into.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconv_set_relocation_prefix.c
===================================================================
--- trunk/lib/libc/iconv/iconv_set_relocation_prefix.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconv_set_relocation_prefix.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconv_set_relocation_prefix.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+void
+iconv_set_relocation_prefix(const char *a, const char *b)
+{
+	return __bsd_iconv_set_relocation_prefix(a, b);
+}


Property changes on: trunk/lib/libc/iconv/iconv_set_relocation_prefix.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/iconv/iconvctl.3
===================================================================
--- trunk/lib/libc/iconv/iconvctl.3	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/iconvctl.3	2017-12-16 17:24:42 UTC (rev 9688)
@@ -32,9 +32,10 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"	http://www.opengroup.org/unix/online.html.
 .\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/iconv/iconvctl.3 258750 2013-11-29 19:44:30Z gjb $
+.\" $MidnightBSD$
 .\"
-.Dd November 7, 2009
+.Dd November 25, 2009
 .Dt ICONVCTL 3
 .Os
 .Sh NAME
@@ -61,7 +62,7 @@
 is an operation-specific argument.
 .Pp
 The possible operations are the following:
-.Bl -tag -width -indent
+.Bl -tag -width indent
 .It ICONV_TRIVIALP
 In this case
 .Fa argument
@@ -110,6 +111,32 @@
 via
 .Fa argument
 by its address.
+.It ICONV_GET_ILSEQ_INVALID
+Determines if a character in the input buffer that is valid,
+but for which an identical character does not exist in the target
+codeset returns
+.Er EILSEQ
+or not.
+The answer is stored in
+.Fa argument ,
+which is of
+.Ft int * .
+It will be set to 1 if this feature is enabled or set to 0 otherwise.
+.It ICONV_SET_ILSEQ_INVALID
+Sets whether a character in the input buffer that is valid,
+but for which an identical character does not exist in the target
+codeset returns
+.Er EILSEQ
+or not.
+If
+.Fa argument ,
+which is of
+.Ft int *
+is set to 1 it will be enabled,
+and if
+.Fa argument
+is set to 0 it will be disabled.
+.El
 .\" XXX: fallbacks are unimplemented and trying to set them will always
 .\"      return EOPNOTSUPP but definitions are provided for source-level
 .\"      compatibility.
@@ -140,6 +167,7 @@
 The conversion descriptor specified by
 .Fa cd
 is invalid.
+.El
 .Sh SEE ALSO
 .Xr iconv 1 ,
 .Xr iconv 3


Property changes on: trunk/lib/libc/iconv/iconvctl.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconvctl.c
===================================================================
--- trunk/lib/libc/iconv/iconvctl.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconvctl.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconvctl.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+int
+iconvctl(iconv_t a, int b, void *c)
+{
+	return __bsd_iconvctl(a, b, c);
+}


Property changes on: trunk/lib/libc/iconv/iconvctl.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/iconv/iconvlist.3
===================================================================
--- trunk/lib/libc/iconv/iconvlist.3	2017-12-16 16:24:10 UTC (rev 9687)
+++ trunk/lib/libc/iconv/iconvlist.3	2017-12-16 17:24:42 UTC (rev 9688)
@@ -32,7 +32,8 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"	http://www.opengroup.org/unix/online.html.
 .\"
-.\" $FreeBSD$
+.\" $FreeBSD: stable/10/lib/libc/iconv/iconvlist.3 233625 2012-03-28 19:20:28Z joel $
+.\" $MidnightBSD$
 .\"
 .Dd October 20, 2009
 .Dt ICONVLIST 3
@@ -46,7 +47,7 @@
 .Sh SYNOPSIS
 .In iconv.h
 .Ft void
-.Fo iconvlist "char ***names" "size_t count" "bool paired"
+.Fo iconvlist
 .Fa "int \*[lp]*do_one\*[rp]\*[lp]unsigned int *count, const char * const *names, void *arg\*[rp]"
 .Fa "void *arg"
 .Fc


Property changes on: trunk/lib/libc/iconv/iconvlist.3
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc/iconv/iconvlist.c
===================================================================
--- trunk/lib/libc/iconv/iconvlist.c	                        (rev 0)
+++ trunk/lib/libc/iconv/iconvlist.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,38 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc/iconv/iconvlist.c 258750 2013-11-29 19:44:30Z gjb $
+ */
+
+#include <sys/types.h>
+#include <iconv.h>
+#include "iconv-internal.h"
+
+void
+iconvlist(int (*a) (unsigned int, const char * const *, void *), void *b)
+{
+	return __bsd_iconvlist(a, b);
+}


Property changes on: trunk/lib/libc/iconv/iconvlist.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/libc.ldscript
===================================================================
--- trunk/lib/libc/libc.ldscript	                        (rev 0)
+++ trunk/lib/libc/libc.ldscript	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,2 @@
+/* $MidnightBSD$ */
+GROUP ( @@SHLIB@@ @@LIBDIR@@/libc_nonshared.a @@LIBDIR@@/libssp_nonshared.a )


Property changes on: trunk/lib/libc/libc.ldscript
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/lib/libc_nonshared/Makefile
===================================================================
--- trunk/lib/libc_nonshared/Makefile	                        (rev 0)
+++ trunk/lib/libc_nonshared/Makefile	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,29 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/lib/libc_nonshared/Makefile 313594 2017-02-11 06:23:07Z ngie $
+
+# We're actually creating a libc_noshared.a that is PIC along side libc.so.*
+# It is used exclusively with libc.so.* - there is no need for any other
+# compile modes.
+# bsd.lib.mk doesn't have an easy way to express that.
+NO_PROFILE?=
+.include <bsd.own.mk>
+NO_PIC=
+# -fpic on some platforms, -fPIC on others.
+CFLAGS+=${PICFLAG} -DPIC -fvisibility=hidden
+
+LIB=	c_nonshared
+
+LIBC_NONSHARED_SRCS=
+
+# So that an empty .a file doesn't cause errors.
+SRCS=	__stub.c
+
+.if ${MK_ICONV} == "yes"
+.PATH: ${.CURDIR}/../libc/iconv
+.include "Makefile.iconv"
+CFLAGS+=-I${SRCTOP}/lib/libc/iconv
+.endif
+
+SRCS+=	${LIBC_NONSHARED_SRCS}
+
+.include <bsd.lib.mk>


Property changes on: trunk/lib/libc_nonshared/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc_nonshared/Makefile.iconv
===================================================================
--- trunk/lib/libc_nonshared/Makefile.iconv	                        (rev 0)
+++ trunk/lib/libc_nonshared/Makefile.iconv	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,10 @@
+# $MidnightBSD$
+# $FreeBSD: stable/10/lib/libc_nonshared/Makefile.iconv 258750 2013-11-29 19:44:30Z gjb $
+
+.if ${MK_ICONV} == "yes"
+LIBC_NONSHARED_SRCS+=	\
+	__iconv.c __iconv_free_list.c __iconv_get_list.c \
+	iconv.c iconv_canonicalize.c iconv_close.c \
+	iconv_open.c iconv_open_into.c \
+	iconv_set_relocation_prefix.c iconvctl.c iconvlist.c
+.endif


Property changes on: trunk/lib/libc_nonshared/Makefile.iconv
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc_nonshared/__stub.c
===================================================================
--- trunk/lib/libc_nonshared/__stub.c	                        (rev 0)
+++ trunk/lib/libc_nonshared/__stub.c	2017-12-16 17:24:42 UTC (rev 9688)
@@ -0,0 +1,32 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Peter Wemm
+ * 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.
+ *
+ * $FreeBSD: stable/10/lib/libc_nonshared/__stub.c 258283 2013-11-17 22:52:17Z peter $
+ */
+
+extern int __stub_N8TwezWFyocUB;
+
+int __stub_N8TwezWFyocUB;		/* 42 */


Property changes on: trunk/lib/libc_nonshared/__stub.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list