From: Richard Russon Date: Wed, 29 Nov 2017 00:13:59 +0000 (+0000) Subject: minor tidying/boolification X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25d8959bf8eda602e1225e65c94e3a473bc4697b;p=neomutt minor tidying/boolification --- diff --git a/address.c b/address.c index 4b58b0b48..07421c672 100644 --- a/address.c +++ b/address.c @@ -104,11 +104,13 @@ struct Address *mutt_addr_new(void) * * @note This doesn't alter the links if the Address is in a list. */ -static void free_address(struct Address *a) +static void free_address(struct Address **a) { - FREE(&a->personal); - FREE(&a->mailbox); - FREE(&a); + if (!a || !*a) + return; + FREE(&(*a)->personal); + FREE(&(*a)->mailbox); + FREE(&(*a)); } /** @@ -135,7 +137,7 @@ int mutt_addr_remove_from_list(struct Address **a, const char *mailbox) (*a) = p->next; t = p; p = p->next; - free_address(t); + free_address(&t); rc = 0; } else @@ -160,9 +162,7 @@ void mutt_addr_free(struct Address **p) { t = *p; *p = (*p)->next; - FREE(&t->personal); - FREE(&t->mailbox); - FREE(&t); + free_address(&t); } } @@ -757,7 +757,7 @@ struct Address *mutt_addr_copy(struct Address *addr) * @param prune Skip groups if there are more addresses * @retval ptr New Address list */ -struct Address *mutt_addr_copy_list(struct Address *addr, int prune) +struct Address *mutt_addr_copy_list(struct Address *addr, bool prune) { struct Address *top = NULL, *last = NULL; @@ -787,7 +787,7 @@ struct Address *mutt_addr_copy_list(struct Address *addr, int prune) * * Append the Source onto the end of the Destination Address list. */ -struct Address *mutt_addr_append(struct Address **a, struct Address *b, int prune) +struct Address *mutt_addr_append(struct Address **a, struct Address *b, bool prune) { struct Address *tmp = *a; @@ -861,23 +861,23 @@ bool mutt_addr_valid_msgid(const char *msgid) * @param b Second Address * @retval true Address lists are strictly identical */ -int mutt_addr_cmp_strict(const struct Address *a, const struct Address *b) +bool mutt_addr_cmp_strict(const struct Address *a, const struct Address *b) { while (a && b) { if ((mutt_str_strcmp(a->mailbox, b->mailbox) != 0) || (mutt_str_strcmp(a->personal, b->personal) != 0)) { - return 0; + return false; } a = a->next; b = b->next; } if (a || b) - return 0; + return false; - return 1; + return true; } /** @@ -921,12 +921,12 @@ bool mutt_addr_cmp(struct Address *a, struct Address *b) * @param lst Address List * @retval true If the Address is in the list */ -int mutt_addr_search(struct Address *a, struct Address *lst) +bool mutt_addr_search(struct Address *a, struct Address *lst) { for (; lst; lst = lst->next) { if (mutt_addr_cmp(a, lst)) - return 1; + return true; } - return 0; + return false; } diff --git a/address.h b/address.h index e0f8a8f1d..67f62e0da 100644 --- a/address.h +++ b/address.h @@ -57,11 +57,11 @@ extern const char AddressSpecials[]; #define address_error(x) AddressErrors[x] -struct Address *mutt_addr_append(struct Address **a, struct Address *b, int prune); +struct Address *mutt_addr_append(struct Address **a, struct Address *b, bool prune); void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials); -int mutt_addr_cmp_strict(const struct Address *a, const struct Address *b); +bool mutt_addr_cmp_strict(const struct Address *a, const struct Address *b); bool mutt_addr_cmp(struct Address *a, struct Address *b); -struct Address *mutt_addr_copy_list(struct Address *addr, int prune); +struct Address *mutt_addr_copy_list(struct Address *addr, bool prune); struct Address *mutt_addr_copy(struct Address *addr); void mutt_addr_free(struct Address **p); int mutt_addr_has_recips(struct Address *a); @@ -70,7 +70,7 @@ struct Address *mutt_addr_parse_list2(struct Address *p, const char *s); struct Address *mutt_addr_parse_list(struct Address *top, const char *s); void mutt_addr_qualify(struct Address *addr, const char *host); int mutt_addr_remove_from_list(struct Address **a, const char *mailbox); -int mutt_addr_search(struct Address *a, struct Address *lst); +bool mutt_addr_search(struct Address *a, struct Address *lst); bool mutt_addr_valid_msgid(const char *msgid); #endif /* _MUTT_ADDRESS_H */ diff --git a/alias.c b/alias.c index 9a0bf1457..cb333d4d7 100644 --- a/alias.c +++ b/alias.c @@ -83,7 +83,7 @@ static struct Address *expand_aliases_r(struct Address *a, struct ListHead *expn if (!i) { mutt_list_insert_head(expn, mutt_str_strdup(a->mailbox)); - w = mutt_addr_copy_list(t, 0); + w = mutt_addr_copy_list(t, false); w = expand_aliases_r(w, expn); if (head) last->next = w; diff --git a/group.c b/group.c index 01897218b..f0640e51b 100644 --- a/group.c +++ b/group.c @@ -113,7 +113,7 @@ static void group_add_adrlist(struct Group *g, struct Address *a) for (p = &g->as; *p; p = &((*p)->next)) ; - q = mutt_addr_copy_list(a, 0); + q = mutt_addr_copy_list(a, false); q = mutt_remove_xrefs(g->as, q); *p = q; } diff --git a/main.c b/main.c index b6b2d31d9..dc7df58b4 100644 --- a/main.c +++ b/main.c @@ -728,9 +728,9 @@ int main(int argc, char **argv, char **env) } } - mutt_addr_append(&msg->env->to, opts_env->to, 0); - mutt_addr_append(&msg->env->cc, opts_env->cc, 0); - mutt_addr_append(&msg->env->bcc, opts_env->bcc, 0); + mutt_addr_append(&msg->env->to, opts_env->to, false); + mutt_addr_append(&msg->env->cc, opts_env->cc, false); + mutt_addr_append(&msg->env->bcc, opts_env->bcc, false); if (opts_env->subject) mutt_str_replace(&msg->env->subject, opts_env->subject); diff --git a/mbox.c b/mbox.c index efe5d1250..b935d152c 100644 --- a/mbox.c +++ b/mbox.c @@ -219,7 +219,7 @@ static int mmdf_parse_mailbox(struct Context *ctx) hdr->env->return_path = mutt_addr_parse_list(hdr->env->return_path, return_path); if (!hdr->env->from) - hdr->env->from = mutt_addr_copy_list(hdr->env->return_path, 0); + hdr->env->from = mutt_addr_copy_list(hdr->env->return_path, false); ctx->msgcount++; } @@ -391,7 +391,7 @@ static int mbox_parse_mailbox(struct Context *ctx) mutt_addr_parse_list(curhdr->env->return_path, return_path); if (!curhdr->env->from) - curhdr->env->from = mutt_addr_copy_list(curhdr->env->return_path, 0); + curhdr->env->from = mutt_addr_copy_list(curhdr->env->return_path, false); lines = 0; } diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 43735dd8b..f163d3d22 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -853,9 +853,9 @@ int crypt_get_keys(struct Header *msg, char **keylist, int oppenc_mode) if ((WithCrypto & APPLICATION_PGP)) set_option(OPT_PGP_CHECK_TRUST); - last = mutt_addr_append(&adrlist, msg->env->to, 0); - last = mutt_addr_append(last ? &last : &adrlist, msg->env->cc, 0); - mutt_addr_append(last ? &last : &adrlist, msg->env->bcc, 0); + last = mutt_addr_append(&adrlist, msg->env->to, false); + last = mutt_addr_append(last ? &last : &adrlist, msg->env->cc, false); + mutt_addr_append(last ? &last : &adrlist, msg->env->bcc, false); if (fqdn) mutt_addr_qualify(adrlist, fqdn); diff --git a/query.c b/query.c index f43f50554..d96647834 100644 --- a/query.c +++ b/query.c @@ -81,7 +81,7 @@ static struct Address *result_to_addr(struct Query *r) { static struct Address *tmp = NULL; - tmp = mutt_addr_copy_list(r->addr, 0); + tmp = mutt_addr_copy_list(r->addr, false); if (!tmp) return NULL; @@ -438,7 +438,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb if (QueryTable[i].tagged) { struct Address *a = result_to_addr(QueryTable[i].data); - mutt_addr_append(&naddr, a, 0); + mutt_addr_append(&naddr, a, false); mutt_addr_free(&a); } } @@ -474,7 +474,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb if (QueryTable[i].tagged) { struct Address *a = result_to_addr(QueryTable[i].data); - mutt_addr_append(&msg->env->to, a, 0); + mutt_addr_append(&msg->env->to, a, false); mutt_addr_free(&a); } } diff --git a/send.c b/send.c index 911273ef3..749d98a31 100644 --- a/send.c +++ b/send.c @@ -510,7 +510,7 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int if (flags && env->mail_followup_to && hmfupto == MUTT_YES) { - mutt_addr_append(to, env->mail_followup_to, 1); + mutt_addr_append(to, env->mail_followup_to, true); return 0; } @@ -523,7 +523,7 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int if (!option(OPT_REPLY_SELF) && mutt_addr_is_user(env->from)) { /* mail is from the user, assume replying to recipients */ - mutt_addr_append(to, env->to, 1); + mutt_addr_append(to, env->to, true); } else if (env->reply_to) { @@ -541,7 +541,7 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int * in his From header, and the reply-to has no display-name. * */ - mutt_addr_append(to, env->from, 0); + mutt_addr_append(to, env->from, false); } else if (!(mutt_addr_cmp(env->from, env->reply_to) && !env->reply_to->next) && quadoption(OPT_REPLY_TO) != MUTT_YES) @@ -559,11 +559,11 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int switch (query_quadoption(OPT_REPLY_TO, prompt)) { case MUTT_YES: - mutt_addr_append(to, env->reply_to, 0); + mutt_addr_append(to, env->reply_to, false); break; case MUTT_NO: - mutt_addr_append(to, env->from, 0); + mutt_addr_append(to, env->from, false); break; default: @@ -571,10 +571,10 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int } } else - mutt_addr_append(to, env->reply_to, 0); + mutt_addr_append(to, env->reply_to, false); } else - mutt_addr_append(to, env->from, 0); + mutt_addr_append(to, env->from, false); return 0; } @@ -599,7 +599,7 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags) if (flags & SENDLISTREPLY) { tmp = find_mailing_lists(in->to, in->cc); - mutt_addr_append(&out->to, tmp, 0); + mutt_addr_append(&out->to, tmp, false); mutt_addr_free(&tmp); if (in->mail_followup_to && hmfupto == MUTT_YES && @@ -616,8 +616,8 @@ int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags) if ((flags & SENDGROUPREPLY) && (!in->mail_followup_to || hmfupto != MUTT_YES)) { /* if(!mutt_addr_is_user(in->to)) */ - mutt_addr_append(&out->cc, in->to, 1); - mutt_addr_append(&out->cc, in->cc, 1); + mutt_addr_append(&out->cc, in->to, true); + mutt_addr_append(&out->cc, in->cc, true); } } return 0; @@ -961,8 +961,8 @@ void mutt_set_followup_to(struct Envelope *e) * mail-followup-to header */ - t = mutt_addr_append(&e->mail_followup_to, e->to, 0); - mutt_addr_append(&t, e->cc, 1); + t = mutt_addr_append(&e->mail_followup_to, e->to, false); + mutt_addr_append(&t, e->cc, true); } /* remove ourselves from the mail-followup-to header */ @@ -978,9 +978,9 @@ void mutt_set_followup_to(struct Envelope *e) if (e->mail_followup_to && !mutt_is_list_recipient(0, e->to, e->cc)) { if (e->reply_to) - from = mutt_addr_copy_list(e->reply_to, 0); + from = mutt_addr_copy_list(e->reply_to, false); else if (e->from) - from = mutt_addr_copy_list(e->from, 0); + from = mutt_addr_copy_list(e->from, false); else from = mutt_default_from(); @@ -1189,11 +1189,11 @@ int mutt_compose_to_sender(struct Header *hdr) for (int i = 0; i < Context->msgcount; i++) { if (message_is_tagged(Context, i)) - mutt_addr_append(&msg->env->to, Context->hdrs[i]->env->from, 0); + mutt_addr_append(&msg->env->to, Context->hdrs[i]->env->from, false); } } else - msg->env->to = mutt_addr_copy_list(hdr->env->from, 0); + msg->env->to = mutt_addr_copy_list(hdr->env->from, false); return ci_send_message(0, msg, NULL, NULL, NULL); } diff --git a/sendlib.c b/sendlib.c index c36cef976..19df360cb 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2821,7 +2821,7 @@ int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to) * function is called, since the user receives confirmation of the address * list being bounced to. */ - resent_to = mutt_addr_copy_list(to, 0); + resent_to = mutt_addr_copy_list(to, false); rfc2047_encode_adrlist(resent_to, "Resent-To"); ret = bounce_message(fp, h, resent_to, resent_from, from);