From b263a459a63915c14fb4ca98a13847ca9c94e8e7 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 11 Apr 2017 14:22:11 +0100 Subject: [PATCH] mutt_check_charset --- charset.c | 10 +++++----- charset.h | 2 +- init.c | 5 +++-- pgp.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/charset.c b/charset.c index eccd0ebe5..bb8678481 100644 --- a/charset.c +++ b/charset.c @@ -624,27 +624,27 @@ void fgetconv_close (FGETCONV **_fc) FREE (_fc); /* __FREE_CHECKED__ */ } -int mutt_check_charset (const char *s, int strict) +bool mutt_check_charset (const char *s, bool strict) { int i; iconv_t cd; if (mutt_is_utf8 (s)) - return 0; + return true; if (!strict) for (i = 0; PreferredMIMENames[i].key; i++) { if ((ascii_strcasecmp (PreferredMIMENames[i].key, s) == 0) || (ascii_strcasecmp (PreferredMIMENames[i].pref, s) == 0)) - return 0; + return true; } if ((cd = mutt_iconv_open (s, s, 0)) != (iconv_t)(-1)) { iconv_close (cd); - return 0; + return true; } - return -1; + return false; } diff --git a/charset.h b/charset.h index 29e02f5d7..5433c582d 100644 --- a/charset.h +++ b/charset.h @@ -48,6 +48,6 @@ char *mutt_get_default_charset (void); * known to local iconv implementation). If strict is non-zero, check * against iconv only. Returns 0 if known and negative otherwise. */ -int mutt_check_charset (const char *s, int strict); +bool mutt_check_charset (const char *s, bool strict); #endif /* _MUTT_CHARSET_H */ diff --git a/init.c b/init.c index dca83c330..316d7648a 100644 --- a/init.c +++ b/init.c @@ -2077,7 +2077,8 @@ static void pretty_var (char *dst, size_t len, const char *option, const char *v static int check_charset (struct option_t *opt, const char *val) { char *p = NULL, *q = NULL, *s = safe_strdup (val); - int rc = 0, strict = (strcmp (opt->option, "send_charset") == 0); + int rc = 0; + bool strict = (strcmp (opt->option, "send_charset") == 0); if (!s) return rc; @@ -2086,7 +2087,7 @@ static int check_charset (struct option_t *opt, const char *val) { if (!*p) continue; - if (mutt_check_charset (p, strict) < 0) + if (!mutt_check_charset (p, strict)) { rc = -1; break; diff --git a/pgp.c b/pgp.c index eb723e6a4..5764c89cf 100644 --- a/pgp.c +++ b/pgp.c @@ -408,7 +408,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s) gpgcharset = safe_strdup (buf + 9); if ((l = mutt_strlen (gpgcharset)) > 0 && gpgcharset[l-1] == '\n') gpgcharset[l-1] = 0; - if (mutt_check_charset (gpgcharset, 0) < 0) + if (!mutt_check_charset (gpgcharset, 0)) mutt_str_replace (&gpgcharset, "UTF-8"); } } -- 2.40.0