various code simplifications.
authorPierre Habouzit <madcoder@debian.org>
Wed, 29 Nov 2006 01:10:17 +0000 (02:10 +0100)
committerPierre Habouzit <madcoder@debian.org>
Wed, 29 Nov 2006 01:10:17 +0000 (02:10 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
alias.c
lib-crypt/crypt-gpgme.c
lib-crypt/pgp.c
lib-crypt/smime.c
lib-mime/rfc822address.c
remailer.c
send.c
sendlib.c

diff --git a/alias.c b/alias.c
index 68afc25..8d48a78 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -355,9 +355,7 @@ static address_t *mutt_expand_aliases_r(address_t *a, string_list_t **expn)
 
     if (option(OPTUSEDOMAIN)) {
         /* now qualify all local addresses */
 
     if (option(OPTUSEDOMAIN)) {
         /* now qualify all local addresses */
-        const char *fqdn = mutt_fqdn(1);
-        if (fqdn)
-            rfc822_qualify(head, fqdn);
+        rfc822_qualify(head, mutt_fqdn(1));
     }
 
     return head;
     }
 
     return head;
index 7e3495b..9790164 100644 (file)
@@ -3649,9 +3649,7 @@ static char *find_keys (address_t * to, address_t * cc, address_t * bcc,
       last = &((*last)->next);
   }
 
       last = &((*last)->next);
   }
 
