Wide-char functions have been standardized for a long time now,
between C99 and POSIX.1(2001/2008).

The only possible exception is wcwidth, so keep the backup function
defined in wcwidth.c.  Otherwise, assume wchar.h and wctype.h exist,
and all their standardized functions exist.
---

While doing this, I noticed INSTALL also mentions configure option
enable-locales-fix, which seems to be another ripe target for removal.
I wonder what you all think about pulling that out.

 .builds/alpine.yml    |   4 -
 .builds/archlinux.yml |   4 -
 .builds/build         |   6 -
 .builds/debian.yml    |   4 -
 .builds/freebsd.yml   |   4 -
 .builds/openbsd.yml   |   4 -
 INSTALL               |  17 --
 Makefile.am           |   2 +-
 configure.ac          |  81 +-------
 main.c                |   6 +-
 mbyte.c               | 425 +-----------------------------------------
 mbyte.h               |  44 +----
 mutt.h                |  16 +-
 protos.h              |   3 -
 regex.c               |  64 +------
 utf8.c                |  81 --------
 wcwidth.c             |   4 +-
 17 files changed, 23 insertions(+), 746 deletions(-)
 delete mode 100644 utf8.c

diff --git a/.builds/alpine.yml b/.builds/alpine.yml
index c6b31402..ec43716b 100644
--- a/.builds/alpine.yml
+++ b/.builds/alpine.yml
@@ -28,10 +28,6 @@ tasks:
     cd mutt
     ./.builds/build default
 
-- without-wc-funcs: |
-    cd mutt
-    ./.builds/build without_wc_funcs
-
 - original: |
     cd mutt
     ./.builds/build original
diff --git a/.builds/archlinux.yml b/.builds/archlinux.yml
index 6721e6a2..cad5c182 100644
--- a/.builds/archlinux.yml
+++ b/.builds/archlinux.yml
@@ -28,10 +28,6 @@ tasks:
     cd mutt
     ./.builds/build default
 
-- without-wc-funcs: |
-    cd mutt
-    ./.builds/build without_wc_funcs
-
 - original: |
     cd mutt
     ./.builds/build original
diff --git a/.builds/build b/.builds/build
index 5907a3ee..fb9510aa 100755
--- a/.builds/build
+++ b/.builds/build
@@ -95,12 +95,6 @@ tcc()
        CC=tcc ./configure
 }
 
-without_wc_funcs()
-{
-       ./configure \
-               --without-wc-funcs
-}
-
 # If no arguments were passed, get all the above function names (except _die)
 # and drop the parentheses.
 # shellcheck disable=SC2046
diff --git a/.builds/debian.yml b/.builds/debian.yml
index f3a9dad9..87679bd1 100644
--- a/.builds/debian.yml
+++ b/.builds/debian.yml
@@ -29,10 +29,6 @@ tasks:
     cd mutt
     ./.builds/build default
 
-- without-wc-funcs: |
-    cd mutt
-    ./.builds/build without_wc_funcs
-
 - original: |
     cd mutt
     ./.builds/build original
diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml
index 15a44406..eb7cb76c 100644
--- a/.builds/freebsd.yml
+++ b/.builds/freebsd.yml
@@ -30,10 +30,6 @@ tasks:
     cd mutt
     ./.builds/build default
 
-- without-wc-funcs: |
-    cd mutt
-    ./.builds/build without_wc_funcs
-
 - original_freebsd: |
     cd mutt
     ./.builds/build original_freebsd
diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml
index defb3ec9..aaa3740d 100644
--- a/.builds/openbsd.yml
+++ b/.builds/openbsd.yml
@@ -32,10 +32,6 @@ tasks:
     cd mutt
     ./.builds/build default
 
-- without-wc-funcs: |
-    cd mutt
-    ./.builds/build without_wc_funcs
-
 - original_freebsd: |
     cd mutt
     ./.builds/build original_freebsd
diff --git a/INSTALL b/INSTALL
index 608aa2ae..445adb3f 100644
--- a/INSTALL
+++ b/INSTALL
@@ -126,10 +126,6 @@ options are:
        you leave it unset, Mutt will attempt to use isprint() if either
        of the environment variables LANG, LC_ALL or LC_CTYPE is set,
        and will revert to the ISO-8859-* range if they aren't.
-       If you need --enable-locales-fix then you will probably need
-       --without-wc-funcs too. However, on a correctly configured
-       modern system you shouldn't need either (try setting LANG,
-       LC_ALL or LC_CTYPE instead).
 
 --enable-exact-address
        By default, Mutt will rewrite all addresses in the form
