}
/**
- * mutt_addr_cmp_strict - Strictly compare two Address lists
+ * mutt_addresslist_equal - Compare two Address lists for equality
* @param a First Address
* @param b Second Address
* @retval true Address lists are strictly identical
*/
-bool mutt_addresslist_cmp_strict(const struct AddressList *ala, const struct AddressList *alb)
+bool mutt_addresslist_equal(const struct AddressList *ala, const struct AddressList *alb)
{
+ if (!ala || !alb)
+ {
+ return !(ala || alb);
+ }
+
struct AddressNode *ana = TAILQ_FIRST(ala);
struct AddressNode *anb = TAILQ_FIRST(alb);
return !(ana || anb);
}
-bool mutt_addr_cmp_strict(const struct Address *a, const struct Address *b)
-{
- struct AddressList *ala = mutt_addr_to_addresslist((struct Address *) a);
- struct AddressList *alb = mutt_addr_to_addresslist((struct Address *) b);
- bool res = mutt_addresslist_cmp_strict(ala, alb);
- FREE(&ala);
- FREE(&alb);
- return res;
-}
/**
* mutt_addresslist_has_recips - Count the number of Addresses with valid recipients
void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials);
bool mutt_addr_cmp(const struct Address *a, const struct Address *b);
-bool mutt_addr_cmp_strict(const struct Address *a, const struct Address *b);
+
+
+
struct Address *mutt_addr_copy(const struct Address *addr);
const char * mutt_addr_for_display(const struct Address *a);
void mutt_addr_free(struct Address **p);
struct Address* mutt_addresslist_first(const struct AddressList *al);
bool mutt_addresslist_search(const struct Address *needle, const struct AddressList *haystack);
int mutt_addresslist_has_recips(const struct AddressList *al);
-bool mutt_addresslist_cmp_strict(const struct AddressList *ala, const struct AddressList *alb);
+bool mutt_addresslist_equal(const struct AddressList *ala, const struct AddressList *alb);
#endif /* MUTT_EMAIL_ADDRESS_H */
if ((mutt_str_strcmp(e1->message_id, e2->message_id) != 0) ||
(mutt_str_strcmp(e1->subject, e2->subject) != 0) ||
!mutt_list_compare(&e1->references, &e2->references) ||
- !mutt_addresslist_cmp_strict(&e1->from, &e2->from) ||
- !mutt_addresslist_cmp_strict(&e1->sender, &e2->sender) ||
- !mutt_addresslist_cmp_strict(&e1->reply_to, &e2->reply_to) ||
- !mutt_addresslist_cmp_strict(&e1->to, &e2->to) ||
- !mutt_addresslist_cmp_strict(&e1->cc, &e2->cc) ||
- !mutt_addresslist_cmp_strict(&e1->return_path, &e2->return_path))
+ !mutt_addresslist_equal(&e1->from, &e2->from) ||
+ !mutt_addresslist_equal(&e1->sender, &e2->sender) ||
+ !mutt_addresslist_equal(&e1->reply_to, &e2->reply_to) ||
+ !mutt_addresslist_equal(&e1->to, &e2->to) ||
+ !mutt_addresslist_equal(&e1->cc, &e2->cc) ||
+ !mutt_addresslist_equal(&e1->return_path, &e2->return_path))
{
return false;
}
ADDRESS_OBJS = test/address/mutt_addr_append.o \
test/address/mutt_addr_cat.o \
test/address/mutt_addr_cmp.o \
- test/address/mutt_addr_cmp_strict.o \
test/address/mutt_addr_copy.o \
test/address/mutt_addr_copy_list.o \
test/address/mutt_addr_for_display.o \
test/address/mutt_addr_has_recips.o \
test/address/mutt_addr_is_intl.o \
test/address/mutt_addr_is_local.o \
+ test/address/mutt_addresslist_equal.o \
test/address/mutt_addrlist_dedupe.o \
test/address/mutt_addrlist_to_intl.o \
test/address/mutt_addrlist_to_local.o \
/**
* @file
- * Test code for mutt_addr_cmp_strict()
+ * Test code for mutt_addresslist_equal()
*
* @authors
* Copyright (C) 2019 Richard Russon <rich@flatcap.org>
#include "mutt/mutt.h"
#include "address/lib.h"
-void test_mutt_addr_cmp_strict(void)
+void test_mutt_addresslist_equal(void)
{
- // bool mutt_addr_cmp_strict(const struct Address *a, const struct Address *b);
+ // bool mutt_addresslist_equal(const struct AddressList *a, const struct AddressList *b);
{
- struct Address addr = { 0 };
- TEST_CHECK(!mutt_addr_cmp_strict(NULL, &addr));
+ struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
+ TEST_CHECK(!mutt_addresslist_equal(NULL, &al));
}
{
- struct Address addr = { 0 };
- TEST_CHECK(!mutt_addr_cmp_strict(&addr, NULL));
+ struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
+ TEST_CHECK(!mutt_addresslist_equal(&al, NULL));
}
}
NEOMUTT_TEST_ITEM(test_mutt_addr_append) \
NEOMUTT_TEST_ITEM(test_mutt_addr_cat) \
NEOMUTT_TEST_ITEM(test_mutt_addr_cmp) \
- NEOMUTT_TEST_ITEM(test_mutt_addr_cmp_strict) \
NEOMUTT_TEST_ITEM(test_mutt_addr_copy) \
NEOMUTT_TEST_ITEM(test_mutt_addr_copy_list) \
NEOMUTT_TEST_ITEM(test_mutt_addr_for_display) \
NEOMUTT_TEST_ITEM(test_mutt_addr_valid_msgid) \
NEOMUTT_TEST_ITEM(test_mutt_addr_write) \
NEOMUTT_TEST_ITEM(test_mutt_addr_write_single) \
+ NEOMUTT_TEST_ITEM(test_mutt_addresslist_equal) \
NEOMUTT_TEST_ITEM(test_mutt_addrlist_to_intl) \
NEOMUTT_TEST_ITEM(test_mutt_addrlist_to_local) \
NEOMUTT_TEST_ITEM(test_mutt_actx_add_attach) \