Commit 99f80efe 99f80efee8fdde2502b31bf913d2e4b679c7f0bb by Sergey Poznyakoff

(builtin_formataddr): Fixed checking for duplicate addresses.

1 parent d4d27428
......@@ -1723,6 +1723,9 @@ builtin_formataddr (struct mh_machine *mach)
{
address_t addr, dest;
size_t size;
int i;
size_t num;
char *buf;
if (strobj_len (&mach->reg_str) == 0)
dest = NULL;
......@@ -1735,38 +1738,27 @@ builtin_formataddr (struct mh_machine *mach)
return;
}
if (addrlist_lookup (mach->addrlist, addr))
{
address_destroy (&dest);
address_destroy (&addr);
return;
}
if (rcpt_mask & RCPT_ME)
address_union (&dest, addr);
else
{
int i;
size_t num;
char *buf;
address_get_count (addr, &num);
for (i = 1; i <= num; i++)
{
if (address_aget_email (addr, i, &buf) == 0)
{
if (!mh_is_my_name (buf))
if ((rcpt_mask & RCPT_ME) || !mh_is_my_name (buf))
{
address_t subaddr;
address_get_nth (addr, i, &subaddr);
if (!addrlist_lookup (mach->addrlist, subaddr))
{
list_append (mach->addrlist, subaddr);
address_union (&dest, subaddr);
}
else
address_destroy (&subaddr);
}
free (buf);
}
}
}
list_append (mach->addrlist, addr);
if (address_to_string (dest, NULL, 0, &size) == 0)
{
strobj_realloc (&mach->reg_str, size + 1);
......