@@ -205,19 +201,6 @@ options are:
        support them.  Almost all systems nowadays should have no need
        for this option.
 
---without-wc-funcs
-       by default Mutt uses the functions mbrtowc(), wctomb() and
-       wcwidth() provided by the system, when they are available.
-       With this option Mutt will use its own version of those
-       functions, which should work with 8-bit display charsets, UTF-8,
-       euc-jp or shift_jis, even if the system doesn't normally support
-       those multibyte charsets.
-
-       If you find Mutt is displaying non-ascii characters as octal
-       escape sequences (e.g. \243), even though you have set LANG and
-       LC_CTYPE correctly, then you might find you can solve the problem
-       with either or both of --enable-locales-fix and --without-wc-funcs.
-
 --with-exec-shell=SHELL
        on some versions of unix, /bin/sh has a bug that makes using emacs
        with mutt very difficult.  If you have the problem that whenever
diff --git a/Makefile.am b/Makefile.am
index c4b62e49..3a483498 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,7 +71,7 @@ EXTRA_mutt_SOURCES = account.c bcache.c compress.c 
crypt-gpgme.c crypt-mod-pgp-c
        mutt_ssl_gnutls.c \
        mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \
        pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \
-       sidebar.c smime.c smtp.c utf8.c wcwidth.c mutt_zstrm.c \
+       sidebar.c smime.c smtp.c wcwidth.c mutt_zstrm.c \
        bcache.h browser.h hcache.h mbyte.h monitor.h mutt_idna.h remailer.h 
url.h \
        mutt_lisp.h mutt_random.h
 
diff --git a/configure.ac b/configure.ac
index 1b864dcd..4817674f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1505,85 +1505,12 @@ fi
 
 dnl -- locales --
 
-AC_CHECK_HEADERS(wchar.h)
+AC_CHECK_FUNC(iswprint, [],
+    AC_MSG_ERROR([A libc with widechar support is required]))
 
-AC_CACHE_CHECK([for wchar_t], mutt_cv_wchar_t,
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stddef.h>
-#include <stdlib.h>
-#ifdef HAVE_WCHAR_H
-#include <wchar.h>
-#endif
-                ]], [[ wchar_t wc; return 0; 
]])],[mutt_cv_wchar_t=yes],[mutt_cv_wchar_t=no]))
+dnl We still support a system without wcwidth
+AC_CHECK_FUNCS(wcwidth,,[MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS wcwidth.o"])
 
-if test "$mutt_cv_wchar_t" = no; then
-        AC_DEFINE(wchar_t,int,[ Define to 'int' if system headers don't 
define. ])
-fi
-
-AC_CACHE_CHECK([for wint_t], mutt_cv_wint_t,
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stddef.h>
-#include <stdlib.h>
-#ifdef HAVE_WCHAR_H
-#include <wchar.h>
-#endif
-                ]], [[ wint_t wc; return 0; 
]])],[mutt_cv_wint_t=yes],[mutt_cv_wint_t=no]))
-
-if test "$mutt_cv_wint_t" = no; then
-        AC_DEFINE(wint_t,int,[ Define to 'int' if system headers don't define. 
])
-fi
-
-AC_CHECK_HEADERS(wctype.h)
-AC_CHECK_FUNCS(iswalnum iswalpha iswblank iswcntrl iswdigit)
-AC_CHECK_FUNCS(iswgraph iswlower iswprint iswpunct iswspace iswupper)
-AC_CHECK_FUNCS(iswxdigit towupper towlower)
-
-AC_CACHE_CHECK([for mbstate_t], mutt_cv_mbstate_t,
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <stddef.h>
-#include <stdlib.h>
-#ifdef HAVE_WCHAR_H
-#include <wchar.h>
-#endif
-                ]], [[ mbstate_t s; return 0; 
]])],[mutt_cv_mbstate_t=yes],[mutt_cv_mbstate_t=no]))
-
-if test "$mutt_cv_mbstate_t" = no; then
-        AC_DEFINE(mbstate_t,int,[ Define to 'int' if system headers don't 
define. ])
-fi
-
-wc_funcs=maybe
-AC_ARG_WITH(wc-funcs, AS_HELP_STRING([--without-wc-funcs],[Do not use the 
system's wchar_t functions]),
-        wc_funcs=$withval)
-
-if test "$wc_funcs" = no; then
-        AC_MSG_WARN([--without-wc-funcs is deprecated and will be removed in 
mutt 2.5.0])
-fi
-
-if test "$wc_funcs" != yes && test "$wc_funcs" != no; then
-        AC_CACHE_CHECK([for wchar_t functions], mutt_cv_wc_funcs,
-                mutt_cv_wc_funcs=no
-                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#define _XOPEN_SOURCE 600
-#include <stddef.h>
-#include <stdlib.h>
-#ifdef HAVE_WCHAR_H
-#include <wchar.h>
-#endif
-#ifdef HAVE_WCTYPE_H
-#include <wctype.h>
-#endif]], [[mbrtowc(0, 0, 0, 0); wctomb(0, 0); wcwidth(0); iswblank(0);
-        iswprint(0); iswspace(0); towlower(0); towupper(0); 
iswalnum(0)]])],[mutt_cv_wc_funcs=yes],[]))
-        wc_funcs=$mutt_cv_wc_funcs
-        if test "$wc_funcs" = no; then
-           AC_MSG_WARN([This system is missing needed wchar_t functions. 
Starting with mutt 2.5.0 this system may no longer be able to compile mutt.])
-        fi
-fi
-
-if test $wc_funcs = yes; then
-        AC_DEFINE(HAVE_WC_FUNCS,1,[ Define if you are using the system's 
wchar_t functions. ])
-else
-        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS utf8.o wcwidth.o"
-fi
 
 AC_CACHE_CHECK([for nl_langinfo and CODESET], mutt_cv_langinfo_codeset,
   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[char* cs = 
nl_langinfo(CODESET);]])],[mutt_cv_langinfo_codeset=yes],[mutt_cv_langinfo_codeset=no])])
diff --git a/main.c b/main.c
index 15507467..9c47f122 100644
--- a/main.c
+++ b/main.c
@@ -477,10 +477,10 @@ static void show_version(void)
     "-LOCALES_HACK  "
 #endif
 
