]> granicus.if.org Git - neomutt/commitdiff
Use mutt_buffer_is_empty instead of mutt_buffer_len where it makes sense 1817/head
authorPietro Cerutti <gahr@gahr.ch>
Fri, 30 Aug 2019 12:11:41 +0000 (12:11 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 31 Aug 2019 00:51:11 +0000 (01:51 +0100)
autocrypt/autocrypt.c
curs_lib.c
email/envelope.c
email/parse.c
hdrline.c
imap/command.c
main.c
ncrypt/crypt_gpgme.c
pop/pop_lib.c
sort.c
test/buffer/mutt_buffer_fix_dptr.c

index f8ca0a684c44c852a9ea779ff0e7b9ed1cf5e756..ede2a8fd4af0a360eee569ea2f8ffcd8b5d7e1d5 100644 (file)
@@ -641,7 +641,7 @@ enum AutocryptRec mutt_autocrypt_ui_recommendation(struct Email *e, char **keyli
       goto cleanup;
     }
 
-    if (mutt_buffer_len(keylist_buf) > 0)
+    if (!mutt_buffer_is_empty(keylist_buf))
       mutt_buffer_addch(keylist_buf, ' ');
     mutt_buffer_addstr(keylist_buf, matching_key);
 
@@ -906,7 +906,7 @@ void mutt_autocrypt_scan_mailboxes(void)
   {
     // L10N: The prompt for a mailbox to scan for Autocrypt: headers
     if ((!mutt_buffer_enter_fname(_("Scan mailbox"), folderbuf, true)) &&
-        (mutt_buffer_len(folderbuf) > 0))
+        (!mutt_buffer_is_empty(folderbuf)))
     {
       mutt_buffer_expand_path_regex(folderbuf, false);
       struct Mailbox *m = mx_path_resolve(mutt_b2s(folderbuf));
index c027cd416060055c1d3e68917291c8c837786798..fac2d4fe2b04b54e23429c0db8d96f883f410e57 100644 (file)
@@ -655,7 +655,7 @@ int mutt_buffer_enter_fname_full(const char *prompt, struct Buffer *fname,
   mutt_window_mvaddstr(MuttMessageWindow, 0, 0, prompt);
   addstr(_(" ('?' for list): "));
   NORMAL_COLOR;
-  if (mutt_buffer_len(fname))
+  if (!mutt_buffer_is_empty(fname))
     addstr(mutt_b2s(fname));
   mutt_window_clrtoeol(MuttMessageWindow);
   mutt_refresh();
index d89332dc537c506ba68fea22e33e5067cd32e4e3..e6551471bc333d6a22314c8853428e56144781bc 100644 (file)
@@ -164,7 +164,7 @@ void mutt_env_merge(struct Envelope *base, struct Envelope **extra)
   }
 
 #define MOVE_BUFFER(member)                                                    \
-  if (mutt_buffer_len(&base->member) == 0)                                     \
+  if (mutt_buffer_is_empty(&base->member))                                     \
   {                                                                            \
     memcpy(&base->member, &(*extra)->member, sizeof(struct Buffer));           \
     mutt_buffer_init(&(*extra)->member);                                       \
index 4ccce4964933bb74bf82cc444e52d9132f812475..082ec529ad83a15e495363e2363613eb5a032593 100644 (file)
@@ -1187,7 +1187,7 @@ struct Envelope *mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hd
       if (!mutt_regexlist_match(&NoSpamList, line))
       {
         /* if spam tag already exists, figure out how to amend it */
-        if ((mutt_buffer_len(&env->spam) != 0) && (*buf != '\0'))
+        if ((!mutt_buffer_is_empty(&env->spam)) && (*buf != '\0'))
         {
           /* If C_SpamSeparator defined, append with separator */
           if (C_SpamSeparator)
@@ -1203,18 +1203,18 @@ struct Envelope *mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hd
         }
 
         /* spam tag is new, and match expr is non-empty; copy */
-        else if ((mutt_buffer_len(&env->spam) == 0) && (*buf != '\0'))
+        else if (mutt_buffer_is_empty(&env->spam) && (*buf != '\0'))
         {
           mutt_buffer_addstr(&env->spam, buf);
         }
 
         /* match expr is empty; plug in null string if no existing tag */
-        else if (mutt_buffer_len(&env->spam) == 0)
+        else if (mutt_buffer_is_empty(&env->spam))
         {
           mutt_buffer_addstr(&env->spam, "");
         }
 
-        if (mutt_buffer_len(&env->spam) != 0)
+        if (!mutt_buffer_is_empty(&env->spam))
           mutt_debug(LL_DEBUG5, "spam = %s\n", env->spam.data);
       }
     }
index 996d9341898b7c8e0915ae40e097d142d8f6fcc6..2f3b9aef22111117a77a1b9e2076c6cf471ed212 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -955,7 +955,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
     case 'H':
       /* (Hormel) spam score */
       if (optional)
-        optional = mutt_buffer_len(&e->env->spam) != 0;
+        optional = !mutt_buffer_is_empty(&e->env->spam);
 
       mutt_format_s(buf, buflen, prec, mutt_b2s(&e->env->spam));
       break;
index 08484798320c6212b50d7783199d17d91aa7e96b..49ceadc2cdfea094c9020972e5df26c61bed12f1 100644 (file)
@@ -201,7 +201,7 @@ static int cmd_start(struct ImapAccountData *adata, const char *cmdstr, ImapCmdF
   if (flags & IMAP_CMD_QUEUE)
     return 0;
 
-  if (mutt_buffer_len(&adata->cmdbuf) == 0)
+  if (mutt_buffer_is_empty(&adata->cmdbuf))
     return IMAP_RES_BAD;
 
   rc = mutt_socket_send_d(adata->conn, adata->cmdbuf.data,
diff --git a/main.c b/main.c
index b20266d2c026d429589dc327a9aadb6bef330c54..2ab5a483510c62b89612d434ae73620290f82128 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1173,13 +1173,13 @@ int main(int argc, char *argv[], char *envp[])
       }
       mutt_buffer_reset(&folder);
       mutt_buffer_select_file(&folder, MUTT_SEL_FOLDER | MUTT_SEL_MAILBOX, NULL, NULL);
-      if (mutt_buffer_len(&folder) == 0)
+      if (mutt_buffer_is_empty(&folder))
       {
         goto main_ok; // TEST40: neomutt -y (quit selection)
       }
     }
 
-    if (mutt_buffer_len(&folder) == 0)
+    if (mutt_buffer_is_empty(&folder))
     {
       if (C_Spoolfile)
       {
index ce1463285730285b94dd3fa2e4901e0ae704e1d5..97e3b4405af67db11968cb9a91f211661d7e0048 100644 (file)
@@ -1265,7 +1265,7 @@ static char *encrypt_gpgme_object(gpgme_data_t plaintext, char *keylist,
 #if GPGME_VERSION_NUMBER >= 0x010b00 /* gpgme >= 1.11.0 */
   struct Buffer *recpstring = mutt_buffer_pool_get();
   create_recipient_string(keylist, recpstring, use_smime);
-  if (mutt_buffer_len(recpstring) == 0)
+  if (mutt_buffer_is_empty(recpstring))
   {
     mutt_buffer_pool_release(&recpstring);
     return NULL;
index a26df64cb40362bddf71dde49a47c37861ef6ef3..02ab4fecc852bdabecd0a42a037b2b17b701a260 100644 (file)
@@ -158,7 +158,7 @@ static int fetch_auth(const char *line, void *data)
 {
   struct PopAccountData *adata = data;
 
-  if (mutt_buffer_len(&adata->auth_list) != 0)
+  if (!mutt_buffer_is_empty(&adata->auth_list))
   {
     mutt_buffer_addstr(&adata->auth_list, " ");
   }
diff --git a/sort.c b/sort.c
index fb5c41b693c5e86169af443fc7c7915607e309fd..ca5fd94a66560964aaa29d06875904224f19a9ac 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -239,8 +239,8 @@ static int compare_spam(const void *a, const void *b)
 
   /* Firstly, require spam attributes for both msgs */
   /* to compare. Determine which msgs have one.     */
-  ahas = (*ppa)->env && mutt_buffer_len(&(*ppa)->env->spam) != 0;
-  bhas = (*ppb)->env && mutt_buffer_len(&(*ppb)->env->spam) != 0;
+  ahas = (*ppa)->env && !mutt_buffer_is_empty(&(*ppa)->env->spam);
+  bhas = (*ppb)->env && !mutt_buffer_is_empty(&(*ppb)->env->spam);
 
   /* If one msg has spam attr but other does not, sort the one with first. */
   if (ahas && !bhas)
index 285a4665c4ec30b5d931d09f60e54b762ad79ba7..e00a5bb2f2198b33f876b2cb5a56d1ad3be61d26 100644 (file)
@@ -37,7 +37,7 @@ void test_mutt_buffer_fix_dptr(void)
   {
     struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_fix_dptr(&buf);
-    TEST_CHECK(mutt_buffer_len(&buf) == 0);
+    TEST_CHECK(mutt_buffer_is_empty(&buf));
   }
 
   {