Cleaned up test-utf8-body a bit.
[mmh] / sbr / addrsbr.c
index fc026fb..929b491 100644 (file)
@@ -169,37 +169,30 @@ getm (char *str, char *dfhost, int dftype, int wanthost, char *eresult)
     if (host) {
        mp->m_mbox = getcpy (mbox);
        mp->m_host = getcpy (host);
-    }
-    else {
+       mp->m_type =
+           mh_strcasecmp (LocalName(0), mp->m_host) ? NETHOST : LOCALHOST;
+    } else {
        if ((pp = strchr(mbox, '!'))) {
            *pp++ = '\0';
            mp->m_mbox = getcpy (pp);
            mp->m_host = getcpy (mbox);
            mp->m_type = UUCPHOST;
-       }
-       else {
+       } else {
            mp->m_nohost = 1;
            mp->m_mbox = getcpy (mbox);
            if (route == NULL && dftype == LOCALHOST) {
                mp->m_host = NULL;
                mp->m_type = dftype;
-           }
-           else
-           {
+           } else {
                mp->m_host = route ? NULL : getcpy (dfhost);
                mp->m_type = route ? NETHOST : dftype;
            }
        }
-       goto got_host;
     }
 
-    if (wanthost == AD_NHST)
-       mp->m_type = !mh_strcasecmp (LocalName (0), mp->m_host)
-           ? LOCALHOST : NETHOST;
-    else
-       mp->m_type = mh_strcasecmp (LocalName(0), mp->m_host) ?  NETHOST : LOCALHOST;
+    /* For alternate mailboxes, m_type gets overwritten in ismymbox ()
+       to support wild-card matching. */
 
-got_host: ;
     if (route)
        mp->m_path = getcpy (route);
     mp->m_ingrp = ingrp;
@@ -356,7 +349,7 @@ ismymbox (struct mailname *np)
        if ((am = context_find ("alternate-mailboxes")) == NULL)
            am = getusername();
        else {
-           mp = &mq;
+           mp = mq.m_next ? mq.m_next : &mq;
            oops = 0;
            while ((cp = getname (am))) {
                if ((mp->m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
@@ -383,16 +376,23 @@ ismymbox (struct mailname *np)
                            *cp = '\0';
                        }
                    }
-                   if ((cp = getenv ("MHWDEBUG")) && *cp)
-                       fprintf (stderr, "mbox=\"%s\" host=\"%s\" %s\n",
-                           mp->m_mbox, mp->m_host,
-                           snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type, WBITS));
                }
            }
            if (oops)
                advise (NULL, "please fix the %s: entry in your %s file",
                        "alternate-mailboxes", mh_profile);
        }
+
+       if ((cp = getenv ("MHWDEBUG")) && *cp) {
+           for (mp = &mq; mp; mp = mp->m_next) {
+             fprintf (stderr, "Local- or Alternate-Mailbox: text=\"%s\" "
+                      "mbox=\"%s\" host=\"%s\" %s\n",
+                      mp->m_text ? mp->m_text : "", mp->m_mbox,
+                      mp->m_host ? mp->m_host : "",
+                      snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type,
+                                WBITS));
+           }
+       }
     }
 
     if (np == NULL) /* XXX */