From: Pietro Cerutti Date: Fri, 30 Aug 2019 12:11:41 +0000 (+0000) Subject: Use mutt_buffer_is_empty instead of mutt_buffer_len where it makes sense X-Git-Tag: 2019-10-25~64^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F1817%2Fhead;p=neomutt Use mutt_buffer_is_empty instead of mutt_buffer_len where it makes sense --- diff --git a/autocrypt/autocrypt.c b/autocrypt/autocrypt.c index f8ca0a684..ede2a8fd4 100644 --- a/autocrypt/autocrypt.c +++ b/autocrypt/autocrypt.c @@ -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)); diff --git a/curs_lib.c b/curs_lib.c index c027cd416..fac2d4fe2 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -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(); diff --git a/email/envelope.c b/email/envelope.c index d89332dc5..e6551471b 100644 --- a/email/envelope.c +++ b/email/envelope.c @@ -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); \ diff --git a/email/parse.c b/email/parse.c index 4ccce4964..082ec529a 100644 --- a/email/parse.c +++ b/email/parse.c @@ -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); } } diff --git a/hdrline.c b/hdrline.c index 996d93418..2f3b9aef2 100644 --- 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; diff --git a/imap/command.c b/imap/command.c index 084847983..49ceadc2c 100644 --- a/imap/command.c +++ b/imap/command.c @@ -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 b20266d2c..2ab5a4835 100644 --- 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) { diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index ce1463285..97e3b4405 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -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; diff --git a/pop/pop_lib.c b/pop/pop_lib.c index a26df64cb..02ab4fecc 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -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 fb5c41b69..ca5fd94a6 100644 --- 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) diff --git a/test/buffer/mutt_buffer_fix_dptr.c b/test/buffer/mutt_buffer_fix_dptr.c index 285a4665c..e00a5bb2f 100644 --- a/test/buffer/mutt_buffer_fix_dptr.c +++ b/test/buffer/mutt_buffer_fix_dptr.c @@ -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)); } {