-#ifdef HAVE_WC_FUNCS
-    "+HAVE_WC_FUNCS  "
+#ifdef HAVE_WCWIDTH
+    "+HAVE_WCWIDTH  "
 #else
-    "-HAVE_WC_FUNCS  "
+    "-HAVE_WCWIDTH  "
 #endif
 
 #ifdef HAVE_LANGINFO_CODESET
diff --git a/mbyte.c b/mbyte.c
index b3f6c65a..8e8b8719 100644
--- a/mbyte.c
+++ b/mbyte.c
@@ -37,10 +37,8 @@
 #endif
 
 int Charset_is_utf8 = 0;
-#ifndef HAVE_WC_FUNCS
+#ifndef HAVE_WCWIDTH
 static int charset_is_ja = 0;
-static iconv_t charset_to_utf8 = (iconv_t)(-1);
-static iconv_t charset_from_utf8 = (iconv_t)(-1);
 #endif
 
 void mutt_set_charset(char *charset)
@@ -50,36 +48,17 @@ void mutt_set_charset(char *charset)
   mutt_canonical_charset(buffer, sizeof(buffer), charset);
 
   Charset_is_utf8 = 0;
-#ifndef HAVE_WC_FUNCS
+#ifndef HAVE_WCWIDTH
   charset_is_ja = 0;
-  if (charset_to_utf8 != (iconv_t)(-1))
-  {
-    iconv_close(charset_to_utf8);
-    charset_to_utf8 = (iconv_t)(-1);
-  }
-  if (charset_from_utf8 != (iconv_t)(-1))
-  {
-    iconv_close(charset_from_utf8);
-    charset_from_utf8 = (iconv_t)(-1);
-  }
 #endif
 
   if (mutt_is_utf8(buffer))
     Charset_is_utf8 = 1;
-#ifndef HAVE_WC_FUNCS
+#ifndef HAVE_WCWIDTH
   else if (!ascii_strcasecmp(buffer, "euc-jp") || !ascii_strcasecmp(buffer, 
"shift_jis")
            || !ascii_strcasecmp(buffer, "cp932") || !ascii_strcasecmp(buffer, 
"eucJP-ms"))
   {
     charset_is_ja = 1;
-
-    /* Note flags=0 to skip charset-hooks: User masters the $charset
-     * name, and we are sure of our "utf-8" constant. So there is no
-     * possibility of wrong name that we would want to try to correct
-     * with a charset-hook. Or rather: If $charset was wrong, we would
-     * want to try to correct... $charset directly.
-     */
-    charset_to_utf8 = mutt_iconv_open("utf-8", charset, 0);
-    charset_from_utf8 = mutt_iconv_open(charset, "utf-8", 0);
   }
 #endif
 
@@ -88,317 +67,13 @@ void mutt_set_charset(char *charset)
 #endif
 }
 
