]> granicus.if.org Git - neomutt/commitdiff
don't check for empty config strings
authorRichard Russon <rich@flatcap.org>
Thu, 16 May 2019 11:55:40 +0000 (12:55 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 16 May 2019 12:56:32 +0000 (13:56 +0100)
The config system stores empty strings as NULL.
Config variables must not be set directly, but using the config system
(this gives us validation and notifications).

24 files changed:
alias.c
bcache.c
commands.c
compose.c
email/parse.c
email/rfc2047.c
email/rfc2231.c
handler.c
imap/auth.c
imap/auth_oauth.c
init.c
mutt_socket.c
muttlib.c
ncrypt/crypt.c
ncrypt/pgpinvoke.c
ncrypt/smime.c
nntp/browse.c
nntp/newsrc.c
nntp/nntp.c
notmuch/mutt_notmuch.c
pop/pop_auth.c
send.c
sendlib.c
smtp.c

diff --git a/alias.c b/alias.c
index 704677e5c29f9ac5e96985555f07315af23ae571..d07f9310f0107a3d2634d4d187d57a09238a4dd2 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -187,7 +187,7 @@ static void write_safe_address(FILE *fp, char *s)
  */
 static void recode_buf(char *buf, size_t buflen)
 {
-  if (!C_ConfigCharset || !*C_ConfigCharset || !C_Charset)
+  if (!C_ConfigCharset || !C_Charset)
     return;
 
   char *s = mutt_str_strdup(buf);
index edc2ed0e678660de5f8ddcd5e546402faefc710c..8a705ac254fcb6a9ebbd47ccab1634c60db8bd60 100644 (file)
--- a/bcache.c
+++ b/bcache.c
@@ -68,7 +68,7 @@ static int bcache_path(struct ConnAccount *account, const char *mailbox, char *d
   struct Url url = { U_UNKNOWN };
   int len;
 
-  if (!account || !C_MessageCachedir || !*C_MessageCachedir || !dst || (dstlen == 0))
+  if (!account || !C_MessageCachedir || !dst || (dstlen == 0))
     return -1;
 
   /* make up a Url we can turn into a string */
index 01058a647fcc32e0f4a2012159c15a7cf7eef666..ec7823ddf0134b101dbd49c0ea482e2a126f65cf 100644 (file)
@@ -234,7 +234,7 @@ int mutt_display_message(struct Email *cur)
     return 0;
   }
 
-  if (C_DisplayFilter && *C_DisplayFilter)
+  if (C_DisplayFilter)
   {
     fp_filter_out = fp_out;
     fp_out = NULL;
@@ -679,7 +679,7 @@ void mutt_print_message(struct Mailbox *m, struct EmailList *el)
   if (!m || !el)
     return;
 
-  if (C_Print && (!C_PrintCommand || !*C_PrintCommand))
+  if (C_Print && !C_PrintCommand)
   {
     mutt_message(_("No printing command has been defined"));
     return;
index eff70f0fbd1fb29b428cef101f6b1aaacb56af6a..b9d3edd622c6b7c16c8e64a05b7f8a205740e301 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -341,7 +341,7 @@ static void redraw_crypt_lines(struct Email *msg)
   }
 
   if (((WithCrypto & APPLICATION_SMIME) != 0) && (msg->security & APPLICATION_SMIME) &&
-      (msg->security & SEC_ENCRYPT) && C_SmimeEncryptWith && *C_SmimeEncryptWith)
+      (msg->security & SEC_ENCRYPT) && C_SmimeEncryptWith)
   {
     SET_COLOR(MT_COLOR_COMPOSE_HEADER);
     mutt_window_mvprintw(MuttIndexWindow, HDR_CRYPTINFO, 40, "%s", _("Encrypt with: "));
index acc0a4b34002c1261cf1caee25e28248a63023ff..a57370bb9ebbc7665839049408eff4dc8ab620fb 100644 (file)
@@ -139,7 +139,7 @@ static void parse_parameters(struct ParameterList *param, const char *s)
         s++;
         for (i = 0; *s && (i < (sizeof(buf) - 1)); i++, s++)
         {
-          if (C_AssumedCharset && *C_AssumedCharset)
+          if (C_AssumedCharset)
           {
             /* As iso-2022-* has a character of '"' with non-ascii state,
              * ignore it. */
@@ -514,9 +514,8 @@ void mutt_parse_content_type(const char *s, struct Body *ct)
     if (!pc)
     {
       mutt_param_set(&ct->parameter, "charset",
-                     (C_AssumedCharset && *C_AssumedCharset) ?
-                         (const char *) mutt_ch_get_default_charset() :
-                         "us-ascii");
+                     (C_AssumedCharset) ? (const char *) mutt_ch_get_default_charset() :
+                                          "us-ascii");
     }
   }
 }
index 95caf0d0944c16bab8d5190cf20c436bad4e3194..c8b0e15ee350cae0d537eff5764de7ad643a941f 100644 (file)
@@ -690,7 +690,7 @@ void rfc2047_decode(char **pd)
 
       /* Add non-encoded part */
       {
-        if (C_AssumedCharset && *C_AssumedCharset)
+        if (C_AssumedCharset)
         {
           char *conv = mutt_str_substr_dup(s, s + holelen);
           mutt_ch_convert_nonmime_string(&conv);
@@ -768,7 +768,7 @@ void rfc2047_decode_addrlist(struct Address *a)
 {
   while (a)
   {
-    if (a->personal && ((strstr(a->personal, "=?")) || (C_AssumedCharset && *C_AssumedCharset)))
+    if (a->personal && ((strstr(a->personal, "=?")) || C_AssumedCharset))
     {
       rfc2047_decode(&a->personal);
     }
index 33fae65cddd3990d1e783d4b5685c486a01eb504..15363d344aaeae2699c4daa53cceeb7c6c3e15f6 100644 (file)
@@ -264,7 +264,7 @@ void rfc2231_decode_parameters(struct ParameterList *p)
 
       if (C_Rfc2047Parameters && np->value && strstr(np->value, "=?"))
         rfc2047_decode(&np->value);
-      else if (C_AssumedCharset && *C_AssumedCharset)
+      else if (C_AssumedCharset)
         mutt_ch_convert_nonmime_string(&np->value);
     }
     else if (*(s + 1) == '\0')
index 6876828488b2ef6bd6dfd175b531bbbf2e72a46a..6ad757f0c9dd114c9a6957c9da81f315ad81b39c 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1794,7 +1794,7 @@ void mutt_decode_attachment(struct Body *b, struct State *s)
   if (istext && s->flags & MUTT_CHARCONV)
   {
     char *charset = mutt_param_get(&b->parameter, "charset");
-    if (!charset && C_AssumedCharset && *C_AssumedCharset)
+    if (!charset && C_AssumedCharset)
       charset = mutt_ch_get_default_charset();
     if (charset && C_Charset)
       cd = mutt_ch_iconv_open(C_Charset, charset, MUTT_ICONV_HOOK_FROM);
index 3d5d1eed7293f02f3027c87ec42b1fe3f900551a..3b28d4cd006b41bf55d08e3b1684b53433be6b81 100644 (file)
@@ -68,7 +68,7 @@ int imap_authenticate(struct ImapAccountData *adata)
 {
   int rc = IMAP_AUTH_FAILURE;
 
-  if (C_ImapAuthenticators && *C_ImapAuthenticators)
+  if (C_ImapAuthenticators)
   {
     mutt_debug(LL_DEBUG2, "Trying user-defined imap_authenticators\n");
 
index 2479561f159c5c0616e30803fdbfb17ca3d4d563..6305114041aa13ae0c75b542555357acd3c7e63a 100644 (file)
@@ -58,7 +58,7 @@ enum ImapAuthRes imap_auth_oauth(struct ImapAccountData *adata, const char *meth
   }
 
   /* If they did not explicitly request or configure oauth then fail quietly */
-  if (!(method || (C_ImapOauthRefreshCommand && *C_ImapOauthRefreshCommand)))
+  if (!method && !C_ImapOauthRefreshCommand)
     return IMAP_AUTH_UNAVAIL;
 
   mutt_message(_("Authenticating (OAUTHBEARER)..."));
diff --git a/init.c b/init.c
index f281d5d55e302935f0b3396147e0bb80123d1e48..5085ad6837a19b2ab7b25e8933f4c213935a5ef7 100644 (file)
--- a/init.c
+++ b/init.c
@@ -806,7 +806,7 @@ static int source_rc(const char *rcfile_path, struct Buffer *err)
   mutt_buffer_init(&token);
   while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, MUTT_CONT)))
   {
-    const bool conv = C_ConfigCharset && (*C_ConfigCharset) && C_Charset;
+    const bool conv = C_ConfigCharset && C_Charset;
     if (conv)
     {
       currentline = mutt_str_strdup(linebuf);
index 72bcf436a4711e73673405360273434c9d6929b9..451f7b523ce6c7e4ecb6befd823cdca5c75ba7b2 100644 (file)
@@ -45,7 +45,7 @@ struct Connection *mutt_conn_new(const struct ConnAccount *account)
 {
   enum ConnectionType conn_type;
 
-  if (C_Tunnel && *C_Tunnel)
+  if (C_Tunnel)
     conn_type = MUTT_CONNECTION_TUNNEL;
   else if (account->flags & MUTT_ACCT_SSL)
     conn_type = MUTT_CONNECTION_SSL;
index d6a42ed47584b5e93969d8584c606687d7dcf566..e32dc6920c7ada696f1a1a22ffbef7c95e5e4a72 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -204,7 +204,7 @@ void mutt_buffer_expand_path_regex(struct Buffer *buf, bool regex)
         }
         else if (mb_type == MUTT_NOTMUCH)
           mutt_buffer_strcpy(p, NONULL(C_Folder));
-        else if (C_Folder && *C_Folder && (C_Folder[strlen(C_Folder) - 1] == '/'))
+        else if (C_Folder && (C_Folder[strlen(C_Folder) - 1] == '/'))
           mutt_buffer_strcpy(p, NONULL(C_Folder));
         else
           mutt_buffer_printf(p, "%s/", NONULL(C_Folder));
index 11962bf1da6d325dafef85c1b579f803b3f61858..6fb2d5fbfd596418a3032cc3dedf04a920d0aa24 100644 (file)
@@ -1032,7 +1032,7 @@ static void crypt_fetch_signatures(struct Body ***signatures, struct Body *a, in
 bool mutt_should_hide_protected_subject(struct Email *e)
 {
   if (C_CryptProtectedHeadersWrite && (e->security & SEC_ENCRYPT) &&
-      !(e->security & SEC_INLINE) && C_CryptProtectedHeadersSubject && *C_CryptProtectedHeadersSubject)
+      !(e->security & SEC_INLINE) && C_CryptProtectedHeadersSubject)
   {
     return true;
   }
index 53a41af5111673beba47f51715d43913e18edb23..03b6811a48a37ee6bde433142635a89b4a52203b 100644 (file)
@@ -222,7 +222,7 @@ static pid_t pgp_invoke(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
   cctx.need_passphrase = need_passphrase;
   cctx.fname = fname;
   cctx.sig_fname = sig_fname;
-  if (C_PgpSignAs && *C_PgpSignAs)
+  if (C_PgpSignAs)
     cctx.signas = C_PgpSignAs;
   else
     cctx.signas = C_PgpDefaultKey;
@@ -411,7 +411,7 @@ void pgp_class_invoke_import(const char *fname)
 
   mutt_buffer_quote_filename(buf_fname, fname, true);
   cctx.fname = mutt_b2s(buf_fname);
-  if (C_PgpSignAs && *C_PgpSignAs)
+  if (C_PgpSignAs)
     cctx.signas = C_PgpSignAs;
   else
     cctx.signas = C_PgpDefaultKey;
index 38aee02e3a4ae12d43f3c8932798fb04a8ce9769..9646a1d5e6ce1a00ef59db92fd0b902fa6c710d8 100644 (file)
@@ -997,7 +997,7 @@ void smime_class_getkeys(struct Envelope *env)
   struct Address *t = NULL;
   bool found = false;
 
-  if (C_SmimeDecryptUseDefaultKey && C_SmimeDefaultKey && *C_SmimeDefaultKey)
+  if (C_SmimeDecryptUseDefaultKey && C_SmimeDefaultKey)
   {
     snprintf(SmimeKeyToUse, sizeof(SmimeKeyToUse), "%s/%s", NONULL(C_SmimeKeys),
              C_SmimeDefaultKey);
@@ -1699,7 +1699,7 @@ struct Body *smime_class_sign_message(struct Body *a)
   pid_t pid;
   char *intermediates = NULL;
 
-  char *signas = (C_SmimeSignAs && *C_SmimeSignAs) ? C_SmimeSignAs : C_SmimeDefaultKey;
+  char *signas = C_SmimeSignAs ? C_SmimeSignAs : C_SmimeDefaultKey;
   if (!signas || !*signas)
   {
     mutt_error(_("Can't sign: No key specified. Use Sign As."));
index 4d4ab44971fe1fbe90c2d4cc5dfdc97552a62d22..65ef7c6b9c5c944f22e8206fbd75d45dda2321af 100644 (file)
@@ -70,7 +70,7 @@ const char *group_index_format_str(char *buf, size_t buflen, size_t col, int col
       if (folder->ff->nd->desc)
       {
         char *desc = mutt_str_strdup(folder->ff->nd->desc);
-        if (C_NewsgroupsCharset && *C_NewsgroupsCharset)
+        if (C_NewsgroupsCharset)
           mutt_ch_convert_string(&desc, C_NewsgroupsCharset, C_Charset, MUTT_ICONV_HOOK_FROM);
         mutt_mb_filter_unprintable(&desc);
 
index 6547a5d4553b9f28478b1be7b800cb862de04e43..a61dc04c611b83876ce323ed3b07afa97c03a638 100644 (file)
@@ -1056,7 +1056,7 @@ struct NntpAccountData *nntp_select_server(struct Mailbox *m, char *server, bool
 
   /* try to create cache directory and enable caching */
   adata->cacheable = false;
-  if ((rc >= 0) && C_NewsCacheDir && *C_NewsCacheDir)
+  if ((rc >= 0) && C_NewsCacheDir)
   {
     cache_expand(file, sizeof(file), &conn->account, NULL);
     if (mutt_file_mkdir(file, S_IRWXU) < 0)
index 101d440980713d40e3c13cd7340f1cf4fb44965a..14f9b6dd90d002f45f21ae110c1a25273cb7d00e 100644 (file)
@@ -535,7 +535,7 @@ static int nntp_auth(struct NntpAccountData *adata)
     }
 
     /* get list of authenticators */
-    if (C_NntpAuthenticators && *C_NntpAuthenticators)
+    if (C_NntpAuthenticators)
       mutt_str_strfcpy(authenticators, C_NntpAuthenticators, sizeof(authenticators));
     else if (adata->hasCAPABILITIES)
     {
index 319d85dd35484536ed77e029b2a70fe99c1a5e2a..7218df1460190904da2d4dbbc1d15d6607438782 100644 (file)
@@ -558,7 +558,7 @@ static int get_limit(struct NmMboxData *mdata)
  */
 static void apply_exclude_tags(notmuch_query_t *query)
 {
-  if (!C_NmExcludeTags || !query || !*C_NmExcludeTags)
+  if (!C_NmExcludeTags || !query)
     return;
 
   char *end = NULL, *tag = NULL;
index 2267bca6eba18bb6d01d1d2e4e086587e0a22f4a..f0fd962604d81533b4f7898338f732780394a330 100644 (file)
@@ -341,7 +341,7 @@ static enum PopAuthRes pop_auth_user(struct PopAccountData *adata, const char *m
 static enum PopAuthRes pop_auth_oauth(struct PopAccountData *adata, const char *method)
 {
   /* If they did not explicitly request or configure oauth then fail quietly */
-  if (!(method || (C_PopOauthRefreshCommand && *C_PopOauthRefreshCommand)))
+  if (!method && !C_PopOauthRefreshCommand)
     return POP_A_UNAVAIL;
 
   mutt_message(_("Authenticating (OAUTHBEARER)..."));
@@ -421,7 +421,7 @@ int pop_authenticate(struct PopAccountData *adata)
     return -3;
   }
 
-  if (C_PopAuthenticators && *C_PopAuthenticators)
+  if (C_PopAuthenticators)
   {
     /* Try user-specified list of authentication methods */
     methods = mutt_str_strdup(C_PopAuthenticators);
diff --git a/send.c b/send.c
index 09a5325c6aa22cdaf85bbf3ea6058ce567ea4778..6f82cc1a49e47d58172b1be9e5eb056b6a60da4c 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1753,7 +1753,7 @@ static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, Sen
   char *encrypt_as = NULL;
   struct Body *clear_content = NULL;
 
-  if (!(C_Postponed && *C_Postponed))
+  if (!C_Postponed)
   {
     mutt_error(_("Can't postpone.  $postponed is unset"));
     return -1;
index f8925a09128608d1cf15842ee03f92ff1cfc44e1..216726cff9c512d82bd74adf32894f4895e97d4a 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1034,9 +1034,7 @@ struct Content *mutt_get_content_info(const char *fname, struct Body *b)
   if (b && (b->type == TYPE_TEXT) && (!b->noconv && !b->force_charset))
   {
     char *chs = mutt_param_get(&b->parameter, "charset");
-    char *fchs = b->use_disp ?
-                     ((C_AttachCharset && *C_AttachCharset) ? C_AttachCharset : C_Charset) :
-                     C_Charset;
+    char *fchs = b->use_disp ? (C_AttachCharset ? C_AttachCharset : C_Charset) : C_Charset;
     if (C_Charset && (chs || C_SendCharset) &&
         (convert_file_from_to(fp, fchs, chs ? chs : C_SendCharset, &fromcode,
                               &tocode, info) != (size_t)(-1)))
@@ -1614,7 +1612,7 @@ struct Body *mutt_make_file_attach(const char *path)
   struct Body *att = mutt_body_new();
   att->filename = mutt_str_strdup(path);
 
-  if (C_MimeTypeQueryCommand && *C_MimeTypeQueryCommand && C_MimeTypeQueryFirst)
+  if (C_MimeTypeQueryCommand && C_MimeTypeQueryFirst)
     run_mime_type_query(att);
 
   /* Attempt to determine the appropriate content-type based on the filename
@@ -1622,7 +1620,7 @@ struct Body *mutt_make_file_attach(const char *path)
   if (!att->subtype)
     mutt_lookup_mime_type(att, path);
 
-  if (!att->subtype && C_MimeTypeQueryCommand && *C_MimeTypeQueryCommand && !C_MimeTypeQueryFirst)
+  if (!att->subtype && C_MimeTypeQueryCommand && !C_MimeTypeQueryFirst)
   {
     run_mime_type_query(att);
   }
@@ -3244,7 +3242,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid,
     if (e->security & SEC_SIGN)
     {
       fputc('S', msg->fp);
-      if (C_PgpSignAs && *C_PgpSignAs)
+      if (C_PgpSignAs)
         fprintf(msg->fp, "<%s>", C_PgpSignAs);
     }
     if (e->security & SEC_INLINE)
@@ -3259,7 +3257,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid,
     if (e->security & SEC_ENCRYPT)
     {
       fputc('E', msg->fp);
-      if (C_SmimeEncryptWith && *C_SmimeEncryptWith)
+      if (C_SmimeEncryptWith)
         fprintf(msg->fp, "C<%s>", C_SmimeEncryptWith);
     }
     if (e->security & SEC_OPPENCRYPT)
@@ -3267,7 +3265,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid,
     if (e->security & SEC_SIGN)
     {
       fputc('S', msg->fp);
-      if (C_SmimeSignAs && *C_SmimeSignAs)
+      if (C_SmimeSignAs)
         fprintf(msg->fp, "<%s>", C_SmimeSignAs);
     }
     if (e->security & SEC_INLINE)
diff --git a/smtp.c b/smtp.c
index 75f56ba04b31fd1869f04eab94582ec7734c9d27..2c5c5ff47dce51c69e19a1696f49acfd05bd3343 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -586,7 +586,7 @@ static int smtp_auth(struct Connection *conn)
 {
   int r = SMTP_AUTH_UNAVAIL;
 
-  if (C_SmtpAuthenticators && *C_SmtpAuthenticators)
+  if (C_SmtpAuthenticators)
   {
     char *methods = mutt_str_strdup(C_SmtpAuthenticators);
     char *method = NULL;