From: Thomas Roessler Date: Mon, 12 Jul 2004 13:22:24 +0000 (+0000) Subject: Add some debugging code, and rewrite the previously-ununderstandable X-Git-Tag: mutt-1-5-15-rel~162 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae44053edadf7385312983611ef902600d3593b8;p=mutt Add some debugging code, and rewrite the previously-ununderstandable mutt_remove_duplicates. (All this done on the search for a problem that ultimately turned out to be a configuration issue. Still, the changed code could come in handy some day.) --- diff --git a/init.c b/init.c index 3d1c13a0..764c23ed 100644 --- a/init.c +++ b/init.c @@ -614,6 +614,9 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) mutt_extract_token (buf, s, 0); + dprint (2, (debugfile, "parse_alias: First token is '%s'.\n", + buf->data)); + /* check to see if an alias with this name already exists */ for (; tmp; tmp = tmp->next) { @@ -641,6 +644,8 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) } mutt_extract_token (buf, s, M_TOKEN_QUOTE | M_TOKEN_SPACE | M_TOKEN_SEMICOLON); + dprint (2, (debugfile, "parse_alias: Second token is '%s'.\n", + buf->data)); tmp->addr = mutt_parse_adrlist (tmp->addr, buf->data); if (last) last->next = tmp; @@ -652,6 +657,21 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) estr, tmp->name); return -1; } +#ifdef DEBUG + if (debuglevel >= 2) + { + ADDRESS *a; + for (a = tmp->addr; a; a = a->next) + { + if (!a->group) + dprint (2, (debugfile, "parse_alias: %s\n", + a->mailbox)); + else + dprint (2, (debugfile, "parse_alias: Group %s\n", + a->mailbox)); + } + } +#endif return 0; } @@ -1370,6 +1390,9 @@ static int source_rc (const char *rcfile, BUFFER *err) size_t buflen; pid_t pid; + dprint (2, (debugfile, "Reading configuration file '%s'.\n", + rcfile)); + if ((f = mutt_open_read (rcfile, &pid)) == NULL) { snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno)); diff --git a/sendlib.c b/sendlib.c index 54b9e54e..f273e26f 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2277,40 +2277,42 @@ int mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to) /* given a list of addresses, return a list of unique addresses */ ADDRESS *mutt_remove_duplicates (ADDRESS *addr) { - ADDRESS *top = NULL; + ADDRESS *top = addr; + ADDRESS **last = ⊤ ADDRESS *tmp; - - if ((top = addr) == NULL) - return (NULL); - addr = addr->next; - top->next = NULL; + int dup; + while (addr) { - tmp = top; - do { - if (addr->mailbox && tmp->mailbox && + for (tmp = top, dup = 0; tmp && tmp != addr; tmp = tmp->next) + { + if (tmp->mailbox && addr->mailbox && !ascii_strcasecmp (addr->mailbox, tmp->mailbox)) { - /* duplicate address, just ignore it */ - tmp = addr; - addr = addr->next; - tmp->next = NULL; - rfc822_free_address (&tmp); - } - else if (!tmp->next) - { - /* unique address. add it to the list */ - tmp->next = addr; - addr = addr->next; - tmp = tmp->next; - tmp->next = NULL; - tmp = NULL; /* so we exit the loop */ + dup = 1; + break; } - else - tmp = tmp->next; - } while (tmp); - } + } + + if (dup) + { + dprint (2, (debugfile, "mutt_remove_duplicates: Removing %s\n", + addr->mailbox)); + + *last = addr->next; + addr->next = NULL; + rfc822_free_address(&addr); + + addr = *last; + } + else + { + last = &addr->next; + addr = addr->next; + } + } + return (top); }