-#ifndef HAVE_WC_FUNCS
-
-/*
- * For systems that don't have them, we provide here our own
- * implementations of wcrtomb(), mbrtowc(), iswprint() and wcwidth().
- * Instead of using the locale, as these functions normally would,
- * we use Mutt's Charset variable. We support 3 types of charset:
- * (1) For 8-bit charsets, wchar_t uses the same encoding as char.
- * (2) For UTF-8, wchar_t uses UCS.
- * (3) For stateless Japanese encodings, we use UCS and convert
- *     via UTF-8 using iconv.
- * Unfortunately, we can't handle non-stateless encodings.
- */
-
-static size_t wcrtomb_iconv(char *s, wchar_t wc, iconv_t cd)
-{
-  char buf[MB_LEN_MAX+1];
-  ICONV_CONST char *ib;
-  char *ob;
-  size_t ibl, obl;
-
-  if (s)
-  {
-    ibl = mutt_wctoutf8(buf, wc, sizeof(buf));
-    if (ibl == (size_t)(-1))
-      return (size_t)(-1);
-    ib = buf;
-    ob = s;
-    obl = MB_LEN_MAX;
-    iconv(cd, &ib, &ibl, &ob, &obl);
-  }
-  else
-  {
-    ib = "";
-    ibl = 1;
-    ob = buf;
-    obl = sizeof(buf);
-    iconv(cd, &ib, &ibl, &ob, &obl);
-  }
-  return ob - s;
-}
-
-size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
-{
-  /* We only handle stateless encodings, so we can ignore ps. */
-
-  if (Charset_is_utf8)
-    return mutt_wctoutf8(s, wc, MB_LEN_MAX);
-  else if (charset_from_utf8 != (iconv_t)(-1))
-    return wcrtomb_iconv(s, wc, charset_from_utf8);
-  else
-  {
-    if (!s)
-      return 1;
-    if (wc < 0x100)
-    {
-      *s = wc;
-      return 1;
-    }
-    errno = EILSEQ;
-    return (size_t)(-1);
-  }
-}
-
-size_t mbrtowc_iconv(wchar_t *pwc, const char *s, size_t n,
-                     mbstate_t *ps, iconv_t cd)
-{
-  static mbstate_t mbstate;
-  ICONV_CONST char *ib, *ibmax;
-  char *ob, *t;
-  size_t ibl, obl, k, r;
-  char bufi[8], bufo[6];
-
-  if (!n)
-    return (size_t)(-2);
-
-  t = memchr(ps, 0, sizeof(*ps));
-  k = t ? (t - (char *)ps) : sizeof(*ps);
-  if (k > sizeof(bufi))
-    k = 0;
-  if (k)
-  {
-    /* use the buffer for input */
-    memcpy(bufi, ps, k);
-    ib = bufi;
-    ibmax = bufi + (k + n < sizeof(bufi) ? k + n : sizeof(bufi));
-    memcpy(bufi + k, s, ibmax - bufi - k);
-  }
-  else
-  {
-    /* use the real input */
-    ib = (ICONV_CONST char*) s;
-    ibmax = (ICONV_CONST char*) s + n;
-  }
-
-  ob = bufo;
-  obl = sizeof(bufo);
-  ibl = 1;
-
-  for (;;)
-  {
-    r = iconv(cd, &ib, &ibl, &ob, &obl);
-    if (ob > bufo && (!k || ib > bufi + k))
-    {
-      /* we have a character */
-      memset(ps, 0, sizeof(*ps));
-      utf8rtowc(pwc, bufo, ob - bufo, &mbstate);
-      return (pwc && *pwc) ? (ib - (k ? bufi + k : s)) : 0;
-    }
-    else if (!r || (r == (size_t)(-1) && errno == EINVAL))
-    {
-      if (ib + ibl < ibmax)
-        /* try using more input */
-        ++ibl;
-      else if (k && ib > bufi + k && bufi + k + n > ibmax)
-      {
-        /* switch to using real input */
-        ib = (ICONV_CONST char*) s + (ib - bufi - k);
-        ibmax = (ICONV_CONST char*) s + n;
-        k = 0;
-        ++ibl;
-      }
-      else
-      {
-        /* save the state and give up */
-        memset(ps, 0, sizeof(*ps));
-        if (ibl <= sizeof(mbstate_t)) /* need extra condition here! */
-          memcpy(ps, ib, ibl);
-        return (size_t)(-2);
-      }
-    }
-    else
-    {
-      /* bad input */
-      errno = EILSEQ;
-      return (size_t)(-1);
-    }
-  }
-}
-
-size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
-{
-  static mbstate_t mbstate;
-
-  if (!ps)
-    ps = &mbstate;
-
-  if (Charset_is_utf8)
-    return utf8rtowc(pwc, s, n, ps);
-  else if (charset_to_utf8 != (iconv_t)(-1))
-    return mbrtowc_iconv(pwc, s, n, ps, charset_to_utf8);
-  else
-  {
-    if (!s)
-    {
-      memset(ps, 0, sizeof(*ps));
-      return 0;
-    }
-    if (!n)
-      return (size_t)-2;
-    if (pwc)
-      *pwc = (wchar_t)(unsigned char)*s;
-    return (*s != 0);
-  }
-}
-
-int iswprint(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return ((0x20 <= wc && wc < 0x7f) || 0xa0 <= wc);
-  else
-    return (0 <= wc && wc < 256) ? IsPrint(wc) : 0;
-}
-
-int iswspace(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return IS_ASCII_WS(wc);
-  else
-    return (0 <= wc && wc < 256) ? isspace(wc) : 0;  /* 
__SAFE_ISSPACE_CHECKED__ */
-}
-
-int iswblank(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return wc == 9 || wc == 32;
-  else
-    return (0 <= wc && wc < 256) ? isblank(wc) : 0;
-}
-
-static wint_t towupper_ucs(wint_t x)
-{
-  /* Only works for x < 0x130 */
-  if ((0x60 < x && x < 0x7b) || (0xe0 <= x && x < 0xff && x != 0xf7))
-    return x - 32;
-  else if (0x100 <= x && x < 0x130)
-    return x & ~1;
-  else if (x == 0xb5)
-    return 0x39c;
-  else if (x == 0xff)
-    return 0x178;
-  else
-    return x;
-}
-
-static int iswupper_ucs(wint_t x)
-{
-  /* Only works for x < 0x130 */
-  if ((0x60 < x && x < 0x7b) || (0xe0 <= x && x < 0xff && x != 0xf7))
-    return 0;
-  else if ((0x40 < x && x < 0x5b) || (0xbf < x && x < 0xde))
-    return 1;
-  else if (0x100 <= x && x < 0x130)
-    return 1;
-  else if (x == 0xb5)
-    return 1;
-  else if (x == 0xff)
-    return 0;
-  else
-    return 0;
-}
-
-static wint_t towlower_ucs(wint_t x)
-{
-  /* Only works for x < 0x130 */
-  if ((0x40 < x && x < 0x5b) || (0xc0 <= x && x < 0xdf && x != 0xd7))
-    return x + 32;
-  else if (0x100 <= x && x < 0x130)
-    return x | 1;
-  else
-    return x;
-}
-
-static int iswalnum_ucs(wint_t wc)
-{
-  /* Only works for x < 0x220 */
-  if (wc >= 0x100)
-    return 1;
-  else if (wc < 0x30)
-    return 0;
-  else if (wc < 0x3a)
-    return 1;
-  else if (wc < 0xa0)
-    return (0x40 < (wc & ~0x20) && (wc & ~0x20) < 0x5b);
-  else if (wc < 0xc0)
-    return (wc == 0xaa || wc == 0xb5 || wc == 0xba);
-  else
-    return !(wc == 0xd7 || wc == 0xf7);
-}
-
-static int iswalpha_ucs(wint_t wc)
-{
-  /* Only works for x < 0x220 */
-  if (wc >= 0x100)
-    return 1;
-  else if (wc < 0x3a)
-    return 0;
-  else if (wc < 0xa0)
-    return (0x40 < (wc & ~0x20) && (wc & ~0x20) < 0x5b);
-  else if (wc < 0xc0)
-    return (wc == 0xaa || wc == 0xb5 || wc == 0xba);
-  else
-    return !(wc == 0xd7 || wc == 0xf7);
-}
-
-wint_t towupper(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return towupper_ucs(wc);
-  else
-    return (0 <= wc && wc < 256) ? toupper(wc) : wc;
-}
-
-wint_t towlower(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return towlower_ucs(wc);
-  else
-    return (0 <= wc && wc < 256) ? tolower(wc) : wc;
-}
-
-int iswalnum(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return iswalnum_ucs(wc);
-  else
-    return (0 <= wc && wc < 256) ? isalnum(wc) : 0;
-}
-
-int iswalpha(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return iswalpha_ucs(wc);
-  else
-    return (0 <= wc && wc < 256) ? isalpha(wc) : 0;
-}
-
-int iswupper(wint_t wc)
-{
-  if (Charset_is_utf8 || charset_is_ja)
-    return iswupper_ucs(wc);
-  else
-    return (0 <= wc && wc < 256) ? isupper(wc) : 0;
-}
-
+#ifndef HAVE_WCWIDTH
 /*
  * l10n for Japanese:
  *   Symbols, Greek and Cyrillic in JIS X 0208, Japanese Kanji
  *   Character Set, have a column width of 2.
  */
-int wcwidth_ja(wchar_t ucs)
+static int wcwidth_ja(wchar_t ucs)
 {
   if (ucs >= 0x3021)
     return -1; /* continue with the normal check */
@@ -438,95 +113,7 @@ int wcwidth(wchar_t wc)
   }
   return wcwidth_ucs(wc);
 }
-
-size_t utf8rtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps)
-{
-  static wchar_t mbstate;
-  wchar_t *ps = (wchar_t *)_ps;
-  size_t k = 1;
-  unsigned char c;
-  wchar_t wc;
-  int count;
-
-  if (!ps)
-    ps = &mbstate;
-
-  if (!s)
-  {
-    *ps = 0;
-    return 0;
-  }
-  if (!n)
-    return (size_t)-2;
-
-  if (!*ps)
-  {
-    c = (unsigned char)*s;
-    if (c < 0x80)
-    {
-      if (pwc)
-        *pwc = c;
-      return (c != 0);
-    }
-    else if (c < 0xc2)
-    {
-      errno = EILSEQ;
-      return (size_t)-1;
-    }
-    else if (c < 0xe0)
-      wc = ((c & 0x1f) << 6) + (count = 0);
-    else if (c < 0xf0)
-      wc = ((c & 0x0f) << 12) + (count = 1);
-    else if (c < 0xf8)
-      wc = ((c & 0x07) << 18) + (count = 2);
-    else if (c < 0xfc)
-      wc = ((c & 0x03) << 24) + (count = 3);
-    else if (c < 0xfe)
-      wc = ((c & 0x01) << 30) + (count = 4);
-    else
-    {
-      errno = EILSEQ;
-      return (size_t)-1;
-    }
-    ++s, --n, ++k;
-  }
-  else
-  {
-    wc = *ps & 0x7fffffff;
-    count = wc & 7; /* if count > 4 it will be caught below */
-  }
-
-  for (; n; ++s, --n, ++k)
-  {
-    c = (unsigned char)*s;
-    if (0x80 <= c && c < 0xc0)
-    {
-      wc |= (c & 0x3f) << (6 * count);
-      if (!count)
-      {
-        if (pwc)
-          *pwc = wc;
-        *ps = 0;
-        return wc ? k : 0;
-      }
-      --count, --wc;
-      if (!(wc >> (11+count*5)))
-      {
-        errno = count < 4 ? EILSEQ : EINVAL;
-        return (size_t)-1;
-      }
-    }
-    else
-    {
-      errno = EILSEQ;
-      return (size_t)-1;
-    }
-  }
-  *ps = wc;
-  return (size_t)-2;
-}
-
-#endif /* !HAVE_WC_FUNCS */
+#endif /* !HAVE_WCWIDTH */
 
 wchar_t replacement_char(void)
 {
diff --git a/mbyte.h b/mbyte.h
index c17ec1df..9822d573 100644
--- a/mbyte.h
+++ b/mbyte.h
@@ -1,52 +1,12 @@
 #ifndef _MBYTE_H
 # define _MBYTE_H
 
-# ifndef HAVE_WC_FUNCS
-#ifdef towupper
-# undef towupper
-#endif
-#ifdef towlower
-# undef towlower
-#endif
-#ifdef iswprint
-# undef iswprint
-#endif
-#ifdef iswspace
-# undef iswspace
-#endif
-#ifdef iswblank
-# undef iswblank
-#endif
-#ifdef iswalnum
-# undef iswalnum
-#endif
-#ifdef iswalpha
-# undef iswalpha
-#endif
-#ifdef iswupper
-# undef iswupper
-#endif
-#ifdef wcwidth
-# undef wcwidth
-#endif
-
-size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
-size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
-int iswprint(wint_t wc);
-int iswspace(wint_t wc);
-int iswblank(wint_t wc);
-int iswalnum(wint_t wc);
-int iswalpha(wint_t wc);
-int iswupper(wint_t wc);
-wint_t towupper(wint_t wc);
-wint_t towlower(wint_t wc);
+# ifndef HAVE_WCWIDTH
 int wcwidth(wchar_t wc);
-# endif /* !HAVE_WC_FUNCS */
-
+# endif /* !HAVE_WCWIDTH */
 
 void mutt_set_charset(char *charset);
 extern int Charset_is_utf8;
-size_t utf8rtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps);
 wchar_t replacement_char(void);
 int is_display_corrupting_utf8(wchar_t wc);
 
diff --git a/mutt.h b/mutt.h
index 764d8c17..cc3b0baa 100644
--- a/mutt.h
+++ b/mutt.h
@@ -38,12 +38,9 @@
 #ifdef __APPLE_CC__
 #define _DONT_USE_CTYPE_INLINE_
 #endif
-#ifdef HAVE_WCHAR_H
-# include <wchar.h>
-#endif
-#if defined(HAVE_WCTYPE_H) && defined(HAVE_WC_FUNCS)
-# include <wctype.h>
-#endif
+
+#include <wchar.h>
+#include <wctype.h>
 
 #ifndef _POSIX_PATH_MAX
 #include <limits.h>
@@ -63,13 +60,6 @@
 #include "buffer.h"
 #include "color.h"
 
-#ifndef HAVE_WC_FUNCS
-# ifdef MB_LEN_MAX
-#  undef MB_LEN_MAX
-# endif
-# define MB_LEN_MAX 16
-#endif
-
 #ifdef HAVE_FGETS_UNLOCKED
 # ifdef fgets
 #  undef fgets
diff --git a/protos.h b/protos.h
index a9ec6031..4958aa0e 100644
--- a/protos.h
+++ b/protos.h
@@ -448,9 +448,6 @@ int mutt_from_base64(char*, const char*, size_t);
 void mutt_buffer_to_base64(BUFFER *, const unsigned char *, size_t);
 int mutt_buffer_from_base64(BUFFER *, const char *);
 
-/* utf8.c */
-int mutt_wctoutf8(char *s, unsigned int c, size_t buflen);
-
 #ifdef LOCALES_HACK
 #define IsPrint(c) (isprint((unsigned char)(c)) ||      \
                     ((unsigned char)(c) >= 0xa0))
diff --git a/regex.c b/regex.c
index a0ea9ee2..bba0daaa 100644
--- a/regex.c
+++ b/regex.c
@@ -80,12 +80,8 @@
 
 /* For platform which support the ISO C amendment 1 functionality we
    support user defined character classes.  */
-#ifdef HAVE_WCHAR_H
-# include <wchar.h>
-#endif
-#if defined(HAVE_WCTYPE_H) && defined(HAVE_WC_FUNCS)
-# include <wctype.h>
-#endif
+#include <wchar.h>
+#include <wctype.h>
 
 /* This is for other GNU distributions with internationalized messages.  */
 #if HAVE_LIBINTL_H || defined (_LIBC)
@@ -1691,16 +1687,10 @@ typedef struct
        }                                                                \
     }
 
-#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
 /* The GNU C library provides support for user-defined character classes
    and the functions from ISO C amendment 1.  */
 # ifdef CHARCLASS_NAME_MAX
 #  define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
-# else
-/* This shouldn't happen but some implementation might still have this
-   problem.  Use a reasonable default value.  */
-#  define CHAR_CLASS_MAX_LENGTH 256
-# endif
 
 # define IS_CHAR_CLASS(string) wctype (string)
 #else
@@ -2191,7 +2181,6 @@ regex_compile (pattern, size, syntax, bufp)
                        the leading `:' and `[' (but set bits for them).  */
                     if (c == ':' && *p == ']')
                       {
-#if defined _LIBC || (defined HAVE_WC_FUNCS && defined HAVE_WCTYPE_H && 
defined HAVE_WCHAR_H)
                         boolean is_lower = STREQ (str, "lower");
                         boolean is_upper = STREQ (str, "upper");
                         wctype_t wt;
@@ -2219,55 +2208,6 @@ regex_compile (pattern, size, syntax, bufp)
                           }
 
                         had_char_class = true;
-#else
-                        int ch;
-                        boolean is_alnum = STREQ (str, "alnum");
-                        boolean is_alpha = STREQ (str, "alpha");
-                        boolean is_blank = STREQ (str, "blank");
-                        boolean is_cntrl = STREQ (str, "cntrl");
-                        boolean is_digit = STREQ (str, "digit");
-                        boolean is_graph = STREQ (str, "graph");
-                        boolean is_lower = STREQ (str, "lower");
-                        boolean is_print = STREQ (str, "print");
-                        boolean is_punct = STREQ (str, "punct");
-                        boolean is_space = STREQ (str, "space");
-                        boolean is_upper = STREQ (str, "upper");
-                        boolean is_xdigit = STREQ (str, "xdigit");
-
-                        if (!IS_CHAR_CLASS (str))
-                          FREE_STACK_RETURN (REG_ECTYPE);
-
-                        /* Throw away the ] at the end of the character
-                           class.  */
-                        PATFETCH (c);
-
-                        if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
-
-                        for (ch = 0; ch < 1 << BYTEWIDTH; ch++)
-                          {
-                            /* This was split into 3 if's to
-                               avoid an arbitrary limit in some compiler.  */
-                            if (   (is_alnum  && ISALNUM (ch))
-                                || (is_alpha  && ISALPHA (ch))
-                                || (is_blank  && ISBLANK (ch))
-                                || (is_cntrl  && ISCNTRL (ch)))
-                              SET_LIST_BIT (ch);
-                            if (   (is_digit  && ISDIGIT (ch))
-                                || (is_graph  && ISGRAPH (ch))
-                                || (is_lower  && ISLOWER (ch))
-                                || (is_print  && ISPRINT (ch)))
-                              SET_LIST_BIT (ch);
-                            if (   (is_punct  && ISPUNCT (ch))
-                                || (is_space  && ISSPACE (ch))
-                                || (is_upper  && ISUPPER (ch))
-                                || (is_xdigit && ISXDIGIT (ch)))
-                              SET_LIST_BIT (ch);
-                            if (   translate && (is_upper || is_lower)
-                                && (ISUPPER (ch) || ISLOWER (ch)))
-                              SET_LIST_BIT (ch);
-                          }
-                        had_char_class = true;
-#endif  /* libc || wctype.h */
                       }
                     else
                       {
diff --git a/utf8.c b/utf8.c
deleted file mode 100644
index f979e7ef..00000000
--- a/utf8.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#ifndef HAVE_WC_FUNCS
-
-#include <sys/types.h>
-#include <errno.h>
-
-#ifndef EILSEQ
-#define EILSEQ EINVAL
-#endif
-
-int mutt_wctoutf8(char *s, unsigned int c, size_t buflen)
-{
-  if (c < (1 << 7))
-  {
-    if (s && buflen >= 1)
-      *s++ = c;
-    return 1;
-  }
-  else if (c < (1 << 11))
-  {
-    if (s && buflen >= 2)
-    {
-      *s++ = 0xc0 | (c >> 6);
-      *s++ = 0x80 | (c & 0x3f);
-    }
-    return 2;
-  }
-  else if (c < (1 << 16))
-  {
-    if (s && buflen >= 3)
-    {
-      *s++ = 0xe0 | (c >> 12);
-      *s++ = 0x80 | ((c >> 6) & 0x3f);
-      *s++ = 0x80 | (c & 0x3f);
-    }
-    return 3;
-  }
-  else if (c < (1 << 21))
-  {
-    if (s && buflen >= 4)
-    {
-      *s++ = 0xf0 | (c >> 18);
-      *s++ = 0x80 | ((c >> 12) & 0x3f);
-      *s++ = 0x80 | ((c >> 6) & 0x3f);
-      *s++ = 0x80 | (c & 0x3f);
-    }
-    return 4;
-  }
-  else if (c < (1 << 26))
-  {
-    if (s && buflen >= 5)
-    {
-      *s++ = 0xf8 | (c >> 24);
-      *s++ = 0x80 | ((c >> 18) & 0x3f);
-      *s++ = 0x80 | ((c >> 12) & 0x3f);
-      *s++ = 0x80 | ((c >> 6) & 0x3f);
-      *s++ = 0x80 | (c & 0x3f);
-    }
-    return 5;
-  }
-  else if (c < (1 << 31))
-  {
-    if (s && buflen >= 6)
-    {
-      *s++ = 0xfc | (c >> 30);
-      *s++ = 0x80 | ((c >> 24) & 0x3f);
-      *s++ = 0x80 | ((c >> 18) & 0x3f);
-      *s++ = 0x80 | ((c >> 12) & 0x3f);
-      *s++ = 0x80 | ((c >> 6) & 0x3f);
-      *s++ = 0x80 | (c & 0x3f);
-    }
-    return 6;
-  }
-  errno = EILSEQ;
-  return -1;
-}
-
-#endif /* !HAVE_WC_FUNCS */
diff --git a/wcwidth.c b/wcwidth.c
index 75e1b9a8..a8167992 100644
--- a/wcwidth.c
+++ b/wcwidth.c
@@ -24,7 +24,7 @@
 # include "config.h"
 #endif
 
-#ifndef HAVE_WC_FUNCS
+#ifndef HAVE_WCWIDTH
 
 #include "mutt.h"
 #include "mbyte.h"
@@ -168,7 +168,7 @@ int wcwidth_ucs(wchar_t ucs)
       (ucs >= 0x30000 && ucs <= 0x3fffd)));
 }
 
-#endif /* !HAVE_WC_FUNCS */
+#endif /* !HAVE_WCWIDTH */
 
 #if 0 /* original */
 int wcswidth(const wchar_t *pwcs, size_t n)
-- 
2.54.0

Reply via email to