about summary refs log tree commit diff
path: root/REORG.TODO/wcsmbs
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/wcsmbs')
-rw-r--r--REORG.TODO/wcsmbs/Depend1
-rw-r--r--REORG.TODO/wcsmbs/Makefile105
-rw-r--r--REORG.TODO/wcsmbs/Versions37
-rw-r--r--REORG.TODO/wcsmbs/bits/types/__mbstate_t.h23
-rw-r--r--REORG.TODO/wcsmbs/bits/types/mbstate_t.h8
-rw-r--r--REORG.TODO/wcsmbs/bits/types/wint_t.h23
-rw-r--r--REORG.TODO/wcsmbs/bits/wchar-ldbl.h70
-rw-r--r--REORG.TODO/wcsmbs/bits/wchar2.h593
-rw-r--r--REORG.TODO/wcsmbs/btowc.c100
-rw-r--r--REORG.TODO/wcsmbs/c16rtomb.c32
-rw-r--r--REORG.TODO/wcsmbs/isoc99_fwscanf.c40
-rw-r--r--REORG.TODO/wcsmbs/isoc99_swscanf.c36
-rw-r--r--REORG.TODO/wcsmbs/isoc99_vfwscanf.c35
-rw-r--r--REORG.TODO/wcsmbs/isoc99_vswscanf.c48
-rw-r--r--REORG.TODO/wcsmbs/isoc99_vwscanf.c34
-rw-r--r--REORG.TODO/wcsmbs/isoc99_wscanf.c41
-rw-r--r--REORG.TODO/wcsmbs/mbrlen.c32
-rw-r--r--REORG.TODO/wcsmbs/mbrtoc16.c154
-rw-r--r--REORG.TODO/wcsmbs/mbrtowc.c129
-rw-r--r--REORG.TODO/wcsmbs/mbsinit.c38
-rw-r--r--REORG.TODO/wcsmbs/mbsnrtowcs.c143
-rw-r--r--REORG.TODO/wcsmbs/mbsrtowcs.c31
-rw-r--r--REORG.TODO/wcsmbs/mbsrtowcs_l.c163
-rw-r--r--REORG.TODO/wcsmbs/test-wcpcpy.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcpncpy.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcscat.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcschr.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wcschrnul.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcscmp.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wcscpy.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wcscspn.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcslen.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wcsncat.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcsncmp.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wcsncpy.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcsnlen.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcspbrk.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wcsrchr.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wcsspn.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wmemchr.c20
-rw-r--r--REORG.TODO/wcsmbs/test-wmemcmp.c2
-rw-r--r--REORG.TODO/wcsmbs/test-wmemset.c20
-rw-r--r--REORG.TODO/wcsmbs/tst-btowc.c176
-rw-r--r--REORG.TODO/wcsmbs/tst-c16c32-1.c131
-rw-r--r--REORG.TODO/wcsmbs/tst-mbrtowc.c235
-rw-r--r--REORG.TODO/wcsmbs/tst-mbrtowc2.c66
-rw-r--r--REORG.TODO/wcsmbs/tst-mbsrtowcs.c66
-rw-r--r--REORG.TODO/wcsmbs/tst-wchar-h.c11
-rw-r--r--REORG.TODO/wcsmbs/tst-wcpncpy.c78
-rw-r--r--REORG.TODO/wcsmbs/tst-wcrtomb.c96
-rw-r--r--REORG.TODO/wcsmbs/tst-wcsnlen.c52
-rw-r--r--REORG.TODO/wcsmbs/tst-wcstod-nan-locale.c25
-rw-r--r--REORG.TODO/wcsmbs/tst-wcstod-round.c31
-rw-r--r--REORG.TODO/wcsmbs/tst-wcstof.c33
-rw-r--r--REORG.TODO/wcsmbs/tst-wcstol-locale.c25
-rw-r--r--REORG.TODO/wcsmbs/uchar.h74
-rw-r--r--REORG.TODO/wcsmbs/wchar.h792
-rw-r--r--REORG.TODO/wcsmbs/wcpcpy.c48
-rw-r--r--REORG.TODO/wcsmbs/wcpncpy.c87
-rw-r--r--REORG.TODO/wcsmbs/wcrtomb.c120
-rw-r--r--REORG.TODO/wcsmbs/wcsatcliff.c23
-rw-r--r--REORG.TODO/wcsmbs/wcscasecmp.c67
-rw-r--r--REORG.TODO/wcsmbs/wcscasecmp_l.c23
-rw-r--r--REORG.TODO/wcsmbs/wcscat.c53
-rw-r--r--REORG.TODO/wcsmbs/wcschr.c37
-rw-r--r--REORG.TODO/wcsmbs/wcschrnul.c38
-rw-r--r--REORG.TODO/wcsmbs/wcscmp.c45
-rw-r--r--REORG.TODO/wcsmbs/wcscoll.c32
-rw-r--r--REORG.TODO/wcsmbs/wcscoll_l.c34
-rw-r--r--REORG.TODO/wcsmbs/wcscpy.c60
-rw-r--r--REORG.TODO/wcsmbs/wcscspn.c39
-rw-r--r--REORG.TODO/wcsmbs/wcsdup.c35
-rw-r--r--REORG.TODO/wcsmbs/wcslen.c46
-rw-r--r--REORG.TODO/wcsmbs/wcsmbs-tst1.c59
-rw-r--r--REORG.TODO/wcsmbs/wcsmbsload.c270
-rw-r--r--REORG.TODO/wcsmbs/wcsmbsload.h80
-rw-r--r--REORG.TODO/wcsmbs/wcsncase.c69
-rw-r--r--REORG.TODO/wcsmbs/wcsncase_l.c23
-rw-r--r--REORG.TODO/wcsmbs/wcsncat.c79
-rw-r--r--REORG.TODO/wcsmbs/wcsncmp.c70
-rw-r--r--REORG.TODO/wcsmbs/wcsncpy.c88
-rw-r--r--REORG.TODO/wcsmbs/wcsnlen.c50
-rw-r--r--REORG.TODO/wcsmbs/wcsnrtombs.c148
-rw-r--r--REORG.TODO/wcsmbs/wcspbrk.c37
-rw-r--r--REORG.TODO/wcsmbs/wcsrchr.c37
-rw-r--r--REORG.TODO/wcsmbs/wcsrtombs.c145
-rw-r--r--REORG.TODO/wcsmbs/wcsspn.c47
-rw-r--r--REORG.TODO/wcsmbs/wcsstr.c97
-rw-r--r--REORG.TODO/wcsmbs/wcstod.c28
-rw-r--r--REORG.TODO/wcsmbs/wcstod_l.c29
-rw-r--r--REORG.TODO/wcsmbs/wcstod_nan.c23
-rw-r--r--REORG.TODO/wcsmbs/wcstof.c27
-rw-r--r--REORG.TODO/wcsmbs/wcstof_l.c29
-rw-r--r--REORG.TODO/wcsmbs/wcstof_nan.c23
-rw-r--r--REORG.TODO/wcsmbs/wcstok.c62
-rw-r--r--REORG.TODO/wcsmbs/wcstol.c22
-rw-r--r--REORG.TODO/wcsmbs/wcstol_l.c29
-rw-r--r--REORG.TODO/wcsmbs/wcstold.c27
-rw-r--r--REORG.TODO/wcsmbs/wcstold_l.c28
-rw-r--r--REORG.TODO/wcsmbs/wcstold_nan.c30
-rw-r--r--REORG.TODO/wcsmbs/wcstoll.c24
-rw-r--r--REORG.TODO/wcsmbs/wcstoll_l.c29
-rw-r--r--REORG.TODO/wcsmbs/wcstoul.c22
-rw-r--r--REORG.TODO/wcsmbs/wcstoul_l.c29
-rw-r--r--REORG.TODO/wcsmbs/wcstoull.c24
-rw-r--r--REORG.TODO/wcsmbs/wcstoull_l.c30
-rw-r--r--REORG.TODO/wcsmbs/wcswidth.c38
-rw-r--r--REORG.TODO/wcsmbs/wcsxfrm.c26
-rw-r--r--REORG.TODO/wcsmbs/wcsxfrm_l.c34
-rw-r--r--REORG.TODO/wcsmbs/wctob.c82
-rw-r--r--REORG.TODO/wcsmbs/wcwidth.c26
-rw-r--r--REORG.TODO/wcsmbs/wcwidth.h39
-rw-r--r--REORG.TODO/wcsmbs/wmemchr.c65
-rw-r--r--REORG.TODO/wcsmbs/wmemcmp.c83
-rw-r--r--REORG.TODO/wcsmbs/wmemcpy.c28
-rw-r--r--REORG.TODO/wcsmbs/wmemmove.c28
-rw-r--r--REORG.TODO/wcsmbs/wmempcpy.c29
-rw-r--r--REORG.TODO/wcsmbs/wmemset.c57
118 files changed, 7197 insertions, 0 deletions
diff --git a/REORG.TODO/wcsmbs/Depend b/REORG.TODO/wcsmbs/Depend
new file mode 100644
index 0000000000..f3e1156a4e
--- /dev/null
+++ b/REORG.TODO/wcsmbs/Depend
@@ -0,0 +1 @@
+localedata
diff --git a/REORG.TODO/wcsmbs/Makefile b/REORG.TODO/wcsmbs/Makefile
new file mode 100644
index 0000000000..08b1de11a8
--- /dev/null
+++ b/REORG.TODO/wcsmbs/Makefile
@@ -0,0 +1,105 @@
+# Copyright (C) 1995-2017 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+#
+#	Sub-makefile for wcsmbs portion of the library.
+#
+subdir	:= wcsmbs
+
+include ../Makeconfig
+
+headers	:= wchar.h bits/wchar.h bits/wchar2.h bits/wchar-ldbl.h uchar.h \
+	   bits/types/__mbstate_t.h bits/types/mbstate_t.h bits/types/wint_t.h
+
+routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
+	    wcsncmp wcsncpy wcspbrk wcsrchr wcsspn wcstok wcsstr wmemchr \
+	    wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy wmempcpy \
+	    btowc wctob mbsinit \
+	    mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \
+	    mbsnrtowcs wcsnrtombs wcsnlen wcschrnul \
+	    wcstol wcstoul wcstoll wcstoull wcstod wcstold wcstof \
+	    wcstol_l wcstoul_l wcstoll_l wcstoull_l \
+	    wcstod_l wcstold_l wcstof_l \
+	    wcstod_nan wcstold_nan wcstof_nan \
+	    wcscoll wcsxfrm \
+	    wcwidth wcswidth \
+	    wcscoll_l wcsxfrm_l \
+	    wcscasecmp wcsncase wcscasecmp_l wcsncase_l \
+	    wcsmbsload mbsrtowcs_l \
+	    isoc99_wscanf isoc99_vwscanf isoc99_fwscanf isoc99_vfwscanf \
+	    isoc99_swscanf isoc99_vswscanf \
+	    mbrtoc16 c16rtomb
+
+strop-tests :=  wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
+		wcpcpy wcsncpy wcpncpy wcscat wcsncat wcschrnul wcsspn wcspbrk \
+		wcscspn wmemchr wmemset
+tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
+	 tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
+	 tst-c16c32-1 wcsatcliff tst-wcstol-locale tst-wcstod-nan-locale \
+	 tst-wcstod-round \
+	 $(addprefix test-,$(strop-tests))
+
+include ../Rules
+
+ifeq ($(run-built-tests),yes)
+LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 hr_HR.ISO-8859-2 \
+	   ja_JP.EUC-JP zh_TW.EUC-TW tr_TR.UTF-8 tr_TR.ISO-8859-9
+include ../gen-locales.mk
+
+$(objpfx)tst-btowc.out: $(gen-locales)
+$(objpfx)tst-c16c32-1.out: $(gen-locales)
+$(objpfx)tst-mbrtowc.out: $(gen-locales)
+$(objpfx)tst-mbrtowc2.out: $(gen-locales)
+$(objpfx)tst-wcrtomb.out: $(gen-locales)
+$(objpfx)wcsmbs-tst1.out: $(gen-locales)
+$(objpfx)tst-wcstol-locale.out: $(gen-locales)
+$(objpfx)tst-wcstod-nan-locale.out: $(gen-locales)
+endif
+
+$(objpfx)tst-wcstod-round: $(libm)
+
+CFLAGS-wcwidth.c = -I../wctype
+CFLAGS-wcswidth.c = -I../wctype
+
+strtox-CFLAGS = -I../include
+CFLAGS-wcstol.c = $(strtox-CFLAGS)
+CFLAGS-wcstoul.c = $(strtox-CFLAGS)
+CFLAGS-wcstoll.c = $(strtox-CFLAGS)
+CFLAGS-wcstoull.c = $(strtox-CFLAGS)
+CFLAGS-wcstod.c = $(strtox-CFLAGS)
+CFLAGS-wcstold.c = $(strtox-CFLAGS)
+CFLAGS-wcstof.c = $(strtox-CFLAGS)
+CFLAGS-wcstol_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstoul_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstoll_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstoull_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstod_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstold_l.c = $(strtox-CFLAGS)
+CFLAGS-wcstof_l.c = $(strtox-CFLAGS)
+CPPFLAGS-tst-wchar-h.c = -D_FORTIFY_SOURCE=2
+
+CFLAGS-isoc99_wscanf.c += -fexceptions
+CFLAGS-isoc99_fwscanf.c += -fexceptions
+CFLAGS-isoc99_vwscanf.c += -fexceptions
+CFLAGS-isoc99_vfwscanf.c += -fexceptions
+
+CPPFLAGS += $(libio-mtsafe)
+
+# We need to find the default version of strtold_l in stdlib.
+CPPFLAGS-wcstold_l.c = -I../stdlib
+
+$(objpfx)tst-wcstod-nan-locale: $(libm)
diff --git a/REORG.TODO/wcsmbs/Versions b/REORG.TODO/wcsmbs/Versions
new file mode 100644
index 0000000000..b8f7bd73eb
--- /dev/null
+++ b/REORG.TODO/wcsmbs/Versions
@@ -0,0 +1,37 @@
+libc {
+  GLIBC_2.0 {
+    # functions used in inline functions or macros
+     __mbrlen; __mbrtowc;
+    __wcstod_internal; __wcstof_internal; __wcstold_internal;
+    __wcstol_internal; __wcstoll_internal;
+    __wcstoul_internal; __wcstoull_internal;
+
+    # b*
+    btowc;
+
+    # w*
+    wcpcpy; wcpncpy; wcrtomb; wcscat; wcschr; wcscmp; wcscoll;
+    wcscpy; wcscspn; wcsdup; wcslen; wcsncat; wcsncmp;
+    wcsncpy; wcsnrtombs; wcspbrk; wcsrchr; wcsrtombs; wcsspn; wcsstr;
+    wcstod; wcstof; wcstok; wcstol; wcstold; wcstoq; wcstoul;
+    wcstouq; wcswidth; wcsxfrm; wctob;
+
+    wmemchr; wmemcmp; wmemcpy; wmemmove; wmemset;
+  }
+  GLIBC_2.1 {
+    # w*
+    wcscasecmp; wcsncasecmp; wcsnlen; wcstoll;
+    wcstoimax; wcstoumax; wcstoull; wcswcs; wmemrtombs; wmemrtowcs;
+  }
+  GLIBC_2.2 {
+    # w*
+    wcschrnul; wmempcpy;
+  }
+  GLIBC_2.7 {
+    __isoc99_fwscanf; __isoc99_swscanf; __isoc99_vfwscanf; __isoc99_vswscanf;
+    __isoc99_vwscanf; __isoc99_wscanf;
+  }
+  GLIBC_2.16 {
+    c16rtomb; c32rtomb; mbrtoc16; mbrtoc32;
+  }
+}
diff --git a/REORG.TODO/wcsmbs/bits/types/__mbstate_t.h b/REORG.TODO/wcsmbs/bits/types/__mbstate_t.h
new file mode 100644
index 0000000000..1d8a4e28d1
--- /dev/null
+++ b/REORG.TODO/wcsmbs/bits/types/__mbstate_t.h
@@ -0,0 +1,23 @@
+#ifndef ____mbstate_t_defined
+#define ____mbstate_t_defined 1
+
+/* Integral type unchanged by default argument promotions that can
+   hold any value corresponding to members of the extended character
+   set, as well as at least one value that does not correspond to any
+   member of the extended character set.  */
+#ifndef __WINT_TYPE__
+# define __WINT_TYPE__ unsigned int
+#endif
+
+/* Conversion state information.  */
+typedef struct
+{
+  int __count;
+  union
+  {
+    __WINT_TYPE__ __wch;
+    char __wchb[4];
+  } __value;		/* Value so far.  */
+} __mbstate_t;
+
+#endif
diff --git a/REORG.TODO/wcsmbs/bits/types/mbstate_t.h b/REORG.TODO/wcsmbs/bits/types/mbstate_t.h
new file mode 100644
index 0000000000..8d1baa5c3b
--- /dev/null
+++ b/REORG.TODO/wcsmbs/bits/types/mbstate_t.h
@@ -0,0 +1,8 @@
+#ifndef __mbstate_t_defined
+#define __mbstate_t_defined 1
+
+#include <bits/types/__mbstate_t.h>
+
+typedef __mbstate_t mbstate_t;
+
+#endif
diff --git a/REORG.TODO/wcsmbs/bits/types/wint_t.h b/REORG.TODO/wcsmbs/bits/types/wint_t.h
new file mode 100644
index 0000000000..fbd63dbc84
--- /dev/null
+++ b/REORG.TODO/wcsmbs/bits/types/wint_t.h
@@ -0,0 +1,23 @@
+#ifndef __wint_t_defined
+#define __wint_t_defined 1
+
+/* Some versions of stddef.h provide wint_t, even though neither the
+   C nor C++ standards, nor POSIX, specifies this.  We assume that
+   stddef.h will define the macro _WINT_T if and only if it provides
+   wint_t, and conversely, that it will avoid providing wint_t if
+   _WINT_T is already defined.  */
+#ifndef _WINT_T
+#define _WINT_T 1
+
+/* Integral type unchanged by default argument promotions that can
+   hold any value corresponding to members of the extended character
+   set, as well as at least one value that does not correspond to any
+   member of the extended character set.  */
+#ifndef __WINT_TYPE__
+# define __WINT_TYPE__ unsigned int
+#endif
+
+typedef __WINT_TYPE__ wint_t;
+
+#endif /* _WINT_T */
+#endif /* bits/types/wint_t.h */
diff --git a/REORG.TODO/wcsmbs/bits/wchar-ldbl.h b/REORG.TODO/wcsmbs/bits/wchar-ldbl.h
new file mode 100644
index 0000000000..a4d1d4d1e9
--- /dev/null
+++ b/REORG.TODO/wcsmbs/bits/wchar-ldbl.h
@@ -0,0 +1,70 @@
+/* -mlong-double-64 compatibility mode for <wchar.h> functions.
+   Copyright (C) 2006-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _WCHAR_H
+# error "Never include <bits/wchar-ldbl.h> directly; use <wchar.h> instead."
+#endif
+
+#if defined __USE_ISOC95 || defined __USE_UNIX98
+__LDBL_REDIR_DECL (fwprintf);
+__LDBL_REDIR_DECL (wprintf);
+__LDBL_REDIR_DECL (swprintf);
+__LDBL_REDIR_DECL (vfwprintf);
+__LDBL_REDIR_DECL (vwprintf);
+__LDBL_REDIR_DECL (vswprintf);
+# if defined __USE_ISOC99 && !defined __USE_GNU \
+     && !defined __REDIRECT \
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+__LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf)
+__LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
+__LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
+# else
+__LDBL_REDIR_DECL (fwscanf);
+__LDBL_REDIR_DECL (wscanf);
+__LDBL_REDIR_DECL (swscanf);
+# endif
+#endif
+
+#ifdef __USE_ISOC99
+__LDBL_REDIR1_DECL (wcstold, wcstod);
+# if !defined __USE_GNU && !defined __REDIRECT \
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+__LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
+__LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
+__LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
+# else
+__LDBL_REDIR_DECL (vfwscanf);
+__LDBL_REDIR_DECL (vwscanf);
+__LDBL_REDIR_DECL (vswscanf);
+# endif
+#endif
+
+#ifdef __USE_GNU
+__LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
+#endif
+
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
+__LDBL_REDIR_DECL (__swprintf_chk)
+__LDBL_REDIR_DECL (__vswprintf_chk)
+# if __USE_FORTIFY_LEVEL > 1
+__LDBL_REDIR_DECL (__fwprintf_chk)
+__LDBL_REDIR_DECL (__wprintf_chk)
+__LDBL_REDIR_DECL (__vfwprintf_chk)
+__LDBL_REDIR_DECL (__vwprintf_chk)
+# endif
+#endif
diff --git a/REORG.TODO/wcsmbs/bits/wchar2.h b/REORG.TODO/wcsmbs/bits/wchar2.h
new file mode 100644
index 0000000000..4a461e6e29
--- /dev/null
+++ b/REORG.TODO/wcsmbs/bits/wchar2.h
@@ -0,0 +1,593 @@
+/* Checking macros for wchar functions.
+   Copyright (C) 2005-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _WCHAR_H
+# error "Never include <bits/wchar2.h> directly; use <wchar.h> instead."
+#endif
+
+
+extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1,
+			       const wchar_t *__restrict __s2, size_t __n,
+			       size_t __ns1) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias,
+				(wchar_t *__restrict __s1,
+				 const wchar_t *__restrict __s2, size_t __n),
+				wmemcpy);
+extern wchar_t *__REDIRECT_NTH (__wmemcpy_chk_warn,
+				(wchar_t *__restrict __s1,
+				 const wchar_t *__restrict __s2, size_t __n,
+				 size_t __ns1), __wmemcpy_chk)
+     __warnattr ("wmemcpy called with length bigger than size of destination "
+		 "buffer");
+
+__fortify_function wchar_t *
+__NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
+		size_t __n))
+{
+  if (__bos0 (__s1) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n))
+	return __wmemcpy_chk (__s1, __s2, __n,
+			      __bos0 (__s1) / sizeof (wchar_t));
+
+      if (__n > __bos0 (__s1) / sizeof (wchar_t))
+	return __wmemcpy_chk_warn (__s1, __s2, __n,
+				   __bos0 (__s1) / sizeof (wchar_t));
+    }
+  return __wmemcpy_alias (__s1, __s2, __n);
+}
+
+
+extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2,
+				size_t __n, size_t __ns1) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1,
+						   const wchar_t *__s2,
+						   size_t __n), wmemmove);
+extern wchar_t *__REDIRECT_NTH (__wmemmove_chk_warn,
+				(wchar_t *__s1, const wchar_t *__s2,
+				 size_t __n, size_t __ns1), __wmemmove_chk)
+     __warnattr ("wmemmove called with length bigger than size of destination "
+		 "buffer");
+
+__fortify_function wchar_t *
+__NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n))
+{
+  if (__bos0 (__s1) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n))
+	return __wmemmove_chk (__s1, __s2, __n,
+			       __bos0 (__s1) / sizeof (wchar_t));
+
+      if (__n > __bos0 (__s1) / sizeof (wchar_t))
+	return __wmemmove_chk_warn (__s1, __s2, __n,
+				    __bos0 (__s1) / sizeof (wchar_t));
+    }
+  return __wmemmove_alias (__s1, __s2, __n);
+}
+
+
+#ifdef __USE_GNU
+extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1,
+				const wchar_t *__restrict __s2, size_t __n,
+				size_t __ns1) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias,
+				(wchar_t *__restrict __s1,
+				 const wchar_t *__restrict __s2,
+				 size_t __n), wmempcpy);
+extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn,
+				(wchar_t *__restrict __s1,
+				 const wchar_t *__restrict __s2, size_t __n,
+				 size_t __ns1), __wmempcpy_chk)
+     __warnattr ("wmempcpy called with length bigger than size of destination "
+		 "buffer");
+
+__fortify_function wchar_t *
+__NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
+		 size_t __n))
+{
+  if (__bos0 (__s1) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n))
+	return __wmempcpy_chk (__s1, __s2, __n,
+			       __bos0 (__s1) / sizeof (wchar_t));
+
+      if (__n > __bos0 (__s1) / sizeof (wchar_t))
+	return __wmempcpy_chk_warn (__s1, __s2, __n,
+				    __bos0 (__s1) / sizeof (wchar_t));
+    }
+  return __wmempcpy_alias (__s1, __s2, __n);
+}
+#endif
+
+
+extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
+			       size_t __ns) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
+						  size_t __n), wmemset);
+extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn,
+				(wchar_t *__s, wchar_t __c, size_t __n,
+				 size_t __ns), __wmemset_chk)
+     __warnattr ("wmemset called with length bigger than size of destination "
+		 "buffer");
+
+__fortify_function wchar_t *
+__NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n))
+{
+  if (__bos0 (__s) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n))
+	return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t));
+
+      if (__n > __bos0 (__s) / sizeof (wchar_t))
+	return __wmemset_chk_warn (__s, __c, __n,
+				   __bos0 (__s) / sizeof (wchar_t));
+    }
+  return __wmemset_alias (__s, __c, __n);
+}
+
+
+extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest,
+			      const wchar_t *__restrict __src,
+			      size_t __n) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wcscpy_alias,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src), wcscpy);
+
+__fortify_function wchar_t *
+__NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
+{
+  if (__bos (__dest) != (size_t) -1)
+    return __wcscpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
+  return __wcscpy_alias (__dest, __src);
+}
+
+
+extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest,
+			      const wchar_t *__restrict __src,
+			      size_t __destlen) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src), wcpcpy);
+
+__fortify_function wchar_t *
+__NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
+{
+  if (__bos (__dest) != (size_t) -1)
+    return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
+  return __wcpcpy_alias (__dest, __src);
+}
+
+
+extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest,
+			       const wchar_t *__restrict __src, size_t __n,
+			       size_t __destlen) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src,
+				 size_t __n), wcsncpy);
+extern wchar_t *__REDIRECT_NTH (__wcsncpy_chk_warn,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src,
+				 size_t __n, size_t __destlen), __wcsncpy_chk)
+     __warnattr ("wcsncpy called with length bigger than size of destination "
+		 "buffer");
+
+__fortify_function wchar_t *
+__NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
+		size_t __n))
+{
+  if (__bos (__dest) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n))
+	return __wcsncpy_chk (__dest, __src, __n,
+			      __bos (__dest) / sizeof (wchar_t));
+      if (__n > __bos (__dest) / sizeof (wchar_t))
+	return __wcsncpy_chk_warn (__dest, __src, __n,
+				   __bos (__dest) / sizeof (wchar_t));
+    }
+  return __wcsncpy_alias (__dest, __src, __n);
+}
+
+
+extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest,
+			       const wchar_t *__restrict __src, size_t __n,
+			       size_t __destlen) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src,
+				 size_t __n), wcpncpy);
+extern wchar_t *__REDIRECT_NTH (__wcpncpy_chk_warn,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src,
+				 size_t __n, size_t __destlen), __wcpncpy_chk)
+     __warnattr ("wcpncpy called with length bigger than size of destination "
+		 "buffer");
+
+__fortify_function wchar_t *
+__NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
+		size_t __n))
+{
+  if (__bos (__dest) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n))
+	return __wcpncpy_chk (__dest, __src, __n,
+			      __bos (__dest) / sizeof (wchar_t));
+      if (__n > __bos (__dest) / sizeof (wchar_t))
+	return __wcpncpy_chk_warn (__dest, __src, __n,
+				   __bos (__dest) / sizeof (wchar_t));
+    }
+  return __wcpncpy_alias (__dest, __src, __n);
+}
+
+
+extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest,
+			      const wchar_t *__restrict __src,
+			      size_t __destlen) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wcscat_alias,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src), wcscat);
+
+__fortify_function wchar_t *
+__NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
+{
+  if (__bos (__dest) != (size_t) -1)
+    return __wcscat_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
+  return __wcscat_alias (__dest, __src);
+}
+
+
+extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest,
+			       const wchar_t *__restrict __src,
+			       size_t __n, size_t __destlen) __THROW;
+extern wchar_t *__REDIRECT_NTH (__wcsncat_alias,
+				(wchar_t *__restrict __dest,
+				 const wchar_t *__restrict __src,
+				 size_t __n), wcsncat);
+
+__fortify_function wchar_t *
+__NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
+		size_t __n))
+{
+  if (__bos (__dest) != (size_t) -1)
+    return __wcsncat_chk (__dest, __src, __n,
+			  __bos (__dest) / sizeof (wchar_t));
+  return __wcsncat_alias (__dest, __src, __n);
+}
+
+
+extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
+			   int __flag, size_t __s_len,
+			   const wchar_t *__restrict __format, ...)
+     __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
+
+extern int __REDIRECT_NTH_LDBL (__swprintf_alias,
+				(wchar_t *__restrict __s, size_t __n,
+				 const wchar_t *__restrict __fmt, ...),
+				swprintf);
+
+#ifdef __va_arg_pack
+__fortify_function int
+__NTH (swprintf (wchar_t *__restrict __s, size_t __n,
+		 const wchar_t *__restrict __fmt, ...))
+{
+  if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
+    return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
+			   __bos (__s) / sizeof (wchar_t),
+			   __fmt, __va_arg_pack ());
+  return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ());
+}
+#elif !defined __cplusplus
+/* XXX We might want to have support in gcc for swprintf.  */
+# define swprintf(s, n, ...) \
+  (__bos (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1			      \
+   ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1,			      \
+		     __bos (s) / sizeof (wchar_t), __VA_ARGS__)		      \
+   : swprintf (s, n, __VA_ARGS__))
+#endif
+
+extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
+			    int __flag, size_t __s_len,
+			    const wchar_t *__restrict __format,
+			    __gnuc_va_list __arg)
+     __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
+
+extern int __REDIRECT_NTH_LDBL (__vswprintf_alias,
+				(wchar_t *__restrict __s, size_t __n,
+				 const wchar_t *__restrict __fmt,
+				 __gnuc_va_list __ap), vswprintf);
+
+__fortify_function int
+__NTH (vswprintf (wchar_t *__restrict __s, size_t __n,
+		  const wchar_t *__restrict __fmt, __gnuc_va_list __ap))
+{
+  if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
+    return __vswprintf_chk (__s, __n,  __USE_FORTIFY_LEVEL - 1,
+			    __bos (__s) / sizeof (wchar_t), __fmt, __ap);
+  return __vswprintf_alias (__s, __n, __fmt, __ap);
+}
+
+
+#if __USE_FORTIFY_LEVEL > 1
+
+extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
+			   const wchar_t *__restrict __format, ...);
+extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
+			  ...);
+extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag,
+			    const wchar_t *__restrict __format,
+			    __gnuc_va_list __ap);
+extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
+			   __gnuc_va_list __ap);
+
+# ifdef __va_arg_pack
+__fortify_function int
+wprintf (const wchar_t *__restrict __fmt, ...)
+{
+  return __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
+}
+
+__fortify_function int
+fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __fmt, ...)
+{
+  return __fwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
+			 __va_arg_pack ());
+}
+# elif !defined __cplusplus
+#  define wprintf(...) \
+  __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
+#  define fwprintf(stream, ...) \
+  __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
+# endif
+
+__fortify_function int
+vwprintf (const wchar_t *__restrict __fmt, __gnuc_va_list __ap)
+{
+  return __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap);
+}
+
+__fortify_function int
+vfwprintf (__FILE *__restrict __stream,
+	   const wchar_t *__restrict __fmt, __gnuc_va_list __ap)
+{
+  return __vfwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
+}
+
+#endif
+
+extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n,
+			      __FILE *__restrict __stream) __wur;
+extern wchar_t *__REDIRECT (__fgetws_alias,
+			    (wchar_t *__restrict __s, int __n,
+			     __FILE *__restrict __stream), fgetws) __wur;
+extern wchar_t *__REDIRECT (__fgetws_chk_warn,
+			    (wchar_t *__restrict __s, size_t __size, int __n,
+			     __FILE *__restrict __stream), __fgetws_chk)
+     __wur __warnattr ("fgetws called with bigger size than length "
+		       "of destination buffer");
+
+__fortify_function __wur wchar_t *
+fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
+{
+  if (__bos (__s) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n) || __n <= 0)
+	return __fgetws_chk (__s, __bos (__s) / sizeof (wchar_t),
+			     __n, __stream);
+
+      if ((size_t) __n > __bos (__s) / sizeof (wchar_t))
+	return __fgetws_chk_warn (__s, __bos (__s) / sizeof (wchar_t),
+				  __n, __stream);
+    }
+  return __fgetws_alias (__s, __n, __stream);
+}
+
+#ifdef __USE_GNU
+extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size,
+				       int __n, __FILE *__restrict __stream)
+  __wur;
+extern wchar_t *__REDIRECT (__fgetws_unlocked_alias,
+			    (wchar_t *__restrict __s, int __n,
+			     __FILE *__restrict __stream), fgetws_unlocked)
+  __wur;
+extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn,
+			    (wchar_t *__restrict __s, size_t __size, int __n,
+			     __FILE *__restrict __stream),
+			    __fgetws_unlocked_chk)
+     __wur __warnattr ("fgetws_unlocked called with bigger size than length "
+		       "of destination buffer");
+
+__fortify_function __wur wchar_t *
+fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
+{
+  if (__bos (__s) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__n) || __n <= 0)
+	return __fgetws_unlocked_chk (__s, __bos (__s) / sizeof (wchar_t),
+				      __n, __stream);
+
+      if ((size_t) __n > __bos (__s) / sizeof (wchar_t))
+	return __fgetws_unlocked_chk_warn (__s, __bos (__s) / sizeof (wchar_t),
+					   __n, __stream);
+    }
+  return __fgetws_unlocked_alias (__s, __n, __stream);
+}
+#endif
+
+
+extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar,
+			     mbstate_t *__restrict __p,
+			     size_t __buflen) __THROW __wur;
+extern size_t __REDIRECT_NTH (__wcrtomb_alias,
+			      (char *__restrict __s, wchar_t __wchar,
+			       mbstate_t *__restrict __ps), wcrtomb) __wur;
+
+__fortify_function __wur size_t
+__NTH (wcrtomb (char *__restrict __s, wchar_t __wchar,
+		mbstate_t *__restrict __ps))
+{
+  /* We would have to include <limits.h> to get a definition of MB_LEN_MAX.
+     But this would only disturb the namespace.  So we define our own
+     version here.  */
+#define __WCHAR_MB_LEN_MAX	16
+#if defined MB_LEN_MAX && MB_LEN_MAX != __WCHAR_MB_LEN_MAX
+# error "Assumed value of MB_LEN_MAX wrong"
+#endif
+  if (__bos (__s) != (size_t) -1 && __WCHAR_MB_LEN_MAX > __bos (__s))
+    return __wcrtomb_chk (__s, __wchar, __ps, __bos (__s));
+  return __wcrtomb_alias (__s, __wchar, __ps);
+}
+
+
+extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst,
+			       const char **__restrict __src,
+			       size_t __len, mbstate_t *__restrict __ps,
+			       size_t __dstlen) __THROW;
+extern size_t __REDIRECT_NTH (__mbsrtowcs_alias,
+			      (wchar_t *__restrict __dst,
+			       const char **__restrict __src,
+			       size_t __len, mbstate_t *__restrict __ps),
+			      mbsrtowcs);
+extern size_t __REDIRECT_NTH (__mbsrtowcs_chk_warn,
+			      (wchar_t *__restrict __dst,
+			       const char **__restrict __src,
+			       size_t __len, mbstate_t *__restrict __ps,
+			       size_t __dstlen), __mbsrtowcs_chk)
+     __warnattr ("mbsrtowcs called with dst buffer smaller than len "
+		 "* sizeof (wchar_t)");
+
+__fortify_function size_t
+__NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
+		  size_t __len, mbstate_t *__restrict __ps))
+{
+  if (__bos (__dst) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__len))
+	return __mbsrtowcs_chk (__dst, __src, __len, __ps,
+				__bos (__dst) / sizeof (wchar_t));
+
+      if (__len > __bos (__dst) / sizeof (wchar_t))
+	return __mbsrtowcs_chk_warn (__dst, __src, __len, __ps,
+				     __bos (__dst) / sizeof (wchar_t));
+    }
+  return __mbsrtowcs_alias (__dst, __src, __len, __ps);
+}
+
+
+extern size_t __wcsrtombs_chk (char *__restrict __dst,
+			       const wchar_t **__restrict __src,
+			       size_t __len, mbstate_t *__restrict __ps,
+			       size_t __dstlen) __THROW;
+extern size_t __REDIRECT_NTH (__wcsrtombs_alias,
+			      (char *__restrict __dst,
+			       const wchar_t **__restrict __src,
+			       size_t __len, mbstate_t *__restrict __ps),
+			      wcsrtombs);
+extern size_t __REDIRECT_NTH (__wcsrtombs_chk_warn,
+			      (char *__restrict __dst,
+			       const wchar_t **__restrict __src,
+			       size_t __len, mbstate_t *__restrict __ps,
+			       size_t __dstlen), __wcsrtombs_chk)
+    __warnattr ("wcsrtombs called with dst buffer smaller than len");
+
+__fortify_function size_t
+__NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
+		  size_t __len, mbstate_t *__restrict __ps))
+{
+  if (__bos (__dst) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__len))
+	return __wcsrtombs_chk (__dst, __src, __len, __ps, __bos (__dst));
+
+      if (__len > __bos (__dst))
+	return __wcsrtombs_chk_warn (__dst, __src, __len, __ps, __bos (__dst));
+    }
+  return __wcsrtombs_alias (__dst, __src, __len, __ps);
+}
+
+
+#ifdef __USE_GNU
+extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst,
+				const char **__restrict __src, size_t __nmc,
+				size_t __len, mbstate_t *__restrict __ps,
+				size_t __dstlen) __THROW;
+extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias,
+			      (wchar_t *__restrict __dst,
+			       const char **__restrict __src, size_t __nmc,
+			       size_t __len, mbstate_t *__restrict __ps),
+			      mbsnrtowcs);
+extern size_t __REDIRECT_NTH (__mbsnrtowcs_chk_warn,
+			      (wchar_t *__restrict __dst,
+			       const char **__restrict __src, size_t __nmc,
+			       size_t __len, mbstate_t *__restrict __ps,
+			       size_t __dstlen), __mbsnrtowcs_chk)
+     __warnattr ("mbsnrtowcs called with dst buffer smaller than len "
+		 "* sizeof (wchar_t)");
+
+__fortify_function size_t
+__NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
+		   size_t __nmc, size_t __len, mbstate_t *__restrict __ps))
+{
+  if (__bos (__dst) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__len))
+	return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps,
+				 __bos (__dst) / sizeof (wchar_t));
+
+      if (__len > __bos (__dst) / sizeof (wchar_t))
+	return __mbsnrtowcs_chk_warn (__dst, __src, __nmc, __len, __ps,
+				      __bos (__dst) / sizeof (wchar_t));
+    }
+  return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps);
+}
+
+
+extern size_t __wcsnrtombs_chk (char *__restrict __dst,
+				const wchar_t **__restrict __src,
+				size_t __nwc, size_t __len,
+				mbstate_t *__restrict __ps, size_t __dstlen)
+     __THROW;
+extern size_t __REDIRECT_NTH (__wcsnrtombs_alias,
+			      (char *__restrict __dst,
+			       const wchar_t **__restrict __src,
+			       size_t __nwc, size_t __len,
+			       mbstate_t *__restrict __ps), wcsnrtombs);
+extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn,
+			      (char *__restrict __dst,
+			       const wchar_t **__restrict __src,
+			       size_t __nwc, size_t __len,
+			       mbstate_t *__restrict __ps,
+			       size_t __dstlen), __wcsnrtombs_chk)
+     __warnattr ("wcsnrtombs called with dst buffer smaller than len");
+
+__fortify_function size_t
+__NTH (wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
+		   size_t __nwc, size_t __len, mbstate_t *__restrict __ps))
+{
+  if (__bos (__dst) != (size_t) -1)
+    {
+      if (!__builtin_constant_p (__len))
+	return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps,
+				 __bos (__dst));
+
+      if (__len > __bos (__dst))
+	return __wcsnrtombs_chk_warn (__dst, __src, __nwc, __len, __ps,
+				      __bos (__dst));
+    }
+  return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps);
+}
+#endif
diff --git a/REORG.TODO/wcsmbs/btowc.c b/REORG.TODO/wcsmbs/btowc.c
new file mode 100644
index 0000000000..22464dc5e2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/btowc.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <ctype.h>
+#include <dlfcn.h>
+#include <gconv.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+#include <limits.h>
+
+#include <sysdep.h>
+
+
+wint_t
+__btowc (int c)
+{
+  const struct gconv_fcts *fcts;
+
+  /* If the parameter does not fit into one byte or it is the EOF value
+     we can give the answer now.  */
+  if (c < SCHAR_MIN || c > UCHAR_MAX || c == EOF)
+    return WEOF;
+
+  /* We know that only ASCII compatible encodings are used for the
+     locale and that the wide character encoding is ISO 10646.  */
+  if (isascii (c))
+    return (wint_t) c;
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+  __gconv_btowc_fct btowc_fct = fcts->towc->__btowc_fct;
+
+  if (__builtin_expect (fcts->towc_nsteps == 1, 1)
+      && __builtin_expect (btowc_fct != NULL, 1))
+    {
+      /* Use the shortcut function.  */
+#ifdef PTR_DEMANGLE
+      if (fcts->towc->__shlib_handle != NULL)
+	PTR_DEMANGLE (btowc_fct);
+#endif
+      return DL_CALL_FCT (btowc_fct, (fcts->towc, (unsigned char) c));
+    }
+  else
+    {
+      /* Fall back to the slow but generic method.  */
+      wchar_t result;
+      struct __gconv_step_data data;
+      unsigned char inbuf[1];
+      const unsigned char *inptr = inbuf;
+      size_t dummy;
+      int status;
+
+      /* Tell where we want the result.  */
+      data.__outbuf = (unsigned char *) &result;
+      data.__outbufend = data.__outbuf + sizeof (wchar_t);
+      data.__invocation_counter = 0;
+      data.__internal_use = 1;
+      data.__flags = __GCONV_IS_LAST;
+      data.__statep = &data.__state;
+
+      /* Make sure we start in the initial state.  */
+      memset (&data.__state, '\0', sizeof (mbstate_t));
+
+      /* Create the input string.  */
+      inbuf[0] = c;
+
+      __gconv_fct fct = fcts->towc->__fct;
+#ifdef PTR_DEMANGLE
+      if (fcts->towc->__shlib_handle != NULL)
+	PTR_DEMANGLE (fct);
+#endif
+      status = DL_CALL_FCT (fct, (fcts->towc, &data, &inptr, inptr + 1,
+				  NULL, &dummy, 0, 1));
+
+      if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
+	  && status != __GCONV_EMPTY_INPUT)
+	/* The conversion failed.  */
+	result = WEOF;
+
+      return result;
+    }
+}
+weak_alias (__btowc, btowc)
diff --git a/REORG.TODO/wcsmbs/c16rtomb.c b/REORG.TODO/wcsmbs/c16rtomb.c
new file mode 100644
index 0000000000..9e6b6a218f
--- /dev/null
+++ b/REORG.TODO/wcsmbs/c16rtomb.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <uchar.h>
+#include <wchar.h>
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+c16rtomb (char *s, char16_t c16, mbstate_t *ps)
+{
+  // XXX The ISO C 11 spec I have does not say anything about handling
+  // XXX surrogates in this interface.
+  return wcrtomb (s, c16, ps ?: &state);
+}
diff --git a/REORG.TODO/wcsmbs/isoc99_fwscanf.c b/REORG.TODO/wcsmbs/isoc99_fwscanf.c
new file mode 100644
index 0000000000..8079edcd1d
--- /dev/null
+++ b/REORG.TODO/wcsmbs/isoc99_fwscanf.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libioP.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+
+/* Read formatted input from STREAM according to the format string FORMAT.  */
+/* VARARGS2 */
+int
+__isoc99_fwscanf (FILE *stream, const wchar_t *format, ...)
+{
+  va_list arg;
+  int done;
+
+  _IO_acquire_lock_clear_flags2 (stream);
+  stream->_flags2 |= _IO_FLAGS2_SCANF_STD;
+
+  va_start (arg, format);
+  done = _IO_vfwscanf (stream, format, arg, NULL);
+  va_end (arg);
+
+  _IO_release_lock (stream);
+  return done;
+}
diff --git a/REORG.TODO/wcsmbs/isoc99_swscanf.c b/REORG.TODO/wcsmbs/isoc99_swscanf.c
new file mode 100644
index 0000000000..872df09806
--- /dev/null
+++ b/REORG.TODO/wcsmbs/isoc99_swscanf.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <libioP.h>
+#include <wchar.h>
+
+/* Read formatted input from S, according to the format string FORMAT.  */
+/* VARARGS2 */
+int
+__isoc99_swscanf (const wchar_t *s, const wchar_t *format, ...)
+{
+  va_list arg;
+  int done;
+
+  va_start (arg, format);
+  done = __isoc99_vswscanf (s, format, arg);
+  va_end (arg);
+
+  return done;
+}
diff --git a/REORG.TODO/wcsmbs/isoc99_vfwscanf.c b/REORG.TODO/wcsmbs/isoc99_vfwscanf.c
new file mode 100644
index 0000000000..e35c39d8f2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/isoc99_vfwscanf.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libioP.h>
+#include <stdio.h>
+#include <wchar.h>
+
+/* Read formatted input from STREAM according to the format string FORMAT.  */
+/* VARARGS2 */
+int
+__isoc99_vfwscanf (FILE *stream, const wchar_t *format, _IO_va_list args)
+{
+  int done;
+
+  _IO_acquire_lock_clear_flags2 (stream);
+  stream->_flags2 |= _IO_FLAGS2_SCANF_STD;
+  done = _IO_vfwscanf (stream, format, args, NULL);
+  _IO_release_lock (stream);
+  return done;
+}
+libc_hidden_def (__isoc99_vfwscanf)
diff --git a/REORG.TODO/wcsmbs/isoc99_vswscanf.c b/REORG.TODO/wcsmbs/isoc99_vswscanf.c
new file mode 100644
index 0000000000..22dc4227d2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/isoc99_vswscanf.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1993-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
+
+   As a special exception, if you link the code in this file with
+   files compiled with a GNU compiler to produce an executable,
+   that does not cause the resulting executable to be covered by
+   the GNU Lesser General Public License.  This exception does not
+   however invalidate any other reasons why the executable file
+   might be covered by the GNU Lesser General Public License.
+   This exception applies to code released by its copyright holders
+   in files containing the exception.  */
+
+#include <libioP.h>
+#include <wchar.h>
+#include "../libio/strfile.h"
+
+int
+__isoc99_vswscanf (const wchar_t *string, const wchar_t *format,
+		   _IO_va_list args)
+{
+  int ret;
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+#ifdef _IO_MTSAFE_IO
+  sf._sbf._f._lock = NULL;
+#endif
+  _IO_no_init (&sf._sbf._f, _IO_USER_LOCK, 0, &wd, &_IO_wstr_jumps);
+  _IO_fwide (&sf._sbf._f, 1);
+  _IO_wstr_init_static (&sf._sbf._f, (wchar_t *)string, 0, NULL);
+  sf._sbf._f._flags2 |= _IO_FLAGS2_SCANF_STD;
+  ret = _IO_vfwscanf ((_IO_FILE *) &sf._sbf, format, args, NULL);
+  return ret;
+}
+libc_hidden_def (__isoc99_vswscanf)
diff --git a/REORG.TODO/wcsmbs/isoc99_vwscanf.c b/REORG.TODO/wcsmbs/isoc99_vwscanf.c
new file mode 100644
index 0000000000..f83ffb79b5
--- /dev/null
+++ b/REORG.TODO/wcsmbs/isoc99_vwscanf.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libioP.h>
+#include <stdio.h>
+#include <wchar.h>
+
+/* Read formatted input from STDIN according to the format string FORMAT.  */
+/* VARARGS2 */
+int
+__isoc99_vwscanf (const wchar_t *format, _IO_va_list args)
+{
+  int done;
+
+  _IO_acquire_lock_clear_flags2 (stdin);
+  stdin->_flags2 |= _IO_FLAGS2_SCANF_STD;
+  done = _IO_vfwscanf (stdin, format, args, NULL);
+  _IO_release_lock (stdin);
+  return done;
+}
diff --git a/REORG.TODO/wcsmbs/isoc99_wscanf.c b/REORG.TODO/wcsmbs/isoc99_wscanf.c
new file mode 100644
index 0000000000..7eb6a19082
--- /dev/null
+++ b/REORG.TODO/wcsmbs/isoc99_wscanf.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <libioP.h>
+#include <wchar.h>
+
+
+/* Read formatted input from stdin according to the format string FORMAT.  */
+/* VARARGS1 */
+int
+__isoc99_wscanf (const wchar_t *format, ...)
+{
+  va_list arg;
+  int done;
+
+  _IO_acquire_lock_clear_flags2 (stdin);
+  stdin->_flags2 |= _IO_FLAGS2_SCANF_STD;
+
+  va_start (arg, format);
+  done = _IO_vfwscanf (stdin, format, arg, NULL);
+  va_end (arg);
+
+  _IO_release_lock (stdin);
+  return done;
+}
diff --git a/REORG.TODO/wcsmbs/mbrlen.c b/REORG.TODO/wcsmbs/mbrlen.c
new file mode 100644
index 0000000000..1e836381ee
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbrlen.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+/* The mbrlen function has an internal shift state which gets used if
+   the PS parameter is NULL.  */
+static mbstate_t internal;
+
+
+size_t
+__mbrlen (const char *s, size_t n, mbstate_t *ps)
+{
+  return __mbrtowc (NULL, s, n, ps ?: &internal);
+}
+libc_hidden_def (__mbrlen)
+weak_alias (__mbrlen, mbrlen)
diff --git a/REORG.TODO/wcsmbs/mbrtoc16.c b/REORG.TODO/wcsmbs/mbrtoc16.c
new file mode 100644
index 0000000000..0fc5bc5d82
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbrtoc16.c
@@ -0,0 +1,154 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <uchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+mbrtoc16 (char16_t *pc16, const char *s, size_t n, mbstate_t *ps)
+{
+  if (ps == NULL)
+    ps = &state;
+
+  /* The standard text does not say that S being NULL means the state
+     is reset even if the second half of a surrogate still have to be
+     returned.  In fact, the error code description indicates
+     otherwise.  Therefore always first try to return a second
+     half.  */
+  if (ps->__count & 0x80000000)
+    {
+      /* We have to return the second word for a surrogate.  */
+      ps->__count &= 0x7fffffff;
+      *pc16 = ps->__value.__wch;
+      ps->__value.__wch = L'\0';
+      return (size_t) -3;
+    }
+
+  wchar_t wc;
+  struct __gconv_step_data data;
+  int status;
+  size_t result;
+  size_t dummy;
+  const unsigned char *inbuf, *endbuf;
+  unsigned char *outbuf = (unsigned char *) &wc;
+  const struct gconv_fcts *fcts;
+
+  /* Set information for this step.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps;
+
+  /* A first special case is if S is NULL.  This means put PS in the
+     initial state.  */
+  if (s == NULL)
+    {
+      pc16 = NULL;
+      s = "";
+      n = 1;
+    }
+
+  if (n == 0)
+    return (size_t) -2;
+
+  /* Tell where we want the result.  */
+  data.__outbuf = outbuf;
+  data.__outbufend = outbuf + sizeof (wchar_t);
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Do a normal conversion.  */
+  inbuf = (const unsigned char *) s;
+  endbuf = inbuf + n;
+  if (__glibc_unlikely (endbuf < inbuf))
+    {
+      endbuf = (const unsigned char *) ~(uintptr_t) 0;
+      if (endbuf == inbuf)
+	goto ilseq;
+    }
+  __gconv_fct fct = fcts->towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct, (fcts->towc, &data, &inbuf, endbuf,
+			      NULL, &dummy, 0, 1));
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  The output buffer must be large enough, otherwise the
+     definition of MB_CUR_MAX is not correct.  All the other possible
+     errors also must not happen.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+      || status == __GCONV_FULL_OUTPUT)
+    {
+      result = inbuf - (const unsigned char *) s;
+
+      if (wc < 0x10000)
+	{
+	  if (pc16 != NULL)
+	    *pc16 = wc;
+
+	  if (data.__outbuf != outbuf && wc == L'\0')
+	    {
+	      /* The converted character is the NUL character.  */
+	      assert (__mbsinit (data.__statep));
+	      result = 0;
+	    }
+	}
+      else
+	{
+	  /* This is a surrogate.  */
+	  if (pc16 != NULL)
+	    *pc16 = 0xd7c0 + (wc >> 10);
+
+	  ps->__count |= 0x80000000;
+	  ps->__value.__wch = 0xdc00 + (wc & 0x3ff);
+	}
+    }
+  else if (status == __GCONV_INCOMPLETE_INPUT)
+    result = (size_t) -2;
+  else
+    {
+    ilseq:
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
diff --git a/REORG.TODO/wcsmbs/mbrtowc.c b/REORG.TODO/wcsmbs/mbrtowc.c
new file mode 100644
index 0000000000..ea207bd0c6
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbrtowc.c
@@ -0,0 +1,129 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+__mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+  wchar_t buf[1];
+  struct __gconv_step_data data;
+  int status;
+  size_t result;
+  size_t dummy;
+  const unsigned char *inbuf, *endbuf;
+  unsigned char *outbuf = (unsigned char *) (pwc ?: buf);
+  const struct gconv_fcts *fcts;
+
+  /* Set information for this step.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps ?: &state;
+
+  /* A first special case is if S is NULL.  This means put PS in the
+     initial state.  */
+  if (s == NULL)
+    {
+      outbuf = (unsigned char *) buf;
+      s = "";
+      n = 1;
+    }
+
+  if (n == 0)
+    return (size_t) -2;
+
+  /* Tell where we want the result.  */
+  data.__outbuf = outbuf;
+  data.__outbufend = outbuf + sizeof (wchar_t);
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Do a normal conversion.  */
+  inbuf = (const unsigned char *) s;
+  endbuf = inbuf + n;
+  if (__glibc_unlikely (endbuf < inbuf))
+    {
+      endbuf = (const unsigned char *) ~(uintptr_t) 0;
+      if (endbuf == inbuf)
+	goto ilseq;
+    }
+  __gconv_fct fct = fcts->towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+  status = DL_CALL_FCT (fct, (fcts->towc, &data, &inbuf, endbuf,
+			      NULL, &dummy, 0, 1));
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  The output buffer must be large enough, otherwise the
+     definition of MB_CUR_MAX is not correct.  All the other possible
+     errors also must not happen.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+      || status == __GCONV_FULL_OUTPUT)
+    {
+      if (data.__outbuf != (unsigned char *) outbuf
+	  && *(wchar_t *) outbuf == L'\0')
+	{
+	  /* The converted character is the NUL character.  */
+	  assert (__mbsinit (data.__statep));
+	  result = 0;
+	}
+      else
+	result = inbuf - (const unsigned char *) s;
+    }
+  else if (status == __GCONV_INCOMPLETE_INPUT)
+    result = (size_t) -2;
+  else
+    {
+    ilseq:
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
+libc_hidden_def (__mbrtowc)
+weak_alias (__mbrtowc, mbrtowc)
+libc_hidden_weak (mbrtowc)
+
+/* There should be no difference between the UTF-32 handling required
+   by mbrtoc32 and the wchar_t handling which has long since been
+   implemented in mbrtowc.  */
+weak_alias (__mbrtowc, mbrtoc32)
diff --git a/REORG.TODO/wcsmbs/mbsinit.c b/REORG.TODO/wcsmbs/mbsinit.c
new file mode 100644
index 0000000000..a34787d8ff
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbsinit.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <string.h>
+#include <wchar.h>
+
+#undef mbsinit
+#undef __mbsinit
+
+/* In GNU libc the conversion functions only can convert between the
+   fixed wide character representation and the multibyte
+   representation of the same character set.  Since we use ISO 10646
+   in UCS4 encoding for wide characters the best solution for
+   multibyte characters is the UTF8 encoding.  I.e., the only state
+   information is a counter of the processed bytes so far and the
+   value collected so far.  Especially, we don't have different shift
+   states.  */
+int
+__mbsinit (const mbstate_t *ps)
+{
+  return ps == NULL || ps->__count == 0;
+}
+weak_alias (__mbsinit, mbsinit)
diff --git a/REORG.TODO/wcsmbs/mbsnrtowcs.c b/REORG.TODO/wcsmbs/mbsnrtowcs.c
new file mode 100644
index 0000000000..ed51678e5b
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbsnrtowcs.c
@@ -0,0 +1,143 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <string.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+/* This is a non-standard function but it is very useful in the
+   implementation of stdio because we have to deal with unterminated
+   buffers.  At most NMC bytes will be converted.  */
+size_t
+__mbsnrtowcs (wchar_t *dst, const char **src, size_t nmc, size_t len,
+	      mbstate_t *ps)
+{
+  const unsigned char *srcend;
+  struct __gconv_step_data data;
+  size_t result;
+  int status;
+  struct __gconv_step *towc;
+  size_t dummy;
+  const struct gconv_fcts *fcts;
+
+  /* Tell where we want the result.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps ?: &state;
+
+  if (nmc == 0)
+    return 0;
+  srcend = (const unsigned char *) *src + __strnlen (*src, nmc - 1) + 1;
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Get the structure with the function pointers.  */
+  towc = fcts->towc;
+  __gconv_fct fct = towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  /* We have to handle DST == NULL special.  */
+  if (dst == NULL)
+    {
+      mbstate_t temp_state;
+      wchar_t buf[64];		/* Just an arbitrary size.  */
+      const unsigned char *inbuf = (const unsigned char *) *src;
+
+      temp_state = *data.__statep;
+      data.__statep = &temp_state;
+
+      result = 0;
+      data.__outbufend = (unsigned char *) buf + sizeof (buf);
+      do
+	{
+	  data.__outbuf = (unsigned char *) buf;
+
+	  status = DL_CALL_FCT (fct, (towc, &data, &inbuf, srcend, NULL,
+				      &dummy, 0, 1));
+
+	  result += (wchar_t *) data.__outbuf - buf;
+	}
+      while (status == __GCONV_FULL_OUTPUT);
+
+      if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	  && ((wchar_t *) data.__outbuf)[-1] == L'\0')
+	/* Don't count the NUL character in.  */
+	--result;
+    }
+  else
+    {
+      /* This code is based on the safe assumption that all internal
+	 multi-byte encodings use the NUL byte only to mark the end
+	 of the string.  */
+      data.__outbuf = (unsigned char *) dst;
+      data.__outbufend = data.__outbuf + len * sizeof (wchar_t);
+
+      status = DL_CALL_FCT (fct,
+			    (towc, &data, (const unsigned char **) src, srcend,
+			     NULL, &dummy, 0, 1));
+
+      result = (wchar_t *) data.__outbuf - dst;
+
+      /* We have to determine whether the last character converted
+	 is the NUL character.  */
+      if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	  && (assert (result > 0),
+	      ((wchar_t *) dst)[result - 1] == L'\0'))
+	{
+	  assert (__mbsinit (data.__statep));
+	  *src = NULL;
+	  --result;
+	}
+    }
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
+      && status != __GCONV_EMPTY_INPUT && status != __GCONV_INCOMPLETE_INPUT)
+    {
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
+weak_alias (__mbsnrtowcs, mbsnrtowcs)
diff --git a/REORG.TODO/wcsmbs/mbsrtowcs.c b/REORG.TODO/wcsmbs/mbsrtowcs.c
new file mode 100644
index 0000000000..796f62f19e
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbsrtowcs.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <locale/localeinfo.h>
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+__mbsrtowcs (wchar_t *dst, const char **src, size_t len, mbstate_t *ps)
+{
+  return __mbsrtowcs_l (dst, src, len, ps ?: &state, _NL_CURRENT_LOCALE);
+}
+weak_alias (__mbsrtowcs, mbsrtowcs)
diff --git a/REORG.TODO/wcsmbs/mbsrtowcs_l.c b/REORG.TODO/wcsmbs/mbsrtowcs_l.c
new file mode 100644
index 0000000000..4ffb652b26
--- /dev/null
+++ b/REORG.TODO/wcsmbs/mbsrtowcs_l.c
@@ -0,0 +1,163 @@
+/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 2002.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+#include "wcsmbsload.h"
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+size_t
+attribute_hidden
+__mbsrtowcs_l (wchar_t *dst, const char **src, size_t len, mbstate_t *ps,
+	       __locale_t l)
+{
+  struct __gconv_step_data data;
+  size_t result;
+  int status;
+  struct __gconv_step *towc;
+  size_t non_reversible;
+  const struct gconv_fcts *fcts;
+
+  /* Tell where we want the result.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps;
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (l->__locales[LC_CTYPE]);
+
+  /* Get the structure with the function pointers.  */
+  towc = fcts->towc;
+  __gconv_fct fct = towc->__fct;
+#ifdef PTR_DEMANGLE
+  if (towc->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  /* We have to handle DST == NULL special.  */
+  if (dst == NULL)
+    {
+      mbstate_t temp_state;
+      wchar_t buf[64];		/* Just an arbitrary size.  */
+      const unsigned char *inbuf = (const unsigned char *) *src;
+      const unsigned char *srcend = inbuf + strlen (*src) + 1;
+
+      temp_state = *data.__statep;
+      data.__statep = &temp_state;
+
+      result = 0;
+      data.__outbufend = (unsigned char *) buf + sizeof (buf);
+      do
+	{
+	  data.__outbuf = (unsigned char *) buf;
+
+	  status = DL_CALL_FCT (fct, (towc, &data, &inbuf, srcend, NULL,
+				      &non_reversible, 0, 1));
+
+	  result += (wchar_t *) data.__outbuf - buf;
+	}
+      while (status == __GCONV_FULL_OUTPUT);
+
+      if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	{
+	  /* There better should be a NUL wide char at the end.  */
+	  assert (((wchar_t *) data.__outbuf)[-1] == L'\0');
+	  /* Don't count the NUL character in.  */
+	  --result;
+	}
+    }
+  else
+    {
+      /* This code is based on the safe assumption that all internal
+	 multi-byte encodings use the NUL byte only to mark the end
+	 of the string.  */
+      const unsigned char *srcp = (const unsigned char *) *src;
+      const unsigned char *srcend;
+
+      data.__outbuf = (unsigned char *) dst;
+      data.__outbufend = data.__outbuf + len * sizeof (wchar_t);
+
+      status = __GCONV_FULL_OUTPUT;
+
+      while (len > 0)
+	{
+	  /* Pessimistic guess as to how much input we can use.  In the
+	     worst case we need one input byte for one output wchar_t.  */
+	  srcend = srcp + __strnlen ((const char *) srcp, len) + 1;
+
+	  status = DL_CALL_FCT (fct, (towc, &data, &srcp, srcend, NULL,
+				      &non_reversible, 0, 1));
+	  if ((status != __GCONV_EMPTY_INPUT
+	       && status != __GCONV_INCOMPLETE_INPUT)
+	      /* Not all input read.  */
+	      || srcp != srcend
+	      /* Reached the end of the input.  */
+	      || srcend[-1] == '\0')
+	    break;
+
+	  len = (wchar_t *) data.__outbufend - (wchar_t *) data.__outbuf;
+	}
+
+      /* Make the end if the input known to the caller.  */
+      *src = (const char *) srcp;
+
+      result = (wchar_t *) data.__outbuf - dst;
+
+      /* We have to determine whether the last character converted
+	 is the NUL character.  */
+      if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	  && ((wchar_t *) dst)[result - 1] == L'\0')
+	{
+	  assert (result > 0);
+	  assert (__mbsinit (data.__statep));
+	  *src = NULL;
+	  --result;
+	}
+    }
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
+      && status != __GCONV_EMPTY_INPUT && status != __GCONV_INCOMPLETE_INPUT)
+    {
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
diff --git a/REORG.TODO/wcsmbs/test-wcpcpy.c b/REORG.TODO/wcsmbs/test-wcpcpy.c
new file mode 100644
index 0000000000..c174d33bdc
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcpcpy.c
@@ -0,0 +1,20 @@
+/* Test wcspcpy functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-stpcpy.c"
diff --git a/REORG.TODO/wcsmbs/test-wcpncpy.c b/REORG.TODO/wcsmbs/test-wcpncpy.c
new file mode 100644
index 0000000000..f037e415fd
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcpncpy.c
@@ -0,0 +1,20 @@
+/* Test wcpncpy functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-stpncpy.c"
diff --git a/REORG.TODO/wcsmbs/test-wcscat.c b/REORG.TODO/wcsmbs/test-wcscat.c
new file mode 100644
index 0000000000..1422219407
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcscat.c
@@ -0,0 +1,20 @@
+/* Test wcscat functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strcat.c"
diff --git a/REORG.TODO/wcsmbs/test-wcschr.c b/REORG.TODO/wcsmbs/test-wcschr.c
new file mode 100644
index 0000000000..be0abf7aed
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcschr.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-strchr.c"
diff --git a/REORG.TODO/wcsmbs/test-wcschrnul.c b/REORG.TODO/wcsmbs/test-wcschrnul.c
new file mode 100644
index 0000000000..624e687b14
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcschrnul.c
@@ -0,0 +1,20 @@
+/* Test wcschrnul functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strchrnul.c"
diff --git a/REORG.TODO/wcsmbs/test-wcscmp.c b/REORG.TODO/wcsmbs/test-wcscmp.c
new file mode 100644
index 0000000000..aa18c30a61
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcscmp.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-strcmp.c"
diff --git a/REORG.TODO/wcsmbs/test-wcscpy.c b/REORG.TODO/wcsmbs/test-wcscpy.c
new file mode 100644
index 0000000000..b7cad535f3
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcscpy.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-strcpy.c"
diff --git a/REORG.TODO/wcsmbs/test-wcscspn.c b/REORG.TODO/wcsmbs/test-wcscspn.c
new file mode 100644
index 0000000000..93d64f3914
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcscspn.c
@@ -0,0 +1,20 @@
+/* Test wcscspn functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strcspn.c"
diff --git a/REORG.TODO/wcsmbs/test-wcslen.c b/REORG.TODO/wcsmbs/test-wcslen.c
new file mode 100644
index 0000000000..496fa185e2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcslen.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-strlen.c"
diff --git a/REORG.TODO/wcsmbs/test-wcsncat.c b/REORG.TODO/wcsmbs/test-wcsncat.c
new file mode 100644
index 0000000000..51073d981a
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcsncat.c
@@ -0,0 +1,20 @@
+/* Test wcsncat functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strncat.c"
diff --git a/REORG.TODO/wcsmbs/test-wcsncmp.c b/REORG.TODO/wcsmbs/test-wcsncmp.c
new file mode 100644
index 0000000000..07757d8e45
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcsncmp.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-strncmp.c"
diff --git a/REORG.TODO/wcsmbs/test-wcsncpy.c b/REORG.TODO/wcsmbs/test-wcsncpy.c
new file mode 100644
index 0000000000..78a810a93f
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcsncpy.c
@@ -0,0 +1,20 @@
+/* Test wcsncpy functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strncpy.c"
diff --git a/REORG.TODO/wcsmbs/test-wcsnlen.c b/REORG.TODO/wcsmbs/test-wcsnlen.c
new file mode 100644
index 0000000000..d216bcb163
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcsnlen.c
@@ -0,0 +1,20 @@
+/* Test wcsnlen function.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strnlen.c"
diff --git a/REORG.TODO/wcsmbs/test-wcspbrk.c b/REORG.TODO/wcsmbs/test-wcspbrk.c
new file mode 100644
index 0000000000..087b72be17
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcspbrk.c
@@ -0,0 +1,20 @@
+/* Test wcspbrk functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strpbrk.c"
diff --git a/REORG.TODO/wcsmbs/test-wcsrchr.c b/REORG.TODO/wcsmbs/test-wcsrchr.c
new file mode 100644
index 0000000000..95a5568742
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcsrchr.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-strrchr.c"
diff --git a/REORG.TODO/wcsmbs/test-wcsspn.c b/REORG.TODO/wcsmbs/test-wcsspn.c
new file mode 100644
index 0000000000..3cd3871ab6
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wcsspn.c
@@ -0,0 +1,20 @@
+/* Test wcsspn functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-strspn.c"
diff --git a/REORG.TODO/wcsmbs/test-wmemchr.c b/REORG.TODO/wcsmbs/test-wmemchr.c
new file mode 100644
index 0000000000..69f0c260d4
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wmemchr.c
@@ -0,0 +1,20 @@
+/* Test wmemchr functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-memchr.c"
diff --git a/REORG.TODO/wcsmbs/test-wmemcmp.c b/REORG.TODO/wcsmbs/test-wmemcmp.c
new file mode 100644
index 0000000000..73bc4b72c8
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wmemcmp.c
@@ -0,0 +1,2 @@
+#define WIDE 1
+#include "../string/test-memcmp.c"
diff --git a/REORG.TODO/wcsmbs/test-wmemset.c b/REORG.TODO/wcsmbs/test-wmemset.c
new file mode 100644
index 0000000000..cea3eea0c2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/test-wmemset.c
@@ -0,0 +1,20 @@
+/* Test wmemset functions.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define WIDE 1
+#include "../string/test-memset.c"
diff --git a/REORG.TODO/wcsmbs/tst-btowc.c b/REORG.TODO/wcsmbs/tst-btowc.c
new file mode 100644
index 0000000000..670ee2226f
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-btowc.c
@@ -0,0 +1,176 @@
+/* Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <wchar.h>
+
+
+/* Currently selected locale.  */
+static const char *current_locale;
+
+
+/* Test which should succeed.  */
+static int
+ok_test (int c, wint_t expwc)
+{
+  wint_t wc = btowc (c);
+
+  if (wc != expwc)
+    {
+      printf ("%s: btowc('%c') failed, returned L'\\x%x' instead of L'\\x%x'\n",
+	      current_locale, c, wc, expwc);
+      return 1;
+    }
+
+  return 0;
+}
+
+/* Test which should fail.  */
+static int
+fail_test (int c)
+{
+  wint_t wc = btowc (c);
+
+  if (wc != WEOF)
+    {
+      printf ("%s: btowc('%c') succeded, returned L'\\x%x' instead of WEOF\n",
+	      current_locale, c, wc);
+      return 1;
+    }
+
+  return 0;
+}
+
+
+/* Test EOF handling.  */
+static int
+eof_test (void)
+{
+  wint_t wc = btowc (EOF);
+  if (wc != WEOF)
+    {
+      printf ("%s: btowc(EOF) returned L'\\x%x', not WEOF\n",
+	      current_locale, wc);
+    }
+
+  return 0;
+}
+
+
+/* Test the btowc() function for a few locales with known character sets.  */
+static int
+do_test (void)
+{
+  int result = 0;
+
+  current_locale = setlocale (LC_ALL, "en_US.ANSI_X3.4-1968");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"en_US.ANSI_X3.4-1968\"");
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+      for (c = 0; c < 128; ++c)
+	result |= ok_test (c, c);
+
+      for (c = 128; c < 256; ++c)
+	result |= fail_test (c);
+
+      result |= eof_test ();
+    }
+
+  current_locale = setlocale (LC_ALL, "de_DE.ISO-8859-1");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"de_DE.ISO-8859-1\"");
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+      for (c = 0; c < 256; ++c)
+	result |= ok_test (c, c);
+
+      result |= eof_test ();
+    }
+
+  current_locale = setlocale (LC_ALL, "de_DE.UTF-8");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"de_DE.UTF-8\"");
+      result = 1;
+    }
+  else
+    {
+      int c;
+
+      for (c = 0; c < 128; ++c)
+	result |= ok_test (c, c);
+
+      for (c = 128; c < 256; ++c)
+	result |= fail_test (c);
+
+      result |= eof_test ();
+    }
+
+  current_locale = setlocale (LC_ALL, "hr_HR.ISO-8859-2");
+  if (current_locale == NULL)
+    {
+      puts ("cannot set locale \"hr_HR.ISO-8859-2\"");
+      result = 1;
+    }
+  else
+    {
+      static const wint_t upper_half[] =
+      {
+	0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, 0x00A8,
+	0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, 0x00B0,
+	0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, 0x00B8,
+	0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, 0x0154,
+	0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, 0x010C,
+	0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, 0x0110,
+	0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158,
+	0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, 0x0155,
+	0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D,
+	0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111,
+	0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159,
+	0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9
+      };
+      int c;
+
+      for (c = 0; c < 161; ++c)
+	result |= ok_test (c, c);
+
+      for (c = 161; c < 256; ++c)
+	result |= ok_test (c, upper_half[c - 161]);
+
+      result |= eof_test ();
+    }
+
+  if (result == 0)
+    puts ("all OK");
+
+  return result;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-c16c32-1.c b/REORG.TODO/wcsmbs/tst-c16c32-1.c
new file mode 100644
index 0000000000..3b1c1d674c
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-c16c32-1.c
@@ -0,0 +1,131 @@
+#include <inttypes.h>
+#include <locale.h>
+#include <stdio.h>
+#include <uchar.h>
+#include <stdint.h>
+
+static int
+do_test (void)
+{
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      puts ("cannot set locale");
+      return 1;
+    }
+
+  int result = 0;
+
+  char32_t c32 = 48;
+  do
+    {
+      if (c32 >= 0xd800 && c32 <= 0xe000)
+	continue;
+
+      char buf[20];
+      size_t n1 = c32rtomb (buf, c32, NULL);
+      if (n1 <= 0)
+	{
+	  printf ("c32rtomb for U'\\x%" PRIx32 "' failed\n", (uint32_t) c32);
+	  result = 1;
+	  continue;
+	}
+
+      char32_t c32out;
+      size_t n2 = mbrtoc32 (&c32out, buf, n1, NULL);
+      if ((ssize_t) n2 < 0)
+	{
+	  printf ("mbrtoc32 for U'\\x%" PRIx32 "' failed\n", (uint32_t) c32);
+	  result = 1;
+	  continue;
+	}
+      if (n2 != n1)
+	{
+	  printf ("mbrtoc32 for U'\\x%" PRIx32 "' consumed %zu bytes, not %zu\n",
+		  (uint32_t) c32, n2, n1);
+	  result = 1;
+	}
+      else if (c32out != c32)
+	{
+	  printf ("mbrtoc32 for U'\\x%" PRIx32 "' produced U'\\x%" PRIx32 "\n",
+		  (uint32_t) c32, (uint32_t) c32out);
+	  result = 1;
+	}
+
+      char16_t c16;
+      size_t n3 = mbrtoc16 (&c16, buf, n1, NULL);
+      if (n3 != n1)
+	{
+	  printf ("mbrtoc16 for U'\\x%" PRIx32 "' did not consume all bytes\n",
+		  (uint32_t) c32);
+	  result = 1;
+	  continue;
+	}
+      if (c32 < 0x10000)
+	{
+	  if (c16 != c32)
+	    {
+	      printf ("mbrtoc16 for U'\\x%" PRIx32 "' produce u'\\x%" PRIx16 "'\n",
+		      (uint32_t) c32, (uint16_t) c16);
+	      result = 1;
+	      continue;
+	    }
+	}
+      else
+	{
+	  buf[0] = '1';
+	  char16_t c16_2;
+	  size_t n4 = mbrtoc16 (&c16_2, buf, 1, NULL);
+	  if (n4 != (size_t) -3)
+	    {
+	      printf ("second mbrtoc16 for U'\\x%" PRIx32 "' did not return -3\n",
+		      (uint32_t) c32);
+	      result = 1;
+	      continue;
+	    }
+
+	  if (c32 != (((uint32_t) (c16 - 0xd7c0)) << 10) + (c16_2 - 0xdc00))
+	    {
+	      printf ("mbrtoc16 for U'\\x%" PRIx32 "' returns U'\\x%" PRIx32 "\n",
+		      (uint32_t) c32,
+		      (((uint32_t) (c16 - 0xd7c0)) << 10) + (c16_2 - 0xdc00));
+	      result = 1;
+	      continue;
+	    }
+	}
+
+      buf[0] = '\0';
+      char16_t c16_nul;
+      n3 = mbrtoc16 (&c16_nul, buf, n1, NULL);
+      if (n3 != 0)
+	{
+	  printf ("mbrtoc16 for '\\0' returns %zd\n", n3);
+	  result = 1;
+	  continue;
+	}
+
+      if (c32 < 0x10000)
+	{
+	  size_t n5 = c16rtomb (buf, c16, NULL);
+	  if ((ssize_t) n5 < 0)
+	    {
+	      printf ("c16rtomb for U'\\x%" PRIx32 "' failed with %zd\n",
+		      (uint32_t) c32, n5);
+	      result = 1;
+	      continue;
+	    }
+	  if (n5 != n1)
+	    {
+	      printf ("c16rtomb for U'\\x%" PRIx32 "' produced %zu bytes instead of %zu bytes\n",
+		      (uint32_t) c32, n5, n1);
+	      result = 1;
+	      continue;
+	    }
+	}
+    }
+  while ((c32 += 0x1111) <= U'\x12000');
+
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/REORG.TODO/wcsmbs/tst-mbrtowc.c b/REORG.TODO/wcsmbs/tst-mbrtowc.c
new file mode 100644
index 0000000000..2bc1a0f8b2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-mbrtowc.c
@@ -0,0 +1,235 @@
+/* Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* We always want assert to be fully defined.  */
+#undef NDEBUG
+#include <assert.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int check_ascii (const char *locname);
+
+/* UTF-8 single byte feeding test for mbrtowc(),
+   contributed by Markus Kuhn <mkuhn@acm.org>.  */
+static int
+utf8_test_1 (void)
+{
+  wchar_t wc;
+  mbstate_t s;
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (wc == 42);		/* no value has not been stored into &wc yet */
+  assert (mbrtowc (&wc, "\xA0", 1, &s) == 1);	/* 3nd byte processed */
+  assert (wc == 0x2260);	/* E2 89 A0 = U+2260 (not equal) decoded correctly */
+  assert (mbrtowc (&wc, "", 1, &s) == 0);	/* test final byte processing */
+  assert (wc == 0);		/* test final byte decoding */
+
+  /* The following test is by Al Viro <aviro@redhat.com>.  */
+  const char str[] = "\xe0\xa0\x80";
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, str, 1, &s) == -2);
+  assert (mbrtowc (&wc, str + 1, 2, &s) == 2);
+  assert (wc == 0x800);
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, str, 3, &s) == 3);
+  assert (wc == 0x800);
+
+  return 0;
+}
+
+/* Test for NUL byte processing via empty string.  */
+static int
+utf8_test_2 (void)
+{
+  wchar_t wc;
+  mbstate_t s;
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (NULL, "", 1, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (NULL, "", 1, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (NULL, "", 1, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (&wc, "\xA0", 1, &s) == 1);	/* 3nd byte processed */
+  assert (mbrtowc (NULL, "", 1, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  return 0;
+}
+
+/* Test for NUL byte processing via NULL string.  */
+static int
+utf8_test_3 (void)
+{
+  wchar_t wc;
+  mbstate_t s;
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (NULL, NULL, 0, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (NULL, NULL, 0, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (NULL, NULL, 0, &s) == (size_t) -1); /* invalid terminator */
+
+  wc = 42;			/* arbitrary number */
+  memset (&s, 0, sizeof (s));	/* get s into initial state */
+  assert (mbrtowc (&wc, "\xE2", 1, &s) == (size_t) -2);	/* 1st byte processed */
+  assert (mbrtowc (&wc, "\x89", 1, &s) == (size_t) -2);	/* 2nd byte processed */
+  assert (mbrtowc (&wc, "\xA0", 1, &s) == 1);	/* 3nd byte processed */
+  assert (mbrtowc (NULL, NULL, 0, &s) == 0); /* valid terminator */
+  assert (mbsinit (&s));
+
+  return 0;
+}
+
+static int
+utf8_test (void)
+{
+  const char *locale = "de_DE.UTF-8";
+  int error = 0;
+
+  if (!setlocale (LC_CTYPE, locale))
+    {
+      fprintf (stderr, "locale '%s' not available!\n", locale);
+      exit (1);
+    }
+
+  error |= utf8_test_1 ();
+  error |= utf8_test_2 ();
+  error |= utf8_test_3 ();
+
+  return error;
+}
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  /* Check mapping of ASCII range for some character sets which have
+     ASCII as a subset.  For those the wide char generated must have
+     the same value.  */
+  setlocale (LC_ALL, "C");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+  result |= utf8_test ();
+
+  setlocale (LC_ALL, "ja_JP.EUC-JP");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  return result;
+}
+
+
+static int
+check_ascii (const char *locname)
+{
+  int c;
+  int res = 0;
+
+  printf ("Testing locale \"%s\":\n", locname);
+
+  for (c = 0; c <= 127; ++c)
+    {
+      char buf[MB_CUR_MAX];
+      wchar_t wc = 0xffffffff;
+      mbstate_t s;
+      size_t n, i;
+
+      for (i = 0; i < MB_CUR_MAX; ++i)
+	buf[i] = c + i;
+
+      memset (&s, '\0', sizeof (s));
+
+      n = mbrtowc (&wc, buf, MB_CUR_MAX, &s);
+      if (n == (size_t) -1)
+	{
+	  printf ("%s: '\\x%x': encoding error\n", locname, c);
+	  ++res;
+	}
+      else if (n == (size_t) -2)
+	{
+	  printf ("%s: '\\x%x': incomplete character\n", locname, c);
+	  ++res;
+	}
+      else if (n == 0 && c != 0)
+	{
+	  printf ("%s: '\\x%x': 0 returned\n", locname, c);
+	  ++res;
+	}
+      else if (n != 0 && c == 0)
+	{
+	  printf ("%s: '\\x%x': not 0 returned\n", locname, c);
+	  ++res;
+	}
+      else if (c != 0 && n != 1)
+	{
+	  printf ("%s: '\\x%x': not 1 returned\n", locname, c);
+	  ++res;
+	}
+      else if (wc != (wchar_t) c)
+	{
+	  printf ("%s: '\\x%x': wc != L'\\x%x'\n", locname, c, c);
+	  ++res;
+	}
+    }
+
+  printf (res == 1 ? "%d error\n" : "%d errors\n", res);
+
+  return res != 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/REORG.TODO/wcsmbs/tst-mbrtowc2.c b/REORG.TODO/wcsmbs/tst-mbrtowc2.c
new file mode 100644
index 0000000000..975043accd
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-mbrtowc2.c
@@ -0,0 +1,66 @@
+/* Derived from the test case in http://sourceware.org/bugzilla/show_bug.cgi?id=714 */
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static struct
+{
+  const char *chp;
+  size_t nchp;
+  const char *loc;
+} tests[] =
+{
+  { (const char[]) { 0x8F, 0xA2, 0xAF }, 3, "ja_JP.EUC-JP" },
+  { (const char[]) { 0xD1, 0xA5 }, 2, "ja_JP.EUC-JP" },
+  { (const char[]) { 0x8E, 0xA5 }, 2, "ja_JP.EUC-JP" },
+  { (const char[]) { 0x8E, 0xA2, 0xA1, 0xA1 }, 4, "zh_TW.EUC-TW" },
+  { (const char[]) { 0xA1, 0xA1 }, 2, "zh_TW.EUC-TW" },
+  { (const char[]) { 0xE3, 0x80, 0x80 }, 3, "de_DE.UTF-8" },
+  { (const char[]) { 0xC3, 0xA4 }, 2, "de_DE.UTF-8" }
+};
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+static int t (const char *ch, size_t nch, const char *loc);
+
+static int
+do_test (void)
+{
+  int r = 0;
+  for (int i = 0; i < ntests; ++i)
+    r |= t (tests[i].chp, tests[i].nchp, tests[i].loc);
+  return r;
+}
+
+static int
+t (const char *ch, size_t nch, const char *loc)
+{
+  int i;
+  wchar_t wch;
+  wchar_t wch2;
+  mbstate_t mbs;
+  int n = 0;
+
+  setlocale (LC_ALL, loc);
+
+  memset (&mbs, '\0', sizeof (mbstate_t));
+  for (i = 0; i < nch; i++)
+    {
+      n = mbrtowc (&wch, ch + i, 1, &mbs);
+      if (n >= 0)
+	break;
+    }
+  printf ("n = %d, count = %d, wch = %08lX\n", n, i, (unsigned long int) wch);
+
+  memset (&mbs, '\0', sizeof (mbstate_t));
+  n = mbrtowc (&wch2, ch, nch, &mbs);
+  printf ("n = %d, wch = %08lX\n", n, (unsigned long int) wch2);
+
+  int ret = n != nch || i + 1 != nch || n != nch || wch != wch2;
+  puts (ret ? "FAIL\n" : "OK\n");
+  return ret;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-mbsrtowcs.c b/REORG.TODO/wcsmbs/tst-mbsrtowcs.c
new file mode 100644
index 0000000000..91ce1166bb
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-mbsrtowcs.c
@@ -0,0 +1,66 @@
+/* Test NUL handling of mbsrtowcs.
+   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+static int
+do_test (void)
+{
+  const unsigned char buf[] = { 'a', 'b', '\0', 'c', 'd', '\0', 'e' };
+  wchar_t out[sizeof (buf)];
+  memset (out, '\xff', sizeof (out));
+
+  mbstate_t state;
+  memset (&state, '\0', sizeof (state));
+
+  const char *in = (const char *) buf;
+  size_t n = mbsrtowcs (out, &in, sizeof (out) / sizeof (wchar_t), &state);
+
+  int result = 0;
+  if (n != 2)
+    {
+      printf ("n = %zu, expected 2\n", n);
+      result = 1;
+    }
+  if (in != NULL)
+    {
+      printf ("in = %p, expected NULL\n", in);
+      result = 1;
+    }
+  if (out[0] != L'a')
+    {
+      printf ("out[0] = L'%lc', expected L'a'\n", (wint_t) out[0]);
+      result = 1;
+    }
+  if (out[1] != L'b')
+    {
+      printf ("out[1] = L'%lc', expected L'b'\n", (wint_t) out[1]);
+      result = 1;
+    }
+  if (out[2] != L'\0')
+    {
+      printf ("out[2] = L'%lc', expected L'\\0'\n", (wint_t) out[2]);
+      result = 1;
+    }
+  return result;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-wchar-h.c b/REORG.TODO/wcsmbs/tst-wchar-h.c
new file mode 100644
index 0000000000..047ba6c377
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wchar-h.c
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+#include <wchar.h>
+
+static int
+do_test (void)
+{
+  mbstate_t x;
+  return sizeof (x) - sizeof (mbstate_t);
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-wcpncpy.c b/REORG.TODO/wcsmbs/tst-wcpncpy.c
new file mode 100644
index 0000000000..99b00a5cf6
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcpncpy.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <wchar.h>
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  const wchar_t src[] = L"0";
+  wchar_t dest[21];
+  wmemset (dest, L'\0', 10);
+  wchar_t *endp = wcpncpy (dest, src, 2);
+  if (wcscmp (dest, src) != 0)
+    {
+      result = 1;
+      puts ("L\"0\" string test failed");
+    }
+  if (endp != dest + 1)
+    {
+      result = 1;
+      puts ("return value of L\"0\" string call incorrect");
+    }
+
+  const wchar_t src2[] = L"abc";
+  endp = wcpncpy (dest, src2, 2);
+  if (endp != dest + 2)
+    {
+      result = 1;
+      puts ("return value of limited call incorrect");
+    }
+
+  const wchar_t src3[] = L"";
+  endp = wcpncpy (dest, src3, 2);
+  if (endp != dest)
+    {
+      result = 1;
+      puts ("return value of empty string call incorrect");
+    }
+
+  const wchar_t src4[] = L"abcdefghijklmnopqrstuvwxyz";
+  endp = wcpncpy (dest, src4, 2);
+  if (endp != dest + 2)
+    {
+      result = 1;
+      puts ("return value of long string call incorrect");
+    }
+
+  const wchar_t src5[] = L"ab";
+  endp = wcpncpy (dest, src5, 20);
+  if (endp != dest + 2)
+    {
+      result = 1;
+      puts ("return value of large limit call incorrect");
+    }
+
+  return result;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-wcrtomb.c b/REORG.TODO/wcsmbs/tst-wcrtomb.c
new file mode 100644
index 0000000000..a506fe7e75
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcrtomb.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+
+static int check_ascii (const char *locname);
+
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  /* Check mapping of ASCII range for some character sets which have
+     ASCII as a subset.  For those the wide char generated must have
+     the same value.  */
+  setlocale (LC_ALL, "C");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  setlocale (LC_ALL, "de_DE.UTF-8");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  setlocale (LC_ALL, "ja_JP.EUC-JP");
+  result |= check_ascii (setlocale (LC_ALL, NULL));
+
+  return result;
+}
+
+
+static int
+check_ascii (const char *locname)
+{
+  wchar_t wc;
+  int res = 0;
+
+  printf ("Testing locale \"%s\":\n", locname);
+
+  for (wc = 0; wc <= 127; ++wc)
+    {
+      char buf[2 * MB_CUR_MAX];
+      mbstate_t s;
+      size_t n;
+
+      memset (buf, '\xff', sizeof (buf));
+      memset (&s, '\0', sizeof (s));
+
+      n = wcrtomb (buf, wc, &s);
+      if (n == (size_t) -1)
+	{
+	  printf ("%s: '\\x%x': encoding error\n", locname, (int) wc);
+	  ++res;
+	}
+      else if (n == 0)
+	{
+	  printf ("%s: '\\x%x': 0 returned\n", locname, (int) wc);
+	  ++res;
+	}
+      else if (n != 1)
+	{
+	  printf ("%s: '\\x%x': not 1 returned\n", locname, (int) wc);
+	  ++res;
+	}
+      else if (wc != (wchar_t) buf[0])
+	{
+	  printf ("%s: L'\\x%x': buf[0] != '\\x%x'\n", locname, (int) wc,
+		  (int) wc);
+	  ++res;
+	}
+    }
+
+  printf (res == 1 ? "%d error\n" : "%d errors\n", res);
+
+  return res != 0;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-wcsnlen.c b/REORG.TODO/wcsmbs/tst-wcsnlen.c
new file mode 100644
index 0000000000..89b5212006
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcsnlen.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <wchar.h>
+
+#define TEST(Str, Max, Exp) \
+  n = wcsnlen (L##Str, Max);						      \
+  if (n != Exp)								      \
+    {									      \
+      result = 1;							      \
+      printf ("wcsnlen (L\"%s\", %d) = %d, not %d\n", Str, Max, n, Exp);      \
+    }
+
+static int
+do_test (void)
+{
+  int result = 0;
+  int n;
+
+  TEST ("0123456789", 0, 0);
+  TEST ("0123456789", 1, 1);
+  TEST ("0123456789", 2, 2);
+  TEST ("0123456789", 3, 3);
+  TEST ("0123456789", 4, 4);
+  TEST ("0123456789", 5, 5);
+  TEST ("0123456789", 6, 6);
+  TEST ("0123456789", 7, 7);
+  TEST ("0123456789", 8, 8);
+  TEST ("0123456789", 9, 9);
+
+  TEST ("01234", 9, 5);
+
+  return result;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-wcstod-nan-locale.c b/REORG.TODO/wcsmbs/tst-wcstod-nan-locale.c
new file mode 100644
index 0000000000..5e623f3046
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcstod-nan-locale.c
@@ -0,0 +1,25 @@
+/* Test strtod functions work with all ASCII letters in NAN(...) in
+   Turkish locales (bug 19266).  Wide string version.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define CHAR wchar_t
+#define SFMT "L\"%ls\""
+#define FNPFX wcsto
+#define L_(C) L ## C
+
+#include "../stdlib/tst-strtod-nan-locale-main.c"
diff --git a/REORG.TODO/wcsmbs/tst-wcstod-round.c b/REORG.TODO/wcsmbs/tst-wcstod-round.c
new file mode 100644
index 0000000000..04499721f6
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcstod-round.c
@@ -0,0 +1,31 @@
+/* wide character shim for tst-strtod-round-skeleton.c.
+   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+/* Include stdio.h early to avoid issues with the snprintf
+   redefinition below.  */
+#include <stdio.h>
+
+#define L_(str) L ## str
+#define FNPFX wcs
+#define CHAR wchar_t
+#define STRM "%ls"
+#define snprintf swprintf
+
+#include <stdlib/tst-strtod-round-skeleton.c>
diff --git a/REORG.TODO/wcsmbs/tst-wcstof.c b/REORG.TODO/wcsmbs/tst-wcstof.c
new file mode 100644
index 0000000000..5b7cdeacd8
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcstof.c
@@ -0,0 +1,33 @@
+#define _GNU_SOURCE 1
+#include <wchar.h>
+#include <stdio.h>
+#include <string.h>
+#include <wctype.h>
+#include <libc-diag.h>
+
+static int
+do_test (void)
+{
+  int result = 0;
+  char buf[100];
+  wchar_t tmp[3];
+  tmp[0] = '8';
+  tmp[1] = '1';
+  tmp[2] = 0;
+
+  /* GCC does not know the result of wcstof so cannot see that the
+     snprintf output is not truncated.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (7, 0)
+  DIAG_IGNORE_NEEDS_COMMENT (7.0, "-Wformat-truncation");
+#endif
+  snprintf (buf, 100, "%S = %f", tmp, wcstof (tmp, NULL));
+  DIAG_POP_NEEDS_COMMENT;
+  printf ("\"%s\" -> %s\n", buf,
+	  strcmp (buf, "81 = 81.000000") == 0 ? "okay" : "buggy");
+  result |= strcmp (buf, "81 = 81.000000") != 0;
+
+  return result;
+}
+
+#include <support/test-driver.c>
diff --git a/REORG.TODO/wcsmbs/tst-wcstol-locale.c b/REORG.TODO/wcsmbs/tst-wcstol-locale.c
new file mode 100644
index 0000000000..946c1d036f
--- /dev/null
+++ b/REORG.TODO/wcsmbs/tst-wcstol-locale.c
@@ -0,0 +1,25 @@
+/* Test strtol functions work with all ASCII letters in Turkish
+   locales (bug 19242).  Wide string version.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define CHAR wchar_t
+#define SFMT "L\"%ls\""
+#define FNPFX wcsto
+#define L_(C) L ## C
+
+#include "../stdlib/tst-strtol-locale-main.c"
diff --git a/REORG.TODO/wcsmbs/uchar.h b/REORG.TODO/wcsmbs/uchar.h
new file mode 100644
index 0000000000..f937519cf4
--- /dev/null
+++ b/REORG.TODO/wcsmbs/uchar.h
@@ -0,0 +1,74 @@
+/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/*
+ *      ISO C11 Standard: 7.28
+ *	Unicode utilities	<uchar.h>
+ */
+
+#ifndef _UCHAR_H
+#define _UCHAR_H	1
+
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <bits/types/mbstate_t.h>
+
+#if defined __GNUC__ && !defined __USE_ISOCXX11
+/* Define the 16-bit and 32-bit character types.  Use the information
+   provided by the compiler.  */
+# if !defined __CHAR16_TYPE__ || !defined __CHAR32_TYPE__
+#  if defined __STDC_VERSION__ && __STDC_VERSION__ < 201000L
+#   error "<uchar.h> requires ISO C11 mode"
+#  else
+#   error "definitions of __CHAR16_TYPE__ and/or __CHAR32_TYPE__ missing"
+#  endif
+# endif
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+#endif
+
+
+__BEGIN_DECLS
+
+/* Write char16_t representation of multibyte character pointed
+   to by S to PC16.  */
+extern size_t mbrtoc16 (char16_t *__restrict __pc16,
+			const char *__restrict __s, size_t __n,
+			mbstate_t *__restrict __p) __THROW;
+
+/* Write multibyte representation of char16_t C16 to S.  */
+extern size_t c16rtomb (char *__restrict __s, char16_t __c16,
+			mbstate_t *__restrict __ps) __THROW;
+
+
+
+/* Write char32_t representation of multibyte character pointed
+   to by S to PC32.  */
+extern size_t mbrtoc32 (char32_t *__restrict __pc32,
+			const char *__restrict __s, size_t __n,
+			mbstate_t *__restrict __p) __THROW;
+
+/* Write multibyte representation of char32_t C32 to S.  */
+extern size_t c32rtomb (char *__restrict __s, char32_t __c32,
+			mbstate_t *__restrict __ps) __THROW;
+
+__END_DECLS
+
+#endif	/* uchar.h */
diff --git a/REORG.TODO/wcsmbs/wchar.h b/REORG.TODO/wcsmbs/wchar.h
new file mode 100644
index 0000000000..d389428daa
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wchar.h
@@ -0,0 +1,792 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/*
+ *      ISO C99 Standard: 7.24
+ *	Extended multibyte and wide character utilities	<wchar.h>
+ */
+
+#ifndef _WCHAR_H
+#define _WCHAR_H 1
+
+#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
+#include <bits/libc-header-start.h>
+
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <stddef.h>
+
+#define __need___va_list
+#include <stdarg.h>
+
+#include <bits/wchar.h>
+#include <bits/types/wint_t.h>
+#include <bits/types/mbstate_t.h>
+#include <bits/types/__FILE.h>
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+# include <bits/types/FILE.h>
+#endif
+
+/* Tell the caller that we provide correct C++ prototypes.  */
+#if defined __cplusplus && __GNUC_PREREQ (4, 4)
+# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
+#endif
+
+#ifndef WCHAR_MIN
+/* These constants might also be defined in <inttypes.h>.  */
+# define WCHAR_MIN __WCHAR_MIN
+# define WCHAR_MAX __WCHAR_MAX
+#endif
+
+#ifndef WEOF
+# define WEOF (0xffffffffu)
+#endif
+
+/* All versions of XPG prior to the publication of ISO C99 required
+   the bulk of <wctype.h>'s declarations to appear in this header
+   (because <wctype.h> did not exist prior to C99).  In POSIX.1-2001
+   those declarations were marked as XSI extensions; in -2008 they
+   were additionally marked as obsolescent.  _GNU_SOURCE mode
+   anticipates the removal of these declarations in the next revision
+   of POSIX.  */
+#if (defined __USE_XOPEN && !defined __USE_GNU \
+     && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI))
+# include <bits/wctype-wchar.h>
+#endif
+
+__BEGIN_DECLS
+
+/* This incomplete type is defined in <time.h> but needed here because
+   of `wcsftime'.  */
+struct tm;
+
+
+/* Copy SRC to DEST.  */
+extern wchar_t *wcscpy (wchar_t *__restrict __dest,
+			const wchar_t *__restrict __src)
+     __THROW __nonnull ((1, 2));
+
+/* Copy no more than N wide-characters of SRC to DEST.  */
+extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
+			 const wchar_t *__restrict __src, size_t __n)
+     __THROW __nonnull ((1, 2));
+
+/* Append SRC onto DEST.  */
+extern wchar_t *wcscat (wchar_t *__restrict __dest,
+			const wchar_t *__restrict __src)
+     __THROW __nonnull ((1, 2));
+/* Append no more than N wide-characters of SRC onto DEST.  */
+extern wchar_t *wcsncat (wchar_t *__restrict __dest,
+			 const wchar_t *__restrict __src, size_t __n)
+     __THROW __nonnull ((1, 2));
+
+/* Compare S1 and S2.  */
+extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+/* Compare N wide-characters of S1 and S2.  */
+extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
+     __THROW __attribute_pure__ __nonnull ((1, 2));
+
+#ifdef __USE_XOPEN2K8
+/* Compare S1 and S2, ignoring case.  */
+extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
+			size_t __n) __THROW;
+
+/* Similar to the two functions above but take the information from
+   the provided locale and not the global locale.  */
+# include <xlocale.h>
+
+extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
+			 __locale_t __loc) __THROW;
+
+extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
+			  size_t __n, __locale_t __loc) __THROW;
+#endif
+
+/* Compare S1 and S2, both interpreted as appropriate to the
+   LC_COLLATE category of the current locale.  */
+extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
+/* Transform S2 into array pointed to by S1 such that if wcscmp is
+   applied to two transformed strings the result is the as applying
+   `wcscoll' to the original strings.  */
+extern size_t wcsxfrm (wchar_t *__restrict __s1,
+		       const wchar_t *__restrict __s2, size_t __n) __THROW;
+
+#ifdef __USE_XOPEN2K8
+/* Similar to the two functions above but take the information from
+   the provided locale and not the global locale.  */
+
+/* Compare S1 and S2, both interpreted as appropriate to the
+   LC_COLLATE category of the given locale.  */
+extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
+		      __locale_t __loc) __THROW;
+
+/* Transform S2 into array pointed to by S1 such that if wcscmp is
+   applied to two transformed strings the result is the as applying
+   `wcscoll' to the original strings.  */
+extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
+			 size_t __n, __locale_t __loc) __THROW;
+
+/* Duplicate S, returning an identical malloc'd string.  */
+extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
+#endif
+
+/* Find the first occurrence of WC in WCS.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcschr (wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcschr") __attribute_pure__;
+extern "C++" const wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcschr") __attribute_pure__;
+#else
+extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
+     __THROW __attribute_pure__;
+#endif
+/* Find the last occurrence of WC in WCS.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcsrchr (wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcsrchr") __attribute_pure__;
+extern "C++" const wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
+     __THROW __asm ("wcsrchr") __attribute_pure__;
+#else
+extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
+     __THROW __attribute_pure__;
+#endif
+
+#ifdef __USE_GNU
+/* This function is similar to `wcschr'.  But it returns a pointer to
+   the closing NUL wide character in case C is not found in S.  */
+extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
+     __THROW __attribute_pure__;
+#endif
+
+/* Return the length of the initial segmet of WCS which
+   consists entirely of wide characters not in REJECT.  */
+extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
+     __THROW __attribute_pure__;
+/* Return the length of the initial segmet of WCS which
+   consists entirely of wide characters in  ACCEPT.  */
+extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
+     __THROW __attribute_pure__;
+/* Find the first occurrence in WCS of any character in ACCEPT.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcspbrk (wchar_t *__wcs, const wchar_t *__accept)
+     __THROW __asm ("wcspbrk") __attribute_pure__;
+extern "C++" const wchar_t *wcspbrk (const wchar_t *__wcs,
+				     const wchar_t *__accept)
+     __THROW __asm ("wcspbrk") __attribute_pure__;
+#else
+extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
+     __THROW __attribute_pure__;
+#endif
+/* Find the first occurrence of NEEDLE in HAYSTACK.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcsstr (wchar_t *__haystack, const wchar_t *__needle)
+     __THROW __asm ("wcsstr") __attribute_pure__;
+extern "C++" const wchar_t *wcsstr (const wchar_t *__haystack,
+				    const wchar_t *__needle)
+     __THROW __asm ("wcsstr") __attribute_pure__;
+#else
+extern wchar_t *wcsstr (const wchar_t *__haystack, const wchar_t *__needle)
+     __THROW __attribute_pure__;
+#endif
+
+/* Divide WCS into tokens separated by characters in DELIM.  */
+extern wchar_t *wcstok (wchar_t *__restrict __s,
+			const wchar_t *__restrict __delim,
+			wchar_t **__restrict __ptr) __THROW;
+
+/* Return the number of wide characters in S.  */
+extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
+
+#ifdef __USE_XOPEN
+/* Another name for `wcsstr' from XPG4.  */
+# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wcswcs (wchar_t *__haystack, const wchar_t *__needle)
+     __THROW __asm ("wcswcs") __attribute_pure__;
+extern "C++" const wchar_t *wcswcs (const wchar_t *__haystack,
+				    const wchar_t *__needle)
+     __THROW __asm ("wcswcs") __attribute_pure__;
+# else
+extern wchar_t *wcswcs (const wchar_t *__haystack, const wchar_t *__needle)
+     __THROW __attribute_pure__;
+# endif
+#endif
+
+#ifdef __USE_XOPEN2K8
+/* Return the number of wide characters in S, but at most MAXLEN.  */
+extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
+     __THROW __attribute_pure__;
+#endif
+
+
+/* Search N wide characters of S for C.  */
+#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO
+extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
+     __THROW __asm ("wmemchr") __attribute_pure__;
+extern "C++" const wchar_t *wmemchr (const wchar_t *__s, wchar_t __c,
+				     size_t __n)
+     __THROW __asm ("wmemchr") __attribute_pure__;
+#else
+extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
+     __THROW __attribute_pure__;
+#endif
+
+/* Compare N wide characters of S1 and S2.  */
+extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
+     __THROW __attribute_pure__;
+
+/* Copy N wide characters of SRC to DEST.  */
+extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
+			 const wchar_t *__restrict __s2, size_t __n) __THROW;
+
+/* Copy N wide characters of SRC to DEST, guaranteeing
+   correct behavior for overlapping strings.  */
+extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
+     __THROW;
+
+/* Set N wide characters of S to C.  */
+extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
+
+#ifdef __USE_GNU
+/* Copy N wide characters of SRC to DEST and return pointer to following
+   wide character.  */
+extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
+			  const wchar_t *__restrict __s2, size_t __n)
+     __THROW;
+#endif
+
+
+/* Determine whether C constitutes a valid (one-byte) multibyte
+   character.  */
+extern wint_t btowc (int __c) __THROW;
+
+/* Determine whether C corresponds to a member of the extended
+   character set whose multibyte representation is a single byte.  */
+extern int wctob (wint_t __c) __THROW;
+
+/* Determine whether PS points to an object representing the initial
+   state.  */
+extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
+
+/* Write wide character representation of multibyte character pointed
+   to by S to PWC.  */
+extern size_t mbrtowc (wchar_t *__restrict __pwc,
+		       const char *__restrict __s, size_t __n,
+		       mbstate_t *__restrict __p) __THROW;
+
+/* Write multibyte representation of wide character WC to S.  */
+extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
+		       mbstate_t *__restrict __ps) __THROW;
+
+/* Return number of bytes in multibyte character pointed to by S.  */
+extern size_t __mbrlen (const char *__restrict __s, size_t __n,
+			mbstate_t *__restrict __ps) __THROW;
+extern size_t mbrlen (const char *__restrict __s, size_t __n,
+		      mbstate_t *__restrict __ps) __THROW;
+
+#ifdef __USE_EXTERN_INLINES
+/* Define inline function as optimization.  */
+
+/* We can use the BTOWC and WCTOB optimizations since we know that all
+   locales must use ASCII encoding for the values in the ASCII range
+   and because the wchar_t encoding is always ISO 10646.  */
+extern wint_t __btowc_alias (int __c) __asm ("btowc");
+__extern_inline wint_t
+__NTH (btowc (int __c))
+{ return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
+	  ? (wint_t) __c : __btowc_alias (__c)); }
+
+extern int __wctob_alias (wint_t __c) __asm ("wctob");
+__extern_inline int
+__NTH (wctob (wint_t __wc))
+{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
+	  ? (int) __wc : __wctob_alias (__wc)); }
+
+__extern_inline size_t
+__NTH (mbrlen (const char *__restrict __s, size_t __n,
+	       mbstate_t *__restrict __ps))
+{ return (__ps != NULL
+	  ? mbrtowc (NULL, __s, __n, __ps) : __mbrlen (__s, __n, NULL)); }
+#endif
+
+/* Write wide character representation of multibyte character string
+   SRC to DST.  */
+extern size_t mbsrtowcs (wchar_t *__restrict __dst,
+			 const char **__restrict __src, size_t __len,
+			 mbstate_t *__restrict __ps) __THROW;
+
+/* Write multibyte character representation of wide character string
+   SRC to DST.  */
+extern size_t wcsrtombs (char *__restrict __dst,
+			 const wchar_t **__restrict __src, size_t __len,
+			 mbstate_t *__restrict __ps) __THROW;
+
+
+#ifdef	__USE_XOPEN2K8
+/* Write wide character representation of at most NMC bytes of the
+   multibyte character string SRC to DST.  */
+extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
+			  const char **__restrict __src, size_t __nmc,
+			  size_t __len, mbstate_t *__restrict __ps) __THROW;
+
+/* Write multibyte character representation of at most NWC characters
+   from the wide character string SRC to DST.  */
+extern size_t wcsnrtombs (char *__restrict __dst,
+			  const wchar_t **__restrict __src,
+			  size_t __nwc, size_t __len,
+			  mbstate_t *__restrict __ps) __THROW;
+#endif	/* use POSIX 2008 */
+
+
+/* The following functions are extensions found in X/Open CAE.  */
+#ifdef __USE_XOPEN
+/* Determine number of column positions required for C.  */
+extern int wcwidth (wchar_t __c) __THROW;
+
+/* Determine number of column positions required for first N wide
+   characters (or fewer if S ends before this) in S.  */
+extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
+#endif	/* Use X/Open.  */
+
+
+/* Convert initial portion of the wide string NPTR to `double'
+   representation.  */
+extern double wcstod (const wchar_t *__restrict __nptr,
+		      wchar_t **__restrict __endptr) __THROW;
+
+#ifdef __USE_ISOC99
+/* Likewise for `float' and `long double' sizes of floating-point numbers.  */
+extern float wcstof (const wchar_t *__restrict __nptr,
+		     wchar_t **__restrict __endptr) __THROW;
+extern long double wcstold (const wchar_t *__restrict __nptr,
+			    wchar_t **__restrict __endptr) __THROW;
+#endif /* C99 */
+
+
+/* Convert initial portion of wide string NPTR to `long int'
+   representation.  */
+extern long int wcstol (const wchar_t *__restrict __nptr,
+			wchar_t **__restrict __endptr, int __base) __THROW;
+
+/* Convert initial portion of wide string NPTR to `unsigned long int'
+   representation.  */
+extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
+				  wchar_t **__restrict __endptr, int __base)
+     __THROW;
+
+#ifdef __USE_ISOC99
+/* Convert initial portion of wide string NPTR to `long long int'
+   representation.  */
+__extension__
+extern long long int wcstoll (const wchar_t *__restrict __nptr,
+			      wchar_t **__restrict __endptr, int __base)
+     __THROW;
+
+/* Convert initial portion of wide string NPTR to `unsigned long long int'
+   representation.  */
+__extension__
+extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
+					wchar_t **__restrict __endptr,
+					int __base) __THROW;
+#endif /* ISO C99.  */
+
+#ifdef __USE_GNU
+/* Convert initial portion of wide string NPTR to `long long int'
+   representation.  */
+__extension__
+extern long long int wcstoq (const wchar_t *__restrict __nptr,
+			     wchar_t **__restrict __endptr, int __base)
+     __THROW;
+
+/* Convert initial portion of wide string NPTR to `unsigned long long int'
+   representation.  */
+__extension__
+extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
+				       wchar_t **__restrict __endptr,
+				       int __base) __THROW;
+#endif /* Use GNU.  */
+
+#ifdef __USE_GNU
+/* The concept of one static locale per category is not very well
+   thought out.  Many applications will need to process its data using
+   information from several different locales.  Another application is
+   the implementation of the internationalization handling in the
+   upcoming ISO C++ standard library.  To support this another set of
+   the functions using locale data exist which have an additional
+   argument.
+
+   Attention: all these functions are *not* standardized in any form.
+   This is a proof-of-concept implementation.  */
+
+/* Structure for reentrant locale using functions.  This is an
+   (almost) opaque type for the user level programs.  */
+# include <xlocale.h>
+
+/* Special versions of the functions above which take the locale to
+   use as an additional parameter.  */
+extern long int wcstol_l (const wchar_t *__restrict __nptr,
+			  wchar_t **__restrict __endptr, int __base,
+			  __locale_t __loc) __THROW;
+
+extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
+				    wchar_t **__restrict __endptr,
+				    int __base, __locale_t __loc) __THROW;
+
+__extension__
+extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
+				wchar_t **__restrict __endptr,
+				int __base, __locale_t __loc) __THROW;
+
+__extension__
+extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
+					  wchar_t **__restrict __endptr,
+					  int __base, __locale_t __loc)
+     __THROW;
+
+extern double wcstod_l (const wchar_t *__restrict __nptr,
+			wchar_t **__restrict __endptr, __locale_t __loc)
+     __THROW;
+
+extern float wcstof_l (const wchar_t *__restrict __nptr,
+		       wchar_t **__restrict __endptr, __locale_t __loc)
+     __THROW;
+
+extern long double wcstold_l (const wchar_t *__restrict __nptr,
+			      wchar_t **__restrict __endptr,
+			      __locale_t __loc) __THROW;
+#endif	/* use GNU */
+
+
+#ifdef __USE_XOPEN2K8
+/* Copy SRC to DEST, returning the address of the terminating L'\0' in
+   DEST.  */
+extern wchar_t *wcpcpy (wchar_t *__restrict __dest,
+			const wchar_t *__restrict __src) __THROW;
+
+/* Copy no more than N characters of SRC to DEST, returning the address of
+   the last character written into DEST.  */
+extern wchar_t *wcpncpy (wchar_t *__restrict __dest,
+			 const wchar_t *__restrict __src, size_t __n)
+     __THROW;
+#endif
+
+
+/* Wide character I/O functions.  */
+
+#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
+/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
+   a wide character string.  */
+extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW;
+#endif
+
+#if defined __USE_ISOC95 || defined __USE_UNIX98
+
+/* Select orientation for stream.  */
+extern int fwide (__FILE *__fp, int __mode) __THROW;
+
+
+/* Write formatted output to STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fwprintf (__FILE *__restrict __stream,
+		     const wchar_t *__restrict __format, ...)
+     /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
+/* Write formatted output to stdout.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int wprintf (const wchar_t *__restrict __format, ...)
+     /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
+/* Write formatted output of at most N characters to S.  */
+extern int swprintf (wchar_t *__restrict __s, size_t __n,
+		     const wchar_t *__restrict __format, ...)
+     __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
+
+/* Write formatted output to S from argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vfwprintf (__FILE *__restrict __s,
+		      const wchar_t *__restrict __format,
+		      __gnuc_va_list __arg)
+     /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
+/* Write formatted output to stdout from argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vwprintf (const wchar_t *__restrict __format,
+		     __gnuc_va_list __arg)
+     /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
+/* Write formatted output of at most N character to S from argument
+   list ARG.  */
+extern int vswprintf (wchar_t *__restrict __s, size_t __n,
+		      const wchar_t *__restrict __format,
+		      __gnuc_va_list __arg)
+     __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
+
+
+/* Read formatted input from STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fwscanf (__FILE *__restrict __stream,
+		    const wchar_t *__restrict __format, ...)
+     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
+/* Read formatted input from stdin.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int wscanf (const wchar_t *__restrict __format, ...)
+     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
+/* Read formatted input from S.  */
+extern int swscanf (const wchar_t *__restrict __s,
+		    const wchar_t *__restrict __format, ...)
+     __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
+
+# if defined __USE_ISOC99 && !defined __USE_GNU \
+     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+#  ifdef __REDIRECT
+/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
+   GNU extension which conflicts with valid %a followed by letter
+   s, S or [.  */
+extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
+				 const wchar_t *__restrict __format, ...),
+		       __isoc99_fwscanf)
+     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
+extern int __REDIRECT (wscanf, (const wchar_t *__restrict __format, ...),
+		       __isoc99_wscanf)
+     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
+extern int __REDIRECT_NTH (swscanf, (const wchar_t *__restrict __s,
+				     const wchar_t *__restrict __format,
+				     ...), __isoc99_swscanf)
+     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
+#  else
+extern int __isoc99_fwscanf (__FILE *__restrict __stream,
+			     const wchar_t *__restrict __format, ...);
+extern int __isoc99_wscanf (const wchar_t *__restrict __format, ...);
+extern int __isoc99_swscanf (const wchar_t *__restrict __s,
+			     const wchar_t *__restrict __format, ...)
+     __THROW;
+#   define fwscanf __isoc99_fwscanf
+#   define wscanf __isoc99_wscanf
+#   define swscanf __isoc99_swscanf
+#  endif
+# endif
+
+#endif /* Use ISO C95, C99 and Unix98. */
+
+#ifdef __USE_ISOC99
+/* Read formatted input from S into argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vfwscanf (__FILE *__restrict __s,
+		     const wchar_t *__restrict __format,
+		     __gnuc_va_list __arg)
+     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+/* Read formatted input from stdin into argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vwscanf (const wchar_t *__restrict __format,
+		    __gnuc_va_list __arg)
+     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
+/* Read formatted input from S into argument list ARG.  */
+extern int vswscanf (const wchar_t *__restrict __s,
+		     const wchar_t *__restrict __format,
+		     __gnuc_va_list __arg)
+     __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+
+# if !defined __USE_GNU \
+     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+#  ifdef __REDIRECT
+extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
+				  const wchar_t *__restrict __format,
+				  __gnuc_va_list __arg), __isoc99_vfwscanf)
+     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+extern int __REDIRECT (vwscanf, (const wchar_t *__restrict __format,
+				 __gnuc_va_list __arg), __isoc99_vwscanf)
+     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
+extern int __REDIRECT_NTH (vswscanf, (const wchar_t *__restrict __s,
+				      const wchar_t *__restrict __format,
+				      __gnuc_va_list __arg), __isoc99_vswscanf)
+     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+#  else
+extern int __isoc99_vfwscanf (__FILE *__restrict __s,
+			      const wchar_t *__restrict __format,
+			      __gnuc_va_list __arg);
+extern int __isoc99_vwscanf (const wchar_t *__restrict __format,
+			     __gnuc_va_list __arg);
+extern int __isoc99_vswscanf (const wchar_t *__restrict __s,
+			      const wchar_t *__restrict __format,
+			      __gnuc_va_list __arg) __THROW;
+#   define vfwscanf __isoc99_vfwscanf
+#   define vwscanf __isoc99_vwscanf
+#   define vswscanf __isoc99_vswscanf
+#  endif
+# endif
+
+#endif /* Use ISO C99. */
+
+
+/* Read a character from STREAM.
+
+   These functions are possible cancellation points and therefore not
+   marked with __THROW.  */
+extern wint_t fgetwc (__FILE *__stream);
+extern wint_t getwc (__FILE *__stream);
+
+/* Read a character from stdin.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern wint_t getwchar (void);
+
+
+/* Write a character to STREAM.
+
+   These functions are possible cancellation points and therefore not
+   marked with __THROW.  */
+extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
+extern wint_t putwc (wchar_t __wc, __FILE *__stream);
+
+/* Write a character to stdout.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern wint_t putwchar (wchar_t __wc);
+
+
+/* Get a newline-terminated wide character string of finite length
+   from STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
+			__FILE *__restrict __stream);
+
+/* Write a string to STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fputws (const wchar_t *__restrict __ws,
+		   __FILE *__restrict __stream);
+
+
+/* Push a character back onto the input buffer of STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
+
+
+#ifdef __USE_GNU
+/* These are defined to be equivalent to the `char' functions defined
+   in POSIX.1:1996.
+
+   These functions are not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation they are cancellation points and
+   therefore not marked with __THROW.  */
+extern wint_t getwc_unlocked (__FILE *__stream);
+extern wint_t getwchar_unlocked (void);
+
+/* This is the wide character version of a GNU extension.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern wint_t fgetwc_unlocked (__FILE *__stream);
+
+/* Faster version when locking is not necessary.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
+
+/* These are defined to be equivalent to the `char' functions defined
+   in POSIX.1:1996.
+
+   These functions are not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation they are cancellation points and
+   therefore not marked with __THROW.  */
+extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
+extern wint_t putwchar_unlocked (wchar_t __wc);
+
+
+/* This function does the same as `fgetws' but does not lock the stream.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
+				 __FILE *__restrict __stream);
+
+/* This function does the same as `fputws' but does not lock the stream.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern int fputws_unlocked (const wchar_t *__restrict __ws,
+			    __FILE *__restrict __stream);
+#endif
+
+
+/* Format TP into S according to FORMAT.
+   Write no more than MAXSIZE wide characters and return the number
+   of wide characters written, or 0 if it would exceed MAXSIZE.  */
+extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
+			const wchar_t *__restrict __format,
+			const struct tm *__restrict __tp) __THROW;
+
+# ifdef __USE_GNU
+# include <xlocale.h>
+
+/* Similar to `wcsftime' but takes the information from
+   the provided locale and not the global locale.  */
+extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
+			  const wchar_t *__restrict __format,
+			  const struct tm *__restrict __tp,
+			  __locale_t __loc) __THROW;
+# endif
+
+/* Define some macros helping to catch buffer overflows.  */
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
+# include <bits/wchar2.h>
+#endif
+
+#ifdef __LDBL_COMPAT
+# include <bits/wchar-ldbl.h>
+#endif
+
+__END_DECLS
+
+#endif /* wchar.h  */
diff --git a/REORG.TODO/wcsmbs/wcpcpy.c b/REORG.TODO/wcsmbs/wcpcpy.c
new file mode 100644
index 0000000000..a370c57be2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcpcpy.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#define __need_ptrdiff_t
+#include <stddef.h>
+
+#ifdef WCPCPY
+# define __wcpcpy WCPCPY
+#endif
+/* Copy SRC to DEST, returning the address of the terminating L'\0' in
+   DEST.  */
+wchar_t *
+__wcpcpy (wchar_t *dest, const wchar_t *src)
+{
+  wchar_t *wcp = (wchar_t *) dest - 1;
+  wint_t c;
+  const ptrdiff_t off = src - dest + 1;
+
+  do
+    {
+      c = wcp[off];
+      *++wcp = c;
+    }
+  while (c != L'\0');
+
+  return wcp;
+}
+
+#ifndef WCPCPY
+weak_alias (__wcpcpy, wcpcpy)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcpncpy.c b/REORG.TODO/wcsmbs/wcpncpy.c
new file mode 100644
index 0000000000..42c17eadd0
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcpncpy.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCPNCPY
+# define __wcpncpy WCPNCPY
+#endif
+
+/* Copy no more than N wide-characters of SRC to DEST, returning the
+   address of the last character written into DEST.  */
+wchar_t *
+__wcpncpy (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  wint_t c;
+  wchar_t *const s = dest;
+
+  if (n >= 4)
+    {
+      size_t n4 = n >> 2;
+
+      for (;;)
+	{
+	  c = *src++;
+	  *dest++ = c;
+	  if (c == L'\0')
+	    break;
+	  c = *src++;
+	  *dest++ = c;
+	  if (c == L'\0')
+	    break;
+	  c = *src++;
+	  *dest++ = c;
+	  if (c == L'\0')
+	    break;
+	  c = *src++;
+	  *dest++ = c;
+	  if (c == L'\0')
+	    break;
+	  if (--n4 == 0)
+	    goto last_chars;
+	}
+      n -= dest - s;
+      goto zero_fill;
+    }
+
+ last_chars:
+  n &= 3;
+  if (n == 0)
+    return dest;
+
+  for (;;)
+    {
+      c = *src++;
+      --n;
+      *dest++ = c;
+      if (c == L'\0')
+	break;
+      if (n == 0)
+	return dest;
+    }
+
+ zero_fill:
+  while (n-- > 0)
+    dest[n] = L'\0';
+
+  return dest - 1;
+}
+
+#ifndef WCPNCPY
+weak_alias (__wcpncpy, wcpncpy)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcrtomb.c b/REORG.TODO/wcsmbs/wcrtomb.c
new file mode 100644
index 0000000000..cc74503374
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcrtomb.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+__wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
+{
+  char buf[MB_LEN_MAX];
+  struct __gconv_step_data data;
+  int status;
+  size_t result;
+  size_t dummy;
+  const struct gconv_fcts *fcts;
+
+  /* Set information for this step.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps ?: &state;
+
+  /* A first special case is if S is NULL.  This means put PS in the
+     initial state.  */
+  if (s == NULL)
+    {
+      s = buf;
+      wc = L'\0';
+    }
+
+  /* Tell where we want to have the result.  */
+  data.__outbuf = (unsigned char *) s;
+  data.__outbufend = (unsigned char *) s + MB_CUR_MAX;
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+  __gconv_fct fct = fcts->tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  /* If WC is the NUL character we write into the output buffer the byte
+     sequence necessary for PS to get into the initial state, followed
+     by a NUL byte.  */
+  if (wc == L'\0')
+    {
+      status = DL_CALL_FCT (fct, (fcts->tomb, &data, NULL, NULL,
+				  NULL, &dummy, 1, 1));
+
+      if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	*data.__outbuf++ = '\0';
+    }
+  else
+    {
+      /* Do a normal conversion.  */
+      const unsigned char *inbuf = (const unsigned char *) &wc;
+
+      status = DL_CALL_FCT (fct,
+			    (fcts->tomb, &data, &inbuf,
+			     inbuf + sizeof (wchar_t), NULL, &dummy, 0, 1));
+    }
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  The output buffer must be large enough, otherwise the
+     definition of MB_CUR_MAX is not correct.  All the other possible
+     errors also must not happen.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+      || status == __GCONV_FULL_OUTPUT)
+    result = data.__outbuf - (unsigned char *) s;
+  else
+    {
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
+weak_alias (__wcrtomb, wcrtomb)
+libc_hidden_weak (wcrtomb)
+
+/* There should be no difference between the UTF-32 handling required
+   by c32rtomb and the wchar_t handling which has long since been
+   implemented in wcrtomb.  */
+weak_alias (__wcrtomb, c32rtomb)
diff --git a/REORG.TODO/wcsmbs/wcsatcliff.c b/REORG.TODO/wcsmbs/wcsatcliff.c
new file mode 100644
index 0000000000..95afff6098
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsatcliff.c
@@ -0,0 +1,23 @@
+#include <wchar.h>
+
+#define WCSTEST 1
+#define L(c) L##c
+#define CHAR wchar_t
+#define MEMSET wmemset
+#define STRLEN wcslen
+#define STRNLEN wcsnlen
+#define STRCHR wcschr
+#define STRRCHR wcsrchr
+#define STRCPY wcscpy
+#define STRNCPY wcsncpy
+#define MEMCMP wmemcmp
+#define STPCPY wcpcpy
+#define STPNCPY wcpncpy
+#define MEMCPY wmemcpy
+#define MEMPCPY wmempcpy
+#define MEMCHR wmemchr
+#define STRCMP wcscmp
+#define STRNCMP wcsncmp
+
+
+#include "../string/stratcliff.c"
diff --git a/REORG.TODO/wcsmbs/wcscasecmp.c b/REORG.TODO/wcsmbs/wcscasecmp.c
new file mode 100644
index 0000000000..0f02e505c0
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscasecmp.c
@@ -0,0 +1,67 @@
+/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <wctype.h>
+#include <wchar.h>
+
+#ifndef weak_alias
+# define __wcscasecmp wcscasecmp
+# define TOLOWER(Ch) towlower (Ch)
+#else
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define __wcscasecmp __wcscasecmp_l
+#  define TOLOWER(Ch) __towlower_l ((Ch), loc)
+# else
+#  define TOLOWER(Ch) towlower (Ch)
+# endif
+#endif
+
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# define LOCALE_PARAM , __locale_t loc
+#else
+# define LOCALE_PARAM
+#endif
+
+/* Compare S1 and S2, ignoring case, returning less than, equal to or
+   greater than zero if S1 is lexicographically less than,
+   equal to or greater than S2.  */
+int
+__wcscasecmp (const wchar_t *s1, const wchar_t *s2 LOCALE_PARAM)
+{
+  wint_t c1, c2;
+
+  if (s1 == s2)
+    return 0;
+
+  do
+    {
+      c1 = TOLOWER (*s1++);
+      c2 = TOLOWER (*s2++);
+      if (c1 == L'\0')
+	break;
+    }
+  while (c1 == c2);
+
+  return c1 - c2;
+}
+#ifndef __wcscasecmp
+weak_alias (__wcscasecmp, wcscasecmp)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcscasecmp_l.c b/REORG.TODO/wcsmbs/wcscasecmp_l.c
new file mode 100644
index 0000000000..9fa1cc621e
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscasecmp_l.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define USE_IN_EXTENDED_LOCALE_MODEL	1
+#include <wcscasecmp.c>
+
+libc_hidden_def (__wcscasecmp_l)
+weak_alias (__wcscasecmp_l, wcscasecmp_l)
diff --git a/REORG.TODO/wcsmbs/wcscat.c b/REORG.TODO/wcsmbs/wcscat.c
new file mode 100644
index 0000000000..d567b7309b
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscat.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSCAT
+# define __wcscat WCSCAT
+#endif
+
+/* Append SRC on the end of DEST.  */
+wchar_t *
+__wcscat (wchar_t *dest, const wchar_t *src)
+{
+  wchar_t *s1 = dest;
+  const wchar_t *s2 = src;
+  wchar_t c;
+
+  /* Find the end of the string.  */
+  do
+    c = *s1++;
+  while (c != L'\0');
+
+  /* Make S1 point before the next character, so we can increment
+     it while memory is read (wins on pipelined cpus).	*/
+  s1 -= 2;
+
+  do
+    {
+      c = *s2++;
+      *++s1 = c;
+    }
+  while (c != L'\0');
+
+  return dest;
+}
+#ifndef WCSCAT
+weak_alias (__wcscat, wcscat)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcschr.c b/REORG.TODO/wcsmbs/wcschr.c
new file mode 100644
index 0000000000..210ae07647
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcschr.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifndef WCSCHR
+# define WCSCHR __wcschr
+#endif
+
+/* Find the first occurrence of WC in WCS.  */
+wchar_t *
+WCSCHR (const wchar_t *wcs, const wchar_t wc)
+{
+  do
+    if (*wcs == wc)
+      return (wchar_t *) wcs;
+  while (*wcs++ != L'\0');
+
+  return NULL;
+}
+libc_hidden_def (__wcschr)
+weak_alias (__wcschr, wcschr)
+libc_hidden_weak (wcschr)
diff --git a/REORG.TODO/wcsmbs/wcschrnul.c b/REORG.TODO/wcsmbs/wcschrnul.c
new file mode 100644
index 0000000000..67ddb1a884
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcschrnul.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSCHRNUL
+# define __wcschrnul WCSCHRNUL
+#endif
+
+/* Find the first occurrence of WC in WCS.  */
+wchar_t *
+__wcschrnul (const wchar_t *wcs, const wchar_t wc)
+{
+  while (*wcs != L'\0')
+    if (*wcs == wc)
+      break;
+    else
+      ++wcs;
+
+  return (wchar_t *) wcs;
+}
+#ifndef WCSCHRNUL
+weak_alias (__wcschrnul, wcschrnul)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcscmp.c b/REORG.TODO/wcsmbs/wcscmp.c
new file mode 100644
index 0000000000..9c0d761311
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscmp.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifndef WCSCMP
+# define WCSCMP __wcscmp
+#endif
+
+/* Compare S1 and S2, returning less than, equal to or
+   greater than zero if S1 is lexicographically less than,
+   equal to or greater than S2.	 */
+int
+WCSCMP (const wchar_t *s1, const wchar_t *s2)
+{
+  wchar_t c1, c2;
+
+  do
+    {
+      c1 = *s1++;
+      c2 = *s2++;
+      if (c2 == L'\0')
+	return c1 - c2;
+    }
+  while (c1 == c2);
+
+  return c1 < c2 ? -1 : 1;
+}
+libc_hidden_def (WCSCMP)
+weak_alias (WCSCMP, wcscmp)
diff --git a/REORG.TODO/wcsmbs/wcscoll.c b/REORG.TODO/wcsmbs/wcscoll.c
new file mode 100644
index 0000000000..88c60fde17
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscoll.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include "../locale/coll-lookup.h"
+
+#define STRING_TYPE wchar_t
+#define USTRING_TYPE wint_t
+#define STRCOLL __wcscoll
+#define STRCOLL_L __wcscoll_l
+#define USE_HIDDEN_DEF
+
+#include "../string/strcoll.c"
+
+#ifndef USE_IN_EXTENDED_LOCALE_MODEL
+weak_alias (__wcscoll, wcscoll)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcscoll_l.c b/REORG.TODO/wcsmbs/wcscoll_l.c
new file mode 100644
index 0000000000..b5e760389a
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscoll_l.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+
+#include <wchar.h>
+#include "../locale/coll-lookup.h"
+
+#define STRING_TYPE wchar_t
+#define USTRING_TYPE wint_t
+#define STRCOLL __wcscoll_l
+#define STRCMP __wcscmp
+#define WEIGHT_H "../locale/weightwc.h"
+#define SUFFIX	WC
+#define L(arg) L##arg
+#define WIDE_CHAR_VERSION 1
+
+#include "../string/strcoll_l.c"
+
+weak_alias (__wcscoll_l, wcscoll_l)
diff --git a/REORG.TODO/wcsmbs/wcscpy.c b/REORG.TODO/wcsmbs/wcscpy.c
new file mode 100644
index 0000000000..21dd547961
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscpy.c
@@ -0,0 +1,60 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <wchar.h>
+
+
+#ifndef WCSCPY
+# define WCSCPY wcscpy
+#endif
+
+/* Copy SRC to DEST.  */
+wchar_t *
+WCSCPY (wchar_t *dest, const wchar_t *src)
+{
+  wint_t c;
+  wchar_t *wcp;
+
+  if (__alignof__ (wchar_t) >= sizeof (wchar_t))
+    {
+      const ptrdiff_t off = dest - src - 1;
+
+      wcp = (wchar_t *) src;
+
+      do
+	{
+	  c = *wcp++;
+	  wcp[off] = c;
+	}
+      while (c != L'\0');
+    }
+  else
+    {
+      wcp = dest;
+
+      do
+	{
+	  c = *src++;
+	  *wcp++ = c;
+	}
+      while (c != L'\0');
+    }
+
+  return dest;
+}
diff --git a/REORG.TODO/wcsmbs/wcscspn.c b/REORG.TODO/wcsmbs/wcscspn.c
new file mode 100644
index 0000000000..5e74d464c5
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcscspn.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSCSPN
+# define wcscspn WCSCSPN
+#endif
+
+/* Return the length of the maximum initial segment
+   of WCS which contains only wide-characters not in REJECT.  */
+size_t
+wcscspn (const wchar_t *wcs, const wchar_t *reject)
+{
+  size_t count = 0;
+
+  while (*wcs != L'\0')
+    if (wcschr (reject, *wcs++) == NULL)
+      ++count;
+    else
+      return count;
+
+  return count;
+}
diff --git a/REORG.TODO/wcsmbs/wcsdup.c b/REORG.TODO/wcsmbs/wcsdup.c
new file mode 100644
index 0000000000..4215541476
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsdup.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+/* Duplicate S, returning an identical malloc'd string.	 */
+wchar_t *
+wcsdup (const wchar_t *s)
+{
+  size_t len = (__wcslen (s) + 1) * sizeof (wchar_t);
+  void *new = malloc (len);
+
+  if (new == NULL)
+    return NULL;
+
+  return (wchar_t *) memcpy (new, (void *) s, len);
+}
diff --git a/REORG.TODO/wcsmbs/wcslen.c b/REORG.TODO/wcsmbs/wcslen.c
new file mode 100644
index 0000000000..716b390b1d
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcslen.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+/* Return length of string S.  */
+#ifdef WCSLEN
+# define __wcslen WCSLEN
+#endif
+
+size_t
+__wcslen (const wchar_t *s)
+{
+  size_t len = 0;
+
+  while (s[len] != L'\0')
+    {
+      if (s[++len] == L'\0')
+	return len;
+      if (s[++len] == L'\0')
+	return len;
+      if (s[++len] == L'\0')
+	return len;
+      ++len;
+    }
+
+  return len;
+}
+#ifndef WCSLEN
+weak_alias (__wcslen, wcslen)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcsmbs-tst1.c b/REORG.TODO/wcsmbs/wcsmbs-tst1.c
new file mode 100644
index 0000000000..0d0e18f63a
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsmbs-tst1.c
@@ -0,0 +1,59 @@
+/* Based on a test program by Won Kyu Park <wkpark@chem.skku.ac.kr>.  */
+
+#include <wchar.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wctype.h>
+#include <locale.h>
+
+int
+main (void)
+{
+  int test = 0;
+  int idx = 0;
+  char buf[100], *pchar;
+  wchar_t tmp[10];
+  wchar_t tmp1[] = { L'W', L'o', L'r', L'l', L'd', L'\0' };
+  char str[] = "Hello";
+  int result = 0;
+
+  pchar = setlocale (LC_ALL, "de_DE.UTF-8");
+  printf ("locale : %s\n",pchar);
+  printf ("MB_CUR_MAX %Zd\n", MB_CUR_MAX);
+
+  puts ("---- test 1 ------");
+  test = mbstowcs (tmp, str, (strlen (str) + 1) * sizeof (char));
+  printf ("size of string by mbstowcs %d\n", test);
+  if (test != strlen (str))
+    result = 1;
+  idx += wctomb (&buf[0], tmp[0]);
+  idx += wctomb (&buf[idx], tmp[1]);
+  buf[idx] = 0;
+  printf ("orig string %s\n", str);
+  printf ("string by wctomb %s\n", buf);
+  printf ("string by %%C %C", (wint_t) tmp[0]);
+  if (tmp[0] != L'H')
+    result = 1;
+  printf ("%C\n", (wint_t) tmp[1]);
+  if (tmp[1] != L'e')
+    result = 1;
+  printf ("string by %%S %S\n", tmp);
+  if (wcscmp (tmp, L"Hello") != 0)
+    result = 1;
+  puts ("---- test 2 ------");
+  printf ("wchar string %S\n", tmp1);
+  printf ("wchar %C\n", (wint_t) tmp1[0]);
+  test = wcstombs (buf, tmp1, (wcslen (tmp1) + 1) * sizeof (wchar_t));
+  printf ("size of string by wcstombs %d\n", test);
+  if (test != wcslen (tmp1))
+    result = 1;
+  test = wcslen (tmp1);
+  printf ("size of string by wcslen %d\n", test);
+  printf ("char %s\n", buf);
+  if (strcmp (buf, "World") != 0)
+    result = 1;
+  puts ("------------------");
+
+  return result;
+}
diff --git a/REORG.TODO/wcsmbs/wcsmbsload.c b/REORG.TODO/wcsmbs/wcsmbsload.c
new file mode 100644
index 0000000000..656cc0a8e8
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsmbsload.c
@@ -0,0 +1,270 @@
+/* Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <ctype.h>
+#include <langinfo.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <locale/localeinfo.h>
+#include <wcsmbsload.h>
+#include <libc-lock.h>
+
+
+/* These are the descriptions for the default conversion functions.  */
+static const struct __gconv_step to_wc =
+{
+  .__shlib_handle = NULL,
+  .__modname = NULL,
+  .__counter = INT_MAX,
+  .__from_name = (char *) "ANSI_X3.4-1968//TRANSLIT",
+  .__to_name = (char *) "INTERNAL",
+  .__fct = __gconv_transform_ascii_internal,
+  .__btowc_fct = __gconv_btwoc_ascii,
+  .__init_fct = NULL,
+  .__end_fct = NULL,
+  .__min_needed_from = 1,
+  .__max_needed_from = 1,
+  .__min_needed_to = 4,
+  .__max_needed_to = 4,
+  .__stateful = 0,
+  .__data = NULL
+};
+
+static const struct __gconv_step to_mb =
+{
+  .__shlib_handle = NULL,
+  .__modname = NULL,
+  .__counter = INT_MAX,
+  .__from_name = (char *) "INTERNAL",
+  .__to_name = (char *) "ANSI_X3.4-1968//TRANSLIT",
+  .__fct = __gconv_transform_internal_ascii,
+  .__btowc_fct = NULL,
+  .__init_fct = NULL,
+  .__end_fct = NULL,
+  .__min_needed_from = 4,
+  .__max_needed_from = 4,
+  .__min_needed_to = 1,
+  .__max_needed_to = 1,
+  .__stateful = 0,
+  .__data = NULL
+};
+
+
+/* For the default locale we only have to handle ANSI_X3.4-1968.  */
+const struct gconv_fcts __wcsmbs_gconv_fcts_c =
+{
+  .towc = (struct __gconv_step *) &to_wc,
+  .towc_nsteps = 1,
+  .tomb = (struct __gconv_step *) &to_mb,
+  .tomb_nsteps = 1,
+};
+
+
+attribute_hidden
+struct __gconv_step *
+__wcsmbs_getfct (const char *to, const char *from, size_t *nstepsp)
+{
+  size_t nsteps;
+  struct __gconv_step *result;
+#if 0
+  size_t nstateful;
+  size_t cnt;
+#endif
+
+  if (__gconv_find_transform (to, from, &result, &nsteps, 0) != __GCONV_OK)
+    /* Loading the conversion step is not possible.  */
+    return NULL;
+
+  /* Maybe it is someday necessary to allow more than one step.
+     Currently this is not the case since the conversions handled here
+     are from and to INTERNAL and there always is a converted for
+     that.  It the directly following code is enabled the libio
+     functions will have to allocate appropriate __gconv_step_data
+     elements instead of only one.  */
+#if 0
+  /* Count the number of stateful conversions.  Since we will only
+     have one 'mbstate_t' object available we can only deal with one
+     stateful conversion.  */
+  nstateful = 0;
+  for (cnt = 0; cnt < nsteps; ++cnt)
+    if (result[cnt].__stateful)
+      ++nstateful;
+  if (nstateful > 1)
+#else
+  if (nsteps > 1)
+#endif
+    {
+      /* We cannot handle this case.  */
+      __gconv_close_transform (result, nsteps);
+      result = NULL;
+    }
+  else
+    *nstepsp = nsteps;
+
+  return result;
+}
+
+
+/* Extract from the given locale name the character set portion.  Since
+   only the XPG form of the name includes this information we don't have
+   to take care for the CEN form.  */
+#define extract_charset_name(str) \
+  ({									      \
+    const char *cp = str;						      \
+    char *result = NULL;						      \
+									      \
+    cp += strcspn (cp, "@.+,");						      \
+    if (*cp == '.')							      \
+      {									      \
+	const char *endp = ++cp;					      \
+	while (*endp != '\0' && *endp != '@')				      \
+	  ++endp;							      \
+	if (endp != cp)							      \
+	  result = strndupa (cp, endp - cp);				      \
+      }									      \
+    result;								      \
+  })
+
+
+/* Some of the functions here must not be used while setlocale is called.  */
+__libc_rwlock_define (extern, __libc_setlocale_lock attribute_hidden)
+
+/* Load conversion functions for the currently selected locale.  */
+void
+internal_function
+__wcsmbs_load_conv (struct __locale_data *new_category)
+{
+  /* Acquire the lock.  */
+  __libc_rwlock_wrlock (__libc_setlocale_lock);
+
+  /* We should repeat the test since while we waited some other thread
+     might have run this function.  */
+  if (__glibc_likely (new_category->private.ctype == NULL))
+    {
+      /* We must find the real functions.  */
+      const char *charset_name;
+      const char *complete_name;
+      struct gconv_fcts *new_fcts;
+      int use_translit;
+
+      /* Allocate the gconv_fcts structure.  */
+      new_fcts = calloc (1, sizeof *new_fcts);
+      if (new_fcts == NULL)
+	goto failed;
+
+      /* Get name of charset of the locale.  */
+      charset_name = new_category->values[_NL_ITEM_INDEX(CODESET)].string;
+
+      /* Does the user want transliteration?  */
+      use_translit = new_category->use_translit;
+
+      /* Normalize the name and add the slashes necessary for a
+	 complete lookup.  */
+      complete_name = norm_add_slashes (charset_name,
+					use_translit ? "TRANSLIT" : "");
+
+      /* It is not necessary to use transliteration in this direction
+	 since the internal character set is supposed to be able to
+	 represent all others.  */
+      new_fcts->towc = __wcsmbs_getfct ("INTERNAL", complete_name,
+					&new_fcts->towc_nsteps);
+      if (new_fcts->towc != NULL)
+	new_fcts->tomb = __wcsmbs_getfct (complete_name, "INTERNAL",
+					  &new_fcts->tomb_nsteps);
+
+      /* If any of the conversion functions is not available we don't
+	 use any since this would mean we cannot convert back and
+	 forth.  NB: NEW_FCTS was allocated with calloc.  */
+      if (new_fcts->tomb == NULL)
+	{
+	  if (new_fcts->towc != NULL)
+	    __gconv_close_transform (new_fcts->towc, new_fcts->towc_nsteps);
+
+	  free (new_fcts);
+
+	failed:
+	  new_category->private.ctype = &__wcsmbs_gconv_fcts_c;
+	}
+      else
+	{
+	  new_category->private.ctype = new_fcts;
+	  new_category->private.cleanup = &_nl_cleanup_ctype;
+	}
+    }
+
+  __libc_rwlock_unlock (__libc_setlocale_lock);
+}
+
+
+/* Clone the current conversion function set.  */
+void
+internal_function
+__wcsmbs_clone_conv (struct gconv_fcts *copy)
+{
+  const struct gconv_fcts *orig;
+
+  orig = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Copy the data.  */
+  *copy = *orig;
+
+  /* Now increment the usage counters.
+     Note: This assumes copy->*_nsteps == 1.  */
+  if (copy->towc->__shlib_handle != NULL)
+    ++copy->towc->__counter;
+  if (copy->tomb->__shlib_handle != NULL)
+    ++copy->tomb->__counter;
+}
+
+
+/* Get converters for named charset.  */
+int
+internal_function
+__wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
+{
+  copy->towc = __wcsmbs_getfct ("INTERNAL", name, &copy->towc_nsteps);
+  if (copy->towc == NULL)
+    return 1;
+
+  copy->tomb = __wcsmbs_getfct (name, "INTERNAL", &copy->tomb_nsteps);
+  if (copy->tomb == NULL)
+    {
+      __gconv_close_transform (copy->towc, copy->towc_nsteps);
+      return 1;
+    }
+
+  return 0;
+}
+
+void internal_function
+_nl_cleanup_ctype (struct __locale_data *locale)
+{
+  const struct gconv_fcts *const data = locale->private.ctype;
+  if (data != NULL)
+    {
+      locale->private.ctype = NULL;
+      locale->private.cleanup = NULL;
+
+      /* Free the old conversions.  */
+      __gconv_close_transform (data->tomb, data->tomb_nsteps);
+      __gconv_close_transform (data->towc, data->towc_nsteps);
+      free ((char *) data);
+    }
+}
diff --git a/REORG.TODO/wcsmbs/wcsmbsload.h b/REORG.TODO/wcsmbs/wcsmbsload.h
new file mode 100644
index 0000000000..3e254a877e
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsmbsload.h
@@ -0,0 +1,80 @@
+/* Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _WCSMBSLOAD_H
+#define _WCSMBSLOAD_H	1
+
+#include <locale.h>
+#include <wchar.h>
+#include <locale/localeinfo.h>
+
+
+/* Contains pointers to the used functions in the `gconv' modules.  */
+struct gconv_fcts
+  {
+    struct __gconv_step *towc;
+    size_t towc_nsteps;
+    struct __gconv_step *tomb;
+    size_t tomb_nsteps;
+  };
+
+/* Set of currently active conversion functions.  */
+extern const struct gconv_fcts __wcsmbs_gconv_fcts_c attribute_hidden;
+
+/* Load conversion functions for the currently selected locale.  */
+extern void __wcsmbs_load_conv (struct __locale_data *new_category)
+     internal_function;
+
+/* Clone the current `__wcsmbs_load_conv' value.  */
+extern void __wcsmbs_clone_conv (struct gconv_fcts *copy)
+     internal_function;
+
+/* Find the conversion functions for converting to and from NAME.  */
+extern int __wcsmbs_named_conv (struct gconv_fcts *copy, const char *name)
+     internal_function;
+
+/* Function used for the `private.cleanup' hook.  */
+extern void _nl_cleanup_ctype (struct __locale_data *)
+     internal_function attribute_hidden;
+
+
+#include <iconv/gconv_int.h>
+
+
+/* Load the function implementation if necessary.  */
+extern struct __gconv_step *__wcsmbs_getfct (const char *to, const char *from,
+					     size_t *nstepsp)
+     attribute_hidden;
+
+extern const struct __locale_data _nl_C_LC_CTYPE attribute_hidden;
+
+/* Check whether the LC_CTYPE locale changed since the last call.
+   Update the pointers appropriately.  */
+static inline const struct gconv_fcts *
+get_gconv_fcts (struct __locale_data *data)
+{
+  if (__glibc_unlikely (data->private.ctype == NULL))
+    {
+      if (__glibc_unlikely (data == &_nl_C_LC_CTYPE))
+	return &__wcsmbs_gconv_fcts_c;
+      __wcsmbs_load_conv (data);
+    }
+  return data->private.ctype;
+}
+
+#endif	/* wcsmbsload.h */
diff --git a/REORG.TODO/wcsmbs/wcsncase.c b/REORG.TODO/wcsmbs/wcsncase.c
new file mode 100644
index 0000000000..945434ce5a
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsncase.c
@@ -0,0 +1,69 @@
+/* Compare at most N wide characters of two strings without taking care
+   for the case.
+   Copyright (C) 1992-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <wchar.h>
+#include <wctype.h>
+
+#ifndef weak_alias
+# define __wcsncasecmp wcsncasecmp
+# define TOLOWER(Ch) towlower (Ch)
+#else
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define __wcsncasecmp __wcsncasecmp_l
+#  define TOLOWER(Ch) __towlower_l ((Ch), loc)
+# else
+#  define TOLOWER(Ch) towlower (Ch)
+# endif
+#endif
+
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# define LOCALE_PARAM , __locale_t loc
+#else
+# define LOCALE_PARAM
+#endif
+
+/* Compare no more than N wide characters of S1 and S2,
+   ignoring case, returning less than, equal to or
+   greater than zero if S1 is lexicographically less
+   than, equal to or greater than S2.  */
+int
+__wcsncasecmp (const wchar_t *s1, const wchar_t *s2, size_t n LOCALE_PARAM)
+{
+  wint_t c1, c2;
+
+  if (s1 == s2 || n == 0)
+    return 0;
+
+  do
+    {
+      c1 = (wint_t) TOLOWER (*s1++);
+      c2 = (wint_t) TOLOWER (*s2++);
+      if (c1 == L'\0' || c1 != c2)
+	return c1 - c2;
+    } while (--n > 0);
+
+  return c1 - c2;
+}
+#ifndef __wcsncasecmp
+weak_alias (__wcsncasecmp, wcsncasecmp)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcsncase_l.c b/REORG.TODO/wcsmbs/wcsncase_l.c
new file mode 100644
index 0000000000..70d9e6d51b
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsncase_l.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define USE_IN_EXTENDED_LOCALE_MODEL	1
+#include <wcsncase.c>
+
+libc_hidden_def (__wcsncasecmp_l)
+weak_alias (__wcsncasecmp_l, wcsncasecmp_l)
diff --git a/REORG.TODO/wcsmbs/wcsncat.c b/REORG.TODO/wcsmbs/wcsncat.c
new file mode 100644
index 0000000000..225d826c50
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsncat.c
@@ -0,0 +1,79 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifndef WCSNCAT
+# define WCSNCAT wcsncat
+#endif
+
+/* Append no more than N wide-character of SRC onto DEST.  */
+wchar_t *
+WCSNCAT (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  wchar_t c;
+  wchar_t * const s = dest;
+
+  /* Find the end of DEST.  */
+  do
+    c = *dest++;
+  while (c != L'\0');
+
+  /* Make DEST point before next character, so we can increment
+     it while memory is read (wins on pipelined cpus).	*/
+  dest -= 2;
+
+  if (n >= 4)
+    {
+      size_t n4 = n >> 2;
+      do
+	{
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    return s;
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    return s;
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    return s;
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    return s;
+	} while (--n4 > 0);
+      n &= 3;
+    }
+
+  while (n > 0)
+    {
+      c = *src++;
+      *++dest = c;
+      if (c == L'\0')
+	return s;
+      n--;
+    }
+
+  if (c != L'\0')
+    *++dest = L'\0';
+
+  return s;
+}
diff --git a/REORG.TODO/wcsmbs/wcsncmp.c b/REORG.TODO/wcsmbs/wcsncmp.c
new file mode 100644
index 0000000000..9fe57c7893
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsncmp.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifndef WCSNCMP
+# define WCSNCMP wcsncmp
+#endif
+
+/* Compare no more than N characters of S1 and S2,
+   returning less than, equal to or greater than zero
+   if S1 is lexicographically less than, equal to or
+   greater than S2.  */
+int
+WCSNCMP (const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  wchar_t c1 = L'\0';
+  wchar_t c2 = L'\0';
+
+  if (n >= 4)
+    {
+      size_t n4 = n >> 2;
+      do
+	{
+	  c1 = *s1++;
+	  c2 = *s2++;
+	  if (c1 == L'\0' || c1 != c2)
+	    return c1 > c2 ? 1 : (c1 < c2 ? -1 : 0);
+	  c1 = *s1++;
+	  c2 = *s2++;
+	  if (c1 == L'\0' || c1 != c2)
+	    return c1 > c2 ? 1 : (c1 < c2 ? -1 : 0);
+	  c1 = *s1++;
+	  c2 = *s2++;
+	  if (c1 == L'\0' || c1 != c2)
+	    return c1 > c2 ? 1 : (c1 < c2 ? -1 : 0);
+	  c1 = *s1++;
+	  c2 = *s2++;
+	  if (c1 == L'\0' || c1 != c2)
+	    return c1 > c2 ? 1 : (c1 < c2 ? -1 : 0);
+	} while (--n4 > 0);
+      n &= 3;
+    }
+
+  while (n > 0)
+    {
+      c1 = *s1++;
+      c2 = *s2++;
+      if (c1 == L'\0' || c1 != c2)
+	return c1 > c2 ? 1 : (c1 < c2 ? -1 : 0);
+      n--;
+    }
+
+  return 0;
+}
diff --git a/REORG.TODO/wcsmbs/wcsncpy.c b/REORG.TODO/wcsmbs/wcsncpy.c
new file mode 100644
index 0000000000..27bfb0d0da
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsncpy.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSNCPY
+# define __wcsncpy WCSNCPY
+#endif
+
+/* Copy no more than N wide-characters of SRC to DEST.	*/
+wchar_t *
+__wcsncpy (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  wint_t c;
+  wchar_t *const s = dest;
+
+  --dest;
+
+  if (n >= 4)
+    {
+      size_t n4 = n >> 2;
+
+      for (;;)
+	{
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    break;
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    break;
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    break;
+	  c = *src++;
+	  *++dest = c;
+	  if (c == L'\0')
+	    break;
+	  if (--n4 == 0)
+	    goto last_chars;
+	}
+      n = n - (dest - s) - 1;
+      if (n == 0)
+	return s;
+      goto zero_fill;
+    }
+
+ last_chars:
+  n &= 3;
+  if (n == 0)
+    return s;
+
+  do
+    {
+      c = *src++;
+      *++dest = c;
+      if (--n == 0)
+	return s;
+    }
+  while (c != L'\0');
+
+ zero_fill:
+  do
+    *++dest = L'\0';
+  while (--n > 0);
+
+  return s;
+}
+#ifndef WCSNCPY
+weak_alias (__wcsncpy, wcsncpy)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcsnlen.c b/REORG.TODO/wcsmbs/wcsnlen.c
new file mode 100644
index 0000000000..21bb6db0c7
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsnlen.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1998-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSNLEN
+# define __wcsnlen WCSNLEN
+#endif
+
+/* Return length of string S at most maxlen.  */
+size_t
+__wcsnlen (const wchar_t *s, size_t maxlen)
+{
+  size_t len = 0;
+
+  while (maxlen > 0 && s[len] != L'\0')
+    {
+      ++len;
+      if (--maxlen == 0 || s[len] == L'\0')
+	return len;
+      ++len;
+      if (--maxlen == 0 || s[len] == L'\0')
+	return len;
+      ++len;
+      if (--maxlen == 0 || s[len] == L'\0')
+	return len;
+      ++len;
+      --maxlen;
+    }
+
+  return len;
+}
+#ifndef WCSNLEN
+weak_alias (__wcsnlen, wcsnlen)
+#endif
diff --git a/REORG.TODO/wcsmbs/wcsnrtombs.c b/REORG.TODO/wcsmbs/wcsnrtombs.c
new file mode 100644
index 0000000000..9c331dc0e6
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsnrtombs.c
@@ -0,0 +1,148 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <gconv.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+/* This is a non-standard function but it is very useful in the
+   implementation of stdio because we have to deal with unterminated
+   buffers.  At most NWC wide character will be converted.  */
+size_t
+__wcsnrtombs (char *dst, const wchar_t **src, size_t nwc, size_t len,
+	      mbstate_t *ps)
+{
+  struct __gconv_step_data data;
+  const wchar_t *srcend;
+  int status;
+  size_t result;
+  struct __gconv_step *tomb;
+  const struct gconv_fcts *fcts;
+
+  /* Tell where we want the result.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps ?: &state;
+
+  if (nwc == 0)
+    return 0;
+  srcend = *src + __wcsnlen (*src, nwc - 1) + 1;
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Get the structure with the function pointers.  */
+  tomb = fcts->tomb;
+  __gconv_fct fct = tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  /* We have to handle DST == NULL special.  */
+  if (dst == NULL)
+    {
+      mbstate_t temp_state;
+      unsigned char buf[256];		/* Just an arbitrary value.  */
+      const unsigned char *inbuf = (const unsigned char *) *src;
+      size_t dummy;
+
+      temp_state = *data.__statep;
+      data.__statep = &temp_state;
+
+      result = 0;
+      data.__outbufend = buf + sizeof (buf);
+
+      do
+	{
+	  data.__outbuf = buf;
+
+	  status = DL_CALL_FCT (fct, (tomb, &data, &inbuf,
+				      (const unsigned char *) srcend, NULL,
+				      &dummy, 0, 1));
+
+	  /* Count the number of bytes.  */
+	  result += data.__outbuf - buf;
+	}
+      while (status == __GCONV_FULL_OUTPUT);
+
+      if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	  && data.__outbuf[-1] == '\0')
+	/* Don't count the NUL character in.  */
+	--result;
+    }
+  else
+    {
+      /* This code is based on the safe assumption that all internal
+	 multi-byte encodings use the NUL byte only to mark the end
+	 of the string.  */
+      size_t dummy;
+
+      data.__outbuf = (unsigned char *) dst;
+      data.__outbufend = (unsigned char *) dst + len;
+
+      status = DL_CALL_FCT (fct, (tomb, &data, (const unsigned char **) src,
+				  (const unsigned char *) srcend, NULL,
+				  &dummy, 0, 1));
+
+      /* Count the number of bytes.  */
+      result = data.__outbuf - (unsigned char *) dst;
+
+      /* We have to determine whether the last character converted
+	 is the NUL character.  */
+      if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	  && data.__outbuf[-1] == '\0')
+	{
+	  assert (data.__outbuf != (unsigned char *) dst);
+	  assert (__mbsinit (data.__statep));
+	  *src = NULL;
+	  --result;
+	}
+    }
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
+      && status != __GCONV_EMPTY_INPUT)
+    {
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
+weak_alias (__wcsnrtombs, wcsnrtombs)
diff --git a/REORG.TODO/wcsmbs/wcspbrk.c b/REORG.TODO/wcsmbs/wcspbrk.c
new file mode 100644
index 0000000000..e510ab8b57
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcspbrk.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSPBRK
+# define wcspbrk WCSPBRK
+#endif
+
+/* Find the first occurrence in WCS of any wide-character in ACCEPT.  */
+wchar_t *
+wcspbrk (const wchar_t *wcs, const wchar_t *accept)
+{
+  while (*wcs != L'\0')
+    if (wcschr (accept, *wcs) == NULL)
+      ++wcs;
+    else
+      return (wchar_t *) wcs;
+
+  return NULL;
+}
+libc_hidden_def (wcspbrk)
diff --git a/REORG.TODO/wcsmbs/wcsrchr.c b/REORG.TODO/wcsmbs/wcsrchr.c
new file mode 100644
index 0000000000..03407d506e
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsrchr.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifndef WCSRCHR
+# define WCSRCHR wcsrchr
+#endif
+
+/* Find the last occurrence of WC in WCS.  */
+wchar_t *
+WCSRCHR (const wchar_t *wcs, const wchar_t wc)
+{
+  const wchar_t *retval = NULL;
+
+  do
+    if (*wcs == wc)
+      retval = wcs;
+  while (*wcs++ != L'\0');
+
+  return (wchar_t *) retval;
+}
diff --git a/REORG.TODO/wcsmbs/wcsrtombs.c b/REORG.TODO/wcsmbs/wcsrtombs.c
new file mode 100644
index 0000000000..9b6efa7751
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsrtombs.c
@@ -0,0 +1,145 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <gconv.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+#ifndef EILSEQ
+# define EILSEQ EINVAL
+#endif
+
+
+/* This is the private state used if PS is NULL.  */
+static mbstate_t state;
+
+size_t
+__wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps)
+{
+  struct __gconv_step_data data;
+  int status;
+  size_t result;
+  struct __gconv_step *tomb;
+  const struct gconv_fcts *fcts;
+
+  /* Tell where we want the result.  */
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = ps ?: &state;
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Get the structure with the function pointers.  */
+  tomb = fcts->tomb;
+  __gconv_fct fct = tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  /* We have to handle DST == NULL special.  */
+  if (dst == NULL)
+    {
+      mbstate_t temp_state;
+      unsigned char buf[256];		/* Just an arbitrary value.  */
+      const wchar_t *srcend = *src + __wcslen (*src) + 1;
+      const unsigned char *inbuf = (const unsigned char *) *src;
+      size_t dummy;
+
+      temp_state = *data.__statep;
+      data.__statep = &temp_state;
+
+      result = 0;
+      data.__outbufend = buf + sizeof (buf);
+
+      do
+	{
+	  data.__outbuf = buf;
+
+	  status = DL_CALL_FCT (fct, (tomb, &data, &inbuf,
+				      (const unsigned char *) srcend, NULL,
+				      &dummy, 0, 1));
+
+	  /* Count the number of bytes.  */
+	  result += data.__outbuf - buf;
+	}
+      while (status == __GCONV_FULL_OUTPUT);
+
+      if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	{
+	  /* There better should be a NUL byte at the end.  */
+	  assert (data.__outbuf[-1] == '\0');
+	  /* Don't count the NUL character in.  */
+	  --result;
+	}
+    }
+  else
+    {
+      /* This code is based on the safe assumption that all internal
+	 multi-byte encodings use the NUL byte only to mark the end
+	 of the string.  */
+      const wchar_t *srcend = *src + __wcsnlen (*src, len) + 1;
+      size_t dummy;
+
+      data.__outbuf = (unsigned char *) dst;
+      data.__outbufend = (unsigned char *) dst + len;
+
+      status = DL_CALL_FCT (fct, (tomb, &data, (const unsigned char **) src,
+				  (const unsigned char *) srcend, NULL,
+				  &dummy, 0, 1));
+
+      /* Count the number of bytes.  */
+      result = data.__outbuf - (unsigned char *) dst;
+
+      /* We have to determine whether the last character converted
+	 is the NUL character.  */
+      if ((status == __GCONV_OK || status == __GCONV_EMPTY_INPUT)
+	  && data.__outbuf[-1] == '\0')
+	{
+	  assert (data.__outbuf != (unsigned char *) dst);
+	  assert (__mbsinit (data.__statep));
+	  *src = NULL;
+	  --result;
+	}
+    }
+
+  /* There must not be any problems with the conversion but illegal input
+     characters.  */
+  assert (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
+	  || status == __GCONV_ILLEGAL_INPUT
+	  || status == __GCONV_INCOMPLETE_INPUT
+	  || status == __GCONV_FULL_OUTPUT);
+
+  if (status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
+      && status != __GCONV_EMPTY_INPUT)
+    {
+      result = (size_t) -1;
+      __set_errno (EILSEQ);
+    }
+
+  return result;
+}
+weak_alias (__wcsrtombs, wcsrtombs)
diff --git a/REORG.TODO/wcsmbs/wcsspn.c b/REORG.TODO/wcsmbs/wcsspn.c
new file mode 100644
index 0000000000..8d911bb23a
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsspn.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WCSSPN
+# define wcsspn WCSSPN
+#endif
+
+/* Return the length of the maximum initial segment
+   of WCS which contains only wide-characters in ACCEPT.  */
+size_t
+wcsspn (const wchar_t *wcs, const wchar_t *accept)
+{
+  const wchar_t *p;
+  const wchar_t *a;
+  size_t count = 0;
+
+  for (p = wcs; *p != L'\0'; ++p)
+    {
+      for (a = accept; *a != L'\0'; ++a)
+	if (*p == *a)
+	  break;
+      if (*a == L'\0')
+	return count;
+      else
+	++count;
+    }
+
+  return count;
+}
+libc_hidden_def (wcsspn)
diff --git a/REORG.TODO/wcsmbs/wcsstr.c b/REORG.TODO/wcsmbs/wcsstr.c
new file mode 100644
index 0000000000..0a9fc4cc67
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsstr.c
@@ -0,0 +1,97 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/*
+ * The original strstr() file contains the following comment:
+ *
+ * My personal strstr() implementation that beats most other algorithms.
+ * Until someone tells me otherwise, I assume that this is the
+ * fastest implementation of strstr() in C.
+ * I deliberately chose not to comment it.  You should have at least
+ * as much fun trying to understand it, as I had to write it :-).
+ *
+ * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
+
+#include <wchar.h>
+
+wchar_t *
+wcsstr (const wchar_t *haystack, const wchar_t *needle)
+{
+  wchar_t b, c;
+
+  if ((b = *needle) != L'\0')
+    {
+      haystack--;				/* possible ANSI violation */
+      do
+	if ((c = *++haystack) == L'\0')
+	  goto ret0;
+      while (c != b);
+
+      if (!(c = *++needle))
+	goto foundneedle;
+      ++needle;
+      goto jin;
+
+      for (;;)
+	{
+	  wchar_t a;
+	  const wchar_t *rhaystack, *rneedle;
+
+	  do
+	    {
+	      if (!(a = *++haystack))
+		goto ret0;
+	      if (a == b)
+		break;
+	      if ((a = *++haystack) == L'\0')
+		goto ret0;
+shloop:	      ;
+	    }
+	  while (a != b);
+
+jin:	  if (!(a = *++haystack))
+	    goto ret0;
+
+	  if (a != c)
+	    goto shloop;
+
+	  if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
+	    do
+	      {
+		if (a == L'\0')
+		  goto foundneedle;
+		if (*++rhaystack != (a = *++needle))
+		  break;
+		if (a == L'\0')
+		  goto foundneedle;
+	      }
+	    while (*++rhaystack == (a = *++needle));
+
+	  needle = rneedle;		  /* took the register-poor approach */
+
+	  if (a == L'\0')
+	    break;
+	}
+    }
+foundneedle:
+  return (wchar_t*) haystack;
+ret0:
+  return NULL;
+}
+/* This alias is for backward compatibility with drafts of the ISO C
+   standard.  Unfortunately the Unix(TM) standard requires this name.  */
+weak_alias (wcsstr, wcswcs)
diff --git a/REORG.TODO/wcsmbs/wcstod.c b/REORG.TODO/wcsmbs/wcstod.c
new file mode 100644
index 0000000000..b7db11b935
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstod.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+
+#define	USE_WIDE_CHAR	1
+
+extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int,
+				     __locale_t);
+
+#include <stdlib/strtod.c>
diff --git a/REORG.TODO/wcsmbs/wcstod_l.c b/REORG.TODO/wcsmbs/wcstod_l.c
new file mode 100644
index 0000000000..5f7498c4f8
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstod_l.c
@@ -0,0 +1,29 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+
+extern double ____wcstod_l_internal (const wchar_t *, wchar_t **, int,
+				     __locale_t);
+
+#define	USE_WIDE_CHAR	1
+
+#include <stdlib/strtod_l.c>
diff --git a/REORG.TODO/wcsmbs/wcstod_nan.c b/REORG.TODO/wcsmbs/wcstod_nan.c
new file mode 100644
index 0000000000..26c15f76de
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstod_nan.c
@@ -0,0 +1,23 @@
+/* Convert string for NaN payload to corresponding NaN.  Wide strings, double.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "../stdlib/strtod_nan_wide.h"
+#include "../stdlib/strtod_nan_double.h"
+
+#define STRTOD_NAN __wcstod_nan
+#include "../stdlib/strtod_nan_main.c"
diff --git a/REORG.TODO/wcsmbs/wcstof.c b/REORG.TODO/wcsmbs/wcstof.c
new file mode 100644
index 0000000000..29cdec3a98
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstof.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+#define	USE_WIDE_CHAR	1
+
+extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
+				    __locale_t);
+
+#include <stdlib/strtof.c>
diff --git a/REORG.TODO/wcsmbs/wcstof_l.c b/REORG.TODO/wcsmbs/wcstof_l.c
new file mode 100644
index 0000000000..23d402d7ea
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstof_l.c
@@ -0,0 +1,29 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+
+#define	USE_WIDE_CHAR	1
+
+extern float ____wcstof_l_internal (const wchar_t *, wchar_t **, int,
+				    __locale_t);
+
+#include <stdlib/strtof_l.c>
diff --git a/REORG.TODO/wcsmbs/wcstof_nan.c b/REORG.TODO/wcsmbs/wcstof_nan.c
new file mode 100644
index 0000000000..98b41d6bf0
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstof_nan.c
@@ -0,0 +1,23 @@
+/* Convert string for NaN payload to corresponding NaN.  Wide strings, float.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "../stdlib/strtod_nan_wide.h"
+#include "../stdlib/strtod_nan_float.h"
+
+#define STRTOD_NAN __wcstof_nan
+#include "../stdlib/strtod_nan_main.c"
diff --git a/REORG.TODO/wcsmbs/wcstok.c b/REORG.TODO/wcsmbs/wcstok.c
new file mode 100644
index 0000000000..39bacf1497
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstok.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1995-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <errno.h>
+
+
+/* Parse WCS into tokens separated by characters in DELIM.  If WCS is
+   NULL, the last string wcstok() was called with is used.  */
+wchar_t *
+wcstok (wchar_t *wcs, const wchar_t *delim, wchar_t **save_ptr)
+{
+  wchar_t *result;
+
+  if (wcs == NULL)
+    {
+      if (*save_ptr == NULL)
+	{
+	  __set_errno (EINVAL);
+	  return NULL;
+	}
+      else
+	wcs = *save_ptr;
+    }
+
+  /* Scan leading delimiters.  */
+  wcs += wcsspn (wcs, delim);
+  if (*wcs == L'\0')
+    {
+      *save_ptr = NULL;
+      return NULL;
+    }
+
+  /* Find the end of the token.	 */
+  result = wcs;
+  wcs = wcspbrk (result, delim);
+  if (wcs == NULL)
+    /* This token finishes the string.	*/
+    *save_ptr = NULL;
+  else
+    {
+      /* Terminate the token and make *SAVE_PTR point past it.  */
+      *wcs = L'\0';
+      *save_ptr = wcs + 1;
+    }
+  return result;
+}
diff --git a/REORG.TODO/wcsmbs/wcstol.c b/REORG.TODO/wcsmbs/wcstol.c
new file mode 100644
index 0000000000..ffa8924207
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstol.c
@@ -0,0 +1,22 @@
+/* Function to parse a `long int' from text.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define	USE_WIDE_CHAR	1
+
+#include <stdlib/strtol.c>
diff --git a/REORG.TODO/wcsmbs/wcstol_l.c b/REORG.TODO/wcsmbs/wcstol_l.c
new file mode 100644
index 0000000000..744f8f85b7
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstol_l.c
@@ -0,0 +1,29 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define __need_wchar_t
+#include <stddef.h>
+#include <locale.h>
+
+#define	USE_WIDE_CHAR	1
+
+extern long int ____wcstol_l_internal (const wchar_t *, wchar_t **, int, int,
+				       __locale_t);
+
+#include <stdlib/strtol_l.c>
diff --git a/REORG.TODO/wcsmbs/wcstold.c b/REORG.TODO/wcsmbs/wcstold.c
new file mode 100644
index 0000000000..e5c1cc3071
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstold.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+#define USE_WIDE_CHAR	1
+
+extern long double ____wcstold_l_internal (const wchar_t *, wchar_t **, int,
+					   __locale_t);
+
+#include <stdlib/strtold.c>
diff --git a/REORG.TODO/wcsmbs/wcstold_l.c b/REORG.TODO/wcsmbs/wcstold_l.c
new file mode 100644
index 0000000000..3dd33a729a
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstold_l.c
@@ -0,0 +1,28 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <xlocale.h>
+
+#define USE_WIDE_CHAR	1
+
+extern long double ____wcstold_l_internal (const wchar_t *, wchar_t **, int,
+					   __locale_t);
+
+#include <strtold_l.c>
diff --git a/REORG.TODO/wcsmbs/wcstold_nan.c b/REORG.TODO/wcsmbs/wcstold_nan.c
new file mode 100644
index 0000000000..726620b5f4
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstold_nan.c
@@ -0,0 +1,30 @@
+/* Convert string for NaN payload to corresponding NaN.  Wide strings,
+   long double.
+   Copyright (C) 2015-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+
+/* This function is unused if long double and double have the same
+   representation.  */
+#ifndef __NO_LONG_DOUBLE_MATH
+# include "../stdlib/strtod_nan_wide.h"
+# include <strtod_nan_ldouble.h>
+
+# define STRTOD_NAN __wcstold_nan
+# include "../stdlib/strtod_nan_main.c"
+#endif
diff --git a/REORG.TODO/wcsmbs/wcstoll.c b/REORG.TODO/wcsmbs/wcstoll.c
new file mode 100644
index 0000000000..493519b205
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstoll.c
@@ -0,0 +1,24 @@
+/* Function to parse a `long long int' from text.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define	QUAD	1
+
+#include "wcstol.c"
+
+weak_alias (wcstoll, wcstoq)
diff --git a/REORG.TODO/wcsmbs/wcstoll_l.c b/REORG.TODO/wcsmbs/wcstoll_l.c
new file mode 100644
index 0000000000..225153f547
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstoll_l.c
@@ -0,0 +1,29 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define __need_wchar_t
+#include <stddef.h>
+#include <locale.h>
+
+#define QUAD	1
+
+extern long long int ____wcstoll_l_internal (const wchar_t *, wchar_t **,
+					     int, int, __locale_t);
+
+#include <wcstol_l.c>
diff --git a/REORG.TODO/wcsmbs/wcstoul.c b/REORG.TODO/wcsmbs/wcstoul.c
new file mode 100644
index 0000000000..708ea8f3c9
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstoul.c
@@ -0,0 +1,22 @@
+/* Function to parse an `unsigned long int' from text.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define	UNSIGNED	1
+
+#include "wcstol.c"
diff --git a/REORG.TODO/wcsmbs/wcstoul_l.c b/REORG.TODO/wcsmbs/wcstoul_l.c
new file mode 100644
index 0000000000..0847284bc2
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstoul_l.c
@@ -0,0 +1,29 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define __need_wchar_t
+#include <stddef.h>
+#include <locale.h>
+
+#define UNSIGNED	1
+
+extern unsigned long int ____wcstoul_l_internal (const wchar_t *, wchar_t **,
+						 int, int, __locale_t);
+
+#include "wcstol_l.c"
diff --git a/REORG.TODO/wcsmbs/wcstoull.c b/REORG.TODO/wcsmbs/wcstoull.c
new file mode 100644
index 0000000000..5d96389e7d
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstoull.c
@@ -0,0 +1,24 @@
+/* Function to parse an `unsigned long long int' from text.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define	QUAD	1
+
+#include "wcstoul.c"
+
+weak_alias (wcstoull, wcstouq)
diff --git a/REORG.TODO/wcsmbs/wcstoull_l.c b/REORG.TODO/wcsmbs/wcstoull_l.c
new file mode 100644
index 0000000000..532d01a250
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcstoull_l.c
@@ -0,0 +1,30 @@
+/* Convert string representing a number to integer value, using given locale.
+   Copyright (C) 1997-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define __need_wchar_t
+#include <stddef.h>
+#include <locale.h>
+
+#define UNSIGNED	1
+
+extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
+						       wchar_t **, int, int,
+						       __locale_t);
+
+#include <wcstoll_l.c>
diff --git a/REORG.TODO/wcsmbs/wcswidth.c b/REORG.TODO/wcsmbs/wcswidth.c
new file mode 100644
index 0000000000..6e4a1d9f95
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcswidth.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "wcwidth.h"
+
+/* Determine number of column positions required for first N wide
+   characters (or fewer if S ends before this) in S.  */
+int
+wcswidth (const wchar_t *s, size_t n)
+{
+  int result = 0;
+
+  while (n-- > 0 && *s != L'\0')
+    {
+      int now = internal_wcwidth (*s);
+      if (now == -1)
+	return -1;
+      result += now;
+      ++s;
+    }
+
+  return result;
+}
diff --git a/REORG.TODO/wcsmbs/wcsxfrm.c b/REORG.TODO/wcsmbs/wcsxfrm.c
new file mode 100644
index 0000000000..fa14ddf706
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsxfrm.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include "../locale/coll-lookup.h"
+
+#define STRING_TYPE wchar_t
+#define STRXFRM wcsxfrm
+#define STRXFRM_L __wcsxfrm_l
+
+#include "../string/strxfrm.c"
diff --git a/REORG.TODO/wcsmbs/wcsxfrm_l.c b/REORG.TODO/wcsmbs/wcsxfrm_l.c
new file mode 100644
index 0000000000..5899cc64cc
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcsxfrm_l.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include "../locale/coll-lookup.h"
+
+#define STRING_TYPE wchar_t
+#define USTRING_TYPE wint_t
+#define STRXFRM __wcsxfrm_l
+#define STRLEN __wcslen
+#define STPNCPY __wcpncpy
+#define WEIGHT_H "../locale/weightwc.h"
+#define SUFFIX  WC
+#define L(arg) L##arg
+#define WIDE_CHAR_VERSION 1
+
+#include "../string/strxfrm_l.c"
+
+weak_alias (__wcsxfrm_l, wcsxfrm_l)
diff --git a/REORG.TODO/wcsmbs/wctob.c b/REORG.TODO/wcsmbs/wctob.c
new file mode 100644
index 0000000000..6a4fb86ac4
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wctob.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <dlfcn.h>
+#include <gconv.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+#include <wcsmbsload.h>
+
+#include <sysdep.h>
+
+
+int
+wctob (wint_t c)
+{
+  unsigned char buf[MB_LEN_MAX];
+  struct __gconv_step_data data;
+  wchar_t inbuf[1];
+  wchar_t *inptr = inbuf;
+  size_t dummy;
+  int status;
+  const struct gconv_fcts *fcts;
+
+  if (c == WEOF)
+    return EOF;
+
+  /* We know that only ASCII compatible encodings are used for the
+     locale and that the wide character encoding is ISO 10646.  */
+  if (c >= L'\0' && c <= L'\x7f')
+    return (int) c;
+
+  /* Tell where we want the result.  */
+  data.__outbuf = buf;
+  data.__outbufend = buf + MB_LEN_MAX;
+  data.__invocation_counter = 0;
+  data.__internal_use = 1;
+  data.__flags = __GCONV_IS_LAST;
+  data.__statep = &data.__state;
+
+  /* Make sure we start in the initial state.  */
+  memset (&data.__state, '\0', sizeof (mbstate_t));
+
+  /* Get the conversion functions.  */
+  fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
+
+  /* Create the input string.  */
+  inbuf[0] = c;
+
+  const unsigned char *argptr = (const unsigned char *) inptr;
+  __gconv_fct fct = fcts->tomb->__fct;
+#ifdef PTR_DEMANGLE
+  if (fcts->tomb->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+  status = DL_CALL_FCT (fct,
+			(fcts->tomb, &data, &argptr,
+			 argptr + sizeof (inbuf[0]), NULL, &dummy, 0, 1));
+
+  /* The conversion failed or the output is too long.  */
+  if ((status != __GCONV_OK && status != __GCONV_FULL_OUTPUT
+       && status != __GCONV_EMPTY_INPUT)
+      || data.__outbuf != (unsigned char *) (buf + 1))
+    return EOF;
+
+  return buf[0];
+}
diff --git a/REORG.TODO/wcsmbs/wcwidth.c b/REORG.TODO/wcsmbs/wcwidth.c
new file mode 100644
index 0000000000..d695186437
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcwidth.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "wcwidth.h"
+
+/* Determine number of column positions required for CH.  */
+int
+wcwidth (wchar_t ch)
+{
+  return internal_wcwidth (ch);
+}
diff --git a/REORG.TODO/wcsmbs/wcwidth.h b/REORG.TODO/wcsmbs/wcwidth.h
new file mode 100644
index 0000000000..1d2c7b084c
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wcwidth.h
@@ -0,0 +1,39 @@
+/* Internal header containing implementation of wcwidth() function.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <wctype.h>
+#include "../wctype/wchar-lookup.h"
+#include "../locale/localeinfo.h"
+
+/* Table containing width information.  */
+extern const char *__ctype32_width attribute_hidden;
+
+static __inline int
+internal_wcwidth (wchar_t wc)
+{
+  unsigned char res;
+
+  /* The tables have been prepared in such a way that
+     1. wc == L'\0' yields res = 0,
+     2. !iswprint (wc) implies res = '\xff'.  */
+  res = wcwidth_table_lookup (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_WIDTH), wc);
+
+  return res == (unsigned char) '\xff' ? -1 : (int) res;
+}
diff --git a/REORG.TODO/wcsmbs/wmemchr.c b/REORG.TODO/wcsmbs/wmemchr.c
new file mode 100644
index 0000000000..2a80f91d52
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wmemchr.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WMEMCHR
+# define __wmemchr WMEMCHR
+#endif
+
+wchar_t *
+__wmemchr (const wchar_t *s, wchar_t c, size_t n)
+{
+  /* For performance reasons unfold the loop four times.  */
+  while (n >= 4)
+    {
+      if (s[0] == c)
+	return (wchar_t *) s;
+      if (s[1] == c)
+	return (wchar_t *) &s[1];
+      if (s[2] == c)
+	return (wchar_t *) &s[2];
+      if (s[3] == c)
+	return (wchar_t *) &s[3];
+      s += 4;
+      n -= 4;
+    }
+
+  if (n > 0)
+    {
+      if (*s == c)
+	return (wchar_t *) s;
+      ++s;
+      --n;
+    }
+  if (n > 0)
+    {
+      if (*s == c)
+	return (wchar_t *) s;
+      ++s;
+      --n;
+    }
+  if (n > 0)
+    if (*s == c)
+      return (wchar_t *) s;
+
+  return NULL;
+}
+libc_hidden_def (__wmemchr)
+weak_alias (__wmemchr, wmemchr)
+libc_hidden_weak (wmemchr)
diff --git a/REORG.TODO/wcsmbs/wmemcmp.c b/REORG.TODO/wcsmbs/wmemcmp.c
new file mode 100644
index 0000000000..ee0724cf2b
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wmemcmp.c
@@ -0,0 +1,83 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifndef WMEMCMP
+# define WMEMCMP wmemcmp
+#endif
+
+int
+WMEMCMP (const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  wchar_t c1;
+  wchar_t c2;
+
+  while (n >= 4)
+    {
+      c1 = s1[0];
+      c2 = s2[0];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+      c1 = s1[1];
+      c2 = s2[1];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+      c1 = s1[2];
+      c2 = s2[2];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+      c1 = s1[3];
+      c2 = s2[3];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+      s1 += 4;
+      s2 += 4;
+      n -= 4;
+    }
+
+  if (n > 0)
+    {
+      c1 = s1[0];
+      c2 = s2[0];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+      ++s1;
+      ++s2;
+      --n;
+    }
+  if (n > 0)
+    {
+      c1 = s1[0];
+      c2 = s2[0];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+      ++s1;
+      ++s2;
+      --n;
+    }
+  if (n > 0)
+    {
+      c1 = s1[0];
+      c2 = s2[0];
+      if (c1 - c2 != 0)
+	return c1 > c2 ? 1 : -1;
+    }
+
+  return 0;
+}
diff --git a/REORG.TODO/wcsmbs/wmemcpy.c b/REORG.TODO/wcsmbs/wmemcpy.c
new file mode 100644
index 0000000000..f44d0fdbef
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wmemcpy.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <string.h>
+
+
+wchar_t *
+__wmemcpy (wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  return (wchar_t *) memcpy ((char *) s1, (char *) s2, n * sizeof (wchar_t));
+}
+weak_alias (__wmemcpy, wmemcpy)
diff --git a/REORG.TODO/wcsmbs/wmemmove.c b/REORG.TODO/wcsmbs/wmemmove.c
new file mode 100644
index 0000000000..5d711ec14b
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wmemmove.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <string.h>
+
+
+wchar_t *
+__wmemmove (wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  return (wchar_t *) memmove ((char *) s1, (char *) s2, n * sizeof (wchar_t));
+}
+weak_alias (__wmemmove, wmemmove)
diff --git a/REORG.TODO/wcsmbs/wmempcpy.c b/REORG.TODO/wcsmbs/wmempcpy.c
new file mode 100644
index 0000000000..c3b65de557
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wmempcpy.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 1999-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+#include <string.h>
+
+
+wchar_t *
+__wmempcpy (wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  return (wchar_t *) __mempcpy ((char *) s1, (char *) s2,
+				n * sizeof (wchar_t));
+}
+weak_alias (__wmempcpy, wmempcpy)
diff --git a/REORG.TODO/wcsmbs/wmemset.c b/REORG.TODO/wcsmbs/wmemset.c
new file mode 100644
index 0000000000..d79b95b47e
--- /dev/null
+++ b/REORG.TODO/wcsmbs/wmemset.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#ifdef WMEMSET
+# define __wmemset WMEMSET
+#endif
+
+wchar_t *
+__wmemset (wchar_t *s, wchar_t c, size_t n)
+{
+  wchar_t *wp = s;
+
+  while (n >= 4)
+    {
+      wp[0] = c;
+      wp[1] = c;
+      wp[2] = c;
+      wp[3] = c;
+      wp += 4;
+      n -= 4;
+    }
+
+  if (n > 0)
+    {
+      wp[0] = c;
+
+      if (n > 1)
+	{
+	  wp[1] = c;
+
+	  if (n > 2)
+	    wp[2] = c;
+	}
+    }
+
+  return s;
+}
+libc_hidden_def (__wmemset)
+weak_alias (__wmemset, wmemset)
+libc_hidden_weak (wmemset)