-  if (fqdn)
-    rfc822_qualify (tmp, fqdn);
-
+  rfc822_qualify(tmp, fqdn);
   address_list_uniq(tmp);
 
   for (p = tmp; p; p = p->next) {
   address_list_uniq(tmp);
 
   for (p = tmp; p; p = p->next) {
@@ -3670,8 +3668,7 @@ static char *find_keys (address_t * to, address_t * cc, address_t * bcc,
         /* check for e-mail address */
         if ((t = strchr (keyID, '@')) &&
             (addr = rfc822_parse_adrlist (NULL, keyID))) {
         /* check for e-mail address */
         if ((t = strchr (keyID, '@')) &&
             (addr = rfc822_parse_adrlist (NULL, keyID))) {
-          if (fqdn)
-            rfc822_qualify (addr, fqdn);
+          rfc822_qualify(addr, fqdn);
           q = addr;
         }
         else {
           q = addr;
         }
         else {
index 7a23728..c58664c 100644 (file)
@@ -1022,8 +1022,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc)
       last = &((*last)->next);
   }
 
       last = &((*last)->next);
   }
 
-  if (fqdn)
-    rfc822_qualify (tmp, fqdn);
+  rfc822_qualify (tmp, fqdn);
 
   address_list_uniq(tmp);
 
 
   address_list_uniq(tmp);
 
@@ -1048,8 +1047,7 @@ char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc)
         /* check for e-mail address */
         if ((t = strchr (keyID, '@')) &&
             (addr = rfc822_parse_adrlist (NULL, keyID))) {
         /* check for e-mail address */
         if ((t = strchr (keyID, '@')) &&
             (addr = rfc822_parse_adrlist (NULL, keyID))) {
-          if (fqdn)
-            rfc822_qualify (addr, fqdn);
+          rfc822_qualify (addr, fqdn);
           q = addr;
         }
         else
           q = addr;
         }
         else
index 1248f31..4a4f89c 100644 (file)
@@ -708,8 +708,6 @@ char *smime_findKeys (address_t * to, address_t * cc, address_t * bcc)
   address_t *p, *q;
   int i;
 
   address_t *p, *q;
   int i;
 
-  const char *fqdn = mutt_fqdn (1);
-
   for (i = 0; i < 3; i++) {
     switch (i) {
     case 0:
   for (i = 0; i < 3; i++) {
     switch (i) {
     case 0:
@@ -730,8 +728,7 @@ char *smime_findKeys (address_t * to, address_t * cc, address_t * bcc)
       last = &((*last)->next);
   }
 
       last = &((*last)->next);
   }
 
-  if (fqdn)
-    rfc822_qualify (tmp, fqdn);
+  rfc822_qualify(tmp, mutt_fqdn(1));
 
   address_list_uniq(tmp);
 
 
   address_list_uniq(tmp);
 
index ad4e117..36485d3 100644 (file)
 
 void rfc822_qualify(address_t *addr, const char *host)
 {
 
 void rfc822_qualify(address_t *addr, const char *host)
 {
-    char *p;
+    if (!host)
+        return;
 
     for (; addr; addr = addr->next) {
         if (!addr->group && addr->mailbox && !strchr(addr->mailbox, '@')) {
 
     for (; addr; addr = addr->next) {
         if (!addr->group && addr->mailbox && !strchr(addr->mailbox, '@')) {
-            p = p_new(char, m_strlen(addr->mailbox) + m_strlen(host) + 2);
+            char *p = p_new(char, m_strlen(addr->mailbox) + m_strlen(host) + 2);
             sprintf(p, "%s@%s", addr->mailbox, host);
             p_delete(&addr->mailbox);
             addr->mailbox = p;
             sprintf(p, "%s@%s", addr->mailbox, host);
             p_delete(&addr->mailbox);
             addr->mailbox = p;
index 226953d..b17ec82 100644 (file)
@@ -672,17 +672,16 @@ int mix_check_message (HEADER * msg)
 
     if (need_hostname) {
 
 
     if (need_hostname) {
 
-        if (!(fqdn = mutt_fqdn (1))) {
+        if (!(fqdn = mutt_fqdn(1))) {
             mutt_error
             mutt_error
-                _
-                ("Please set the hostname variable to a proper value when using mixmaster!");
-            return (-1);
+                _("Please set the hostname variable to a proper value when using mixmaster!");
+            return -1;
         }
 
         /* Cc and Bcc are empty at this point. */
         }
 
         /* Cc and Bcc are empty at this point. */
-        rfc822_qualify (msg->env->to, fqdn);
-        rfc822_qualify (msg->env->reply_to, fqdn);
-        rfc822_qualify (msg->env->mail_followup_to, fqdn);
+        rfc822_qualify(msg->env->to, fqdn);
+        rfc822_qualify(msg->env->reply_to, fqdn);
+        rfc822_qualify(msg->env->mail_followup_to, fqdn);
     }
 
     return 0;
     }
 
     return 0;
diff --git a/send.c b/send.c
index 1773589..f5ffa26 100644 (file)
--- a/send.c
+++ b/send.c
@@ -849,62 +849,59 @@ static int generate_body (FILE * tempfp,        /* stream for outgoing message *
 
 void mutt_set_followup_to (ENVELOPE * e)
 {
 
 void mutt_set_followup_to (ENVELOPE * e)
 {
-  address_t *from;
-
-  /* 
-   * Only generate the Mail-Followup-To if the user has requested it, and
-   * it hasn't already been set
-   */
+    /*
+     * Only generate the Mail-Followup-To if the user has requested it, and
+     * it hasn't already been set
+     */
+    if (!option(OPTFOLLOWUPTO))
+        return;
 
 
-  if (!option (OPTFOLLOWUPTO))
-    return;
 #ifdef USE_NNTP
 #ifdef USE_NNTP
-  if (option (OPTNEWSSEND)) {
-    if (!e->followup_to && e->newsgroups && (strrchr (e->newsgroups, ',')))
-      e->followup_to = m_strdup(e->newsgroups);
-    return;
-  }
+    if (option(OPTNEWSSEND)) {
+        if (!e->followup_to && e->newsgroups && strrchr(e->newsgroups, ','))
+            e->followup_to = m_strdup(e->newsgroups);
+        return;
+    }
 #endif
 
 #endif
 
-  if (!e->mail_followup_to) {
+    if (e->mail_followup_to)
+        return;
+
     if (mutt_is_list_cc (0, e->to, e->cc)) {
     if (mutt_is_list_cc (0, e->to, e->cc)) {
-      address_t **tmp;
-      /* 
-       * this message goes to known mailing lists, so create a proper
-       * mail-followup-to header
-       */
+        address_t **tmp;
 
 
-      tmp = address_list_append(&e->mail_followup_to, address_list_dup(e->to));
-      address_list_append(tmp, address_list_dup(e->cc));
+        /*
+         * this message goes to known mailing lists, so create a proper
+         * mail-followup-to header
+         */
+        tmp = address_list_append(&e->mail_followup_to, address_list_dup(e->to));
+        address_list_append(tmp, address_list_dup(e->cc));
     }
 
     /* remove ourselves from the mail-followup-to header */
     }
 
     /* remove ourselves from the mail-followup-to header */
-    e->mail_followup_to = remove_user (e->mail_followup_to, 0);
+    e->mail_followup_to = remove_user(e->mail_followup_to, 0);
 
     /*
      * If we are not subscribed to any of the lists in question,
 
     /*
      * If we are not subscribed to any of the lists in question,
-     * re-add ourselves to the mail-followup-to header.  The 
+     * re-add ourselves to the mail-followup-to header.  The
      * mail-followup-to header generated is a no-op with group-reply,
      * but makes sure list-reply has the desired effect.
      */
      * mail-followup-to header generated is a no-op with group-reply,
      * but makes sure list-reply has the desired effect.
      */
+    if (e->mail_followup_to && !mutt_is_list_recipient(0, e->to, e->cc)) {
+        address_t *from;
 
 
-    if (e->mail_followup_to && !mutt_is_list_recipient (0, e->to, e->cc)) {
-      if (e->reply_to)
-        from = address_list_dup (e->reply_to);
-      else if (e->from)
-        from = address_list_dup (e->from);
-      else
-        from = mutt_default_from ();
+        if (e->reply_to)
+            from = address_list_dup(e->reply_to);
+        else if (e->from)
+            from = address_list_dup(e->from);
+        else
+            from = mutt_default_from();
 
 
-      if (from) {
-        address_list_append(&from->next, e->mail_followup_to);
+        address_list_append(&from, e->mail_followup_to);
         e->mail_followup_to = from;
         e->mail_followup_to = from;
-      }
     }
 
     address_list_uniq(e->mail_followup_to);
     }
 
     address_list_uniq(e->mail_followup_to);
-
-  }
 }
 
 
 }
 
 
@@ -913,50 +910,48 @@ void mutt_set_followup_to (ENVELOPE * e)
    from field */
 static address_t *set_reverse_name (ENVELOPE * env)
 {
    from field */
 static address_t *set_reverse_name (ENVELOPE * env)
 {
-  address_t *tmp;
+    address_t *tmp;
 
 
-  for (tmp = env->to; tmp; tmp = tmp->next) {
-    if (mutt_addr_is_user (tmp))
-      break;
-  }
-  if (!tmp) {
+    for (tmp = env->to; tmp; tmp = tmp->next) {
+        if (mutt_addr_is_user(tmp))
+            goto found;
+    }
     for (tmp = env->cc; tmp; tmp = tmp->next) {
     for (tmp = env->cc; tmp; tmp = tmp->next) {
-      if (mutt_addr_is_user (tmp))
-        break;
+        if (mutt_addr_is_user(tmp))
+            goto found;
     }
     }
-  }
-  if (!tmp && mutt_addr_is_user (env->from))
-    tmp = env->from;
-  if (tmp) {
-    tmp = address_dup (tmp);
-    if (!option (OPTREVREAL))
-      p_delete(&tmp->personal);
-    if (!tmp->personal)
-      tmp->personal = m_strdup(Realname);
-  }
-  return (tmp);
+
+    if (!mutt_addr_is_user(env->from))
+        return NULL;
+
+  found:
+    tmp = address_dup(tmp);
+    if (!option(OPTREVREAL) || !tmp->personal) {
+        p_delete(&tmp->personal);
+        tmp->personal = m_strdup(Realname);
+    }
+    return tmp;
 }
 
 address_t *mutt_default_from (void)
 {
   address_t *adr;
 }
 
 address_t *mutt_default_from (void)
 {
   address_t *adr;
-  const char *fqdn = mutt_fqdn (1);
 
 
-  /* 
-   * Note: We let $from override $realname here.  Is this the right
-   * thing to do? 
+  /*
+   * Note: We let $from override $realname here.
+   * Is this the right thing to do?
    */
 
   if (From)
    */
 
   if (From)
-    adr = address_dup (From);
+    adr = address_dup(From);
   else if (option (OPTUSEDOMAIN)) {
   else if (option (OPTUSEDOMAIN)) {
-    adr = address_new ();
+    const char *fqdn = mutt_fqdn (1);
+    adr = address_new();
     adr->mailbox = p_new(char, m_strlen(Username) + m_strlen(fqdn) + 2);
     adr->mailbox = p_new(char, m_strlen(Username) + m_strlen(fqdn) + 2);
-    sprintf (adr->mailbox, "%s@%s", NONULL (Username), NONULL (fqdn));
-  }
-  else {
+    sprintf(adr->mailbox, "%s@%s", NONULL(Username), NONULL(fqdn));
+  } else {
     adr = address_new ();
     adr = address_new ();
-    adr->mailbox = m_strdup(NONULL (Username));
+    adr->mailbox = m_strdup(NONULL(Username));
   }
 
   return (adr);
   }
 
   return (adr);
index 0f676b9..6cd48b5 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -2078,7 +2078,6 @@ static int _mutt_bounce_message (FILE * fp, HEADER * h, address_t * to,
 int mutt_bounce_message (FILE * fp, HEADER * h, address_t * to)
 {
   address_t *from;
 int mutt_bounce_message (FILE * fp, HEADER * h, address_t * to)
 {
   address_t *from;
-  const char *fqdn = mutt_fqdn (1);
   char resent_from[STRING];
   int ret;
   char *err;
   char resent_from[STRING];
   int ret;
   char *err;
@@ -2086,8 +2085,7 @@ int mutt_bounce_message (FILE * fp, HEADER * h, address_t * to)
   resent_from[0] = '\0';
   from = mutt_default_from ();
 
   resent_from[0] = '\0';
   from = mutt_default_from ();
 
-  if (fqdn)
-    rfc822_qualify (from, fqdn);
+  rfc822_qualify(from, mutt_fqdn(1));
 
   rfc2047_encode_adrlist (from, "Resent-From");
   if (mutt_addrlist_to_idna (from, &err)) {
 
   rfc2047_encode_adrlist (from, "Resent-From");
   if (mutt_addrlist_to_idna (from, &err)) {