From 9fab3817cf6b2e1d04287a80c4a652b4f9d0a5e1 Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Wed, 15 Mar 2017 19:34:58 +0000 Subject: [PATCH] Make iconv mandatory (no more --disable-iconv) Issue: #460 --- Makefile.am | 4 +-- charset.c | 21 ------------ charset.h | 13 ------- configure.ac | 96 ++++++++++++++++++---------------------------------- hcache.c | 5 --- init.h | 2 -- mutt_idna.h | 28 --------------- sendlib.c | 4 --- version.c | 5 --- 9 files changed, 34 insertions(+), 144 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1883e26bd..eb1117487 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,8 +41,8 @@ mutt_SOURCES = \ edit.c enter.c flags.c init.c filter.c from.c \ getdomain.c group.c \ handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \ - main.c mbox.c menu.c mh.c mutt_sasl_plain.c mx.c pager.c parse.c pattern.c \ - postpone.c query.c recvattach.c recvcmd.c \ + main.c mbox.c menu.c mh.c mutt_idna.c mutt_sasl_plain.c mx.c pager.c \ + parse.c pattern.c postpone.c query.c recvattach.c recvcmd.c \ rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ score.c send.c sendlib.c signal.c sort.c \ status.c system.c thread.c charset.c history.c lib.c \ diff --git a/charset.c b/charset.c index e2e21bcb6..6a4d2fe14 100644 --- a/charset.c +++ b/charset.c @@ -325,27 +325,6 @@ char *mutt_get_default_charset () return strcpy (fcharset, "us-ascii"); /* __STRCPY_CHECKED__ */ } -#ifndef HAVE_ICONV - -iconv_t iconv_open (const char *tocode, const char *fromcode) -{ - return (iconv_t)(-1); -} - -size_t iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) -{ - return 0; -} - -int iconv_close (iconv_t cd) -{ - return 0; -} - -#endif /* !HAVE_ICONV */ - - /* * Like iconv_open, but canonicalises the charsets, applies charset-hooks, * recanonicalises, and finally applies iconv-hooks. Parameter flags=0 skips diff --git a/charset.h b/charset.h index 54891f0e6..890c9f31c 100644 --- a/charset.h +++ b/charset.h @@ -19,20 +19,7 @@ #ifndef _CHARSET_H #define _CHARSET_H -#ifdef HAVE_ICONV_H #include -#endif - -#ifndef HAVE_ICONV_T_DEF -typedef void *iconv_t; -#endif - -#ifndef HAVE_ICONV -#define ICONV_CONST /**/ -iconv_t iconv_open (const char *, const char *); -size_t iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *); -int iconv_close (iconv_t); -#endif int mutt_convert_string (char **, const char *, const char *, int); diff --git a/configure.ac b/configure.ac index 1aa73d310..bb9f59dc4 100644 --- a/configure.ac +++ b/configure.ac @@ -1183,29 +1183,14 @@ AC_SUBST(NOTMUCH_LIBS) dnl -- iconv/gettext -- -AC_ARG_ENABLE(iconv, AS_HELP_STRING([--disable-iconv],[Disable iconv support]), - [if test x$enableval = xno; then - am_cv_func_iconv=no - fi -]) - AM_GNU_GETTEXT_VERSION([0.18]) AM_GNU_GETTEXT([external]) AC_CHECK_HEADERS([locale.h]) -if test "$am_cv_func_iconv" = "no"; then - AC_MSG_WARN([Configuring without iconv support. See INSTALL for details]) -else - AM_ICONV - -AC_CHECK_HEADERS(iconv.h, - [AC_MSG_CHECKING(whether iconv.h defines iconv_t) - AC_EGREP_HEADER([typedef.*iconv_t],iconv.h, - [AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_ICONV_T_DEF, 1, - [Define if defines iconv_t.])], - AC_MSG_RESULT(no))]) +if test "$am_cv_func_iconv" != yes; then + AC_MSG_ERROR([An iconv implementation is required]) +fi dnl (1) Some implementations of iconv won't convert from UTF-8 to UTF-8. dnl (2) In glibc-2.1.2 and earlier there is a bug that messes up ob and @@ -1266,17 +1251,6 @@ else AC_DEFINE(ICONV_NONTRANS, 0) fi -fi # libiconv - -dnl -- IDN depends on iconv - -dnl mutt_idna.c will perform charset transformations (for smtputf8 -dnl support) as long as at least iconv is installed. If there is no -dnl iconv, then it doesn't need to be included in the build. -if test "$am_cv_func_iconv" = yes; then - MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS mutt_idna.o" -fi - AC_ARG_WITH(idn, AS_HELP_STRING([--with-idn=@<:@PFX@:>@],[Use GNU libidn for internationalized domain names]), [ if test "$with_idn" != "no"; then @@ -1289,41 +1263,35 @@ AC_ARG_WITH(idn, AS_HELP_STRING([--with-idn=@<:@PFX@:>@],[Use GNU libidn for int [with_idn=auto]) if test "x$with_idn" != "xno"; then - if test "$am_cv_func_iconv" != "yes"; then - if test "$with_idn" != "auto"; then - AC_MSG_ERROR([IDN requested but iconv is disabled or unavailable]) - fi - else - dnl Solaris 11 has /usr/include/idn - have_stringprep_h=no - AC_CHECK_HEADERS([stringprep.h idn/stringprep.h], [ - have_stringprep_h=yes - break]) - have_idna_h=no - AC_CHECK_HEADERS([idna.h idn/idna.h], [ - have_idna_h=yes - break]) - - mutt_save_LIBS="$LIBS" - LIBS= - - AC_SEARCH_LIBS([stringprep_check_version], [idn], [ - AC_DEFINE([HAVE_LIBIDN], 1, [Define to 1 if you have the GNU idn library]) - MUTTLIBS="$MUTTLIBS $LIBS" - - LIBS="$LIBS $LIBICONV" - AC_CHECK_FUNCS(idna_to_unicode_utf8_from_utf8 idna_to_unicode_8z8z) - AC_CHECK_FUNCS(idna_to_ascii_from_utf8 idna_to_ascii_8z) - AC_CHECK_FUNCS(idna_to_ascii_lz idna_to_ascii_from_locale) - ]) - - LIBS="$mutt_save_LIBS" - - if test "$with_idn" != auto; then - if test $have_stringprep_h = no || test $have_idna_h = no || test $ac_cv_search_stringprep_check_version = no; then - AC_MSG_ERROR([IDN was requested, but libidn was not usable on this system]) - fi - fi + dnl Solaris 11 has /usr/include/idn + have_stringprep_h=no + AC_CHECK_HEADERS([stringprep.h idn/stringprep.h], [ + have_stringprep_h=yes + break]) + have_idna_h=no + AC_CHECK_HEADERS([idna.h idn/idna.h], [ + have_idna_h=yes + break]) + + mutt_save_LIBS="$LIBS" + LIBS= + + AC_SEARCH_LIBS([stringprep_check_version], [idn], [ + AC_DEFINE([HAVE_LIBIDN], 1, [Define to 1 if you have the GNU idn library]) + MUTTLIBS="$MUTTLIBS $LIBS" + + LIBS="$LIBS $LIBICONV" + AC_CHECK_FUNCS(idna_to_unicode_utf8_from_utf8 idna_to_unicode_8z8z) + AC_CHECK_FUNCS(idna_to_ascii_from_utf8 idna_to_ascii_8z) + AC_CHECK_FUNCS(idna_to_ascii_lz idna_to_ascii_from_locale) + ]) + + LIBS="$mutt_save_LIBS" + + if test "$with_idn" != auto; then + if test $have_stringprep_h = no || test $have_idna_h = no || test $ac_cv_search_stringprep_check_version = no; then + AC_MSG_ERROR([IDN was requested, but libidn was not usable on this system]) + fi fi fi diff --git a/hcache.c b/hcache.c index eb2aa8ba8..c015d3f73 100644 --- a/hcache.c +++ b/hcache.c @@ -588,11 +588,6 @@ static const char *mutt_hcache_per_folder(const char *path, const char *folder, int ret = stat(path, &sb); int slash = (path[plen - 1] == '/'); -#ifndef HAVE_ICONV - snprintf(suffix, sizeof(suffix), "-%s", - Charset && *Charset ? Charset : mutt_get_default_charset()); -#endif - if (((ret == 0) && !S_ISDIR(sb.st_mode)) || ((ret == -1) && !slash)) { /* An existing file or a non-existing path not ending with a slash */ diff --git a/init.h b/init.h index 97b00f65d..498095711 100644 --- a/init.h +++ b/init.h @@ -4459,9 +4459,7 @@ const struct command_t Commands[] = { { "ifdef", parse_ifdef, 0 }, { "ifndef", parse_ifdef, 1 }, { "finish", finish_source, 0 }, -#ifdef HAVE_ICONV { "iconv-hook", mutt_parse_hook, MUTT_ICONVHOOK }, -#endif { "ignore", parse_ignore, 0 }, { "lists", parse_lists, 0 }, #ifdef USE_LUA diff --git a/mutt_idna.h b/mutt_idna.h index 1681a12bb..5765641f0 100644 --- a/mutt_idna.h +++ b/mutt_idna.h @@ -45,7 +45,6 @@ #endif /* HAVE_LIBIDN */ -#ifdef HAVE_ICONV int mutt_addrlist_to_intl (ADDRESS *, char **); int mutt_addrlist_to_local (ADDRESS *); @@ -53,32 +52,5 @@ void mutt_env_to_local (ENVELOPE *); int mutt_env_to_intl (ENVELOPE *, char **, char **); const char *mutt_addr_for_display (ADDRESS *a); -#else -static inline int mutt_addrlist_to_intl (ADDRESS *addr, char **err) -{ - return 0; -} - -static inline int mutt_addrlist_to_local (ADDRESS *addr) -{ - return 0; -} - -static inline void mutt_env_to_local (ENVELOPE *env) -{ - return; -} - -static inline int mutt_env_to_intl (ENVELOPE *env, char **tag, char **err) -{ - return 0; -} - -static inline const char *mutt_addr_for_display (ADDRESS *a) -{ - return a->mailbox; -} -#endif /* HAVE_LIBICONV */ - #endif diff --git a/sendlib.c b/sendlib.c index 90fc58f02..d34816387 100644 --- a/sendlib.c +++ b/sendlib.c @@ -637,7 +637,6 @@ static size_t convert_file_to (FILE *file, const char *fromcode, int ncodes, const char **tocodes, int *tocode, CONTENT *info) { -#ifdef HAVE_ICONV iconv_t cd1, *cd; char bufi[256], bufu[512], bufo[4 * sizeof (bufi)]; ICONV_CONST char *ib, *ub; @@ -762,9 +761,6 @@ static size_t convert_file_to (FILE *file, const char *fromcode, FREE (&states); return ret; -#else - return -1; -#endif /* !HAVE_ICONV */ } /* diff --git a/version.c b/version.c index 40417f5a7..6845a8db2 100644 --- a/version.c +++ b/version.c @@ -184,11 +184,6 @@ static struct compile_options comp_opts[] = #else { "HAVE_GETSID", 0 }, #endif -#ifdef HAVE_ICONV - { "HAVE_ICONV", 1 }, -#else - { "HAVE_ICONV", 0 }, -#endif #ifdef HAVE_LANGINFO_CODESET { "HAVE_LANGINFO_CODESET", 1 }, #else -- 2.50.0