]> diplodocus.org Git - nmh/blobdiff - sbr/addrsbr.c
new.c: Order two return statements to match comment.
[nmh] / sbr / addrsbr.c
index 466d8cca0a1b646131ee619eace39427608733fe..b4e6e890a6dbe43d1045672bef82eb550482f4ad 100644 (file)
    REALLYDUMB are now the default in the code.
 
    If #ifdef DUMB is in effect, a full 822-style parser is called
-   for syntax recongition.  This breaks each address into its components.
+   for syntax recognition.  This breaks each address into its components.
    Note however that no semantics are assumed about the parts or their
    totality.  This means that implicit hostnames aren't made explicit,
-   and explicit hostnames aren't expanded to their "official" represenations.
+   and explicit hostnames aren't expanded to their "official" representations.
 
    If DUMB is not in effect, then this module does some
    high-level thinking about what the addresses are.
@@ -77,7 +77,7 @@ static char adr[BUFSIZ];
 static int eai = 0;
 
 void
-enable_eai() {
+enable_eai(void) {
     eai = 1;
 }
 
@@ -89,7 +89,7 @@ getname (const char *addrs)
     pers = mbox = host = route = grp = note = NULL;
     err[0] = '\0';
 
-    if ((ap = getadrx (addrs ? addrs : "", eai)) == NULL) {
+    if ((ap = getadrx (FENDNULL(addrs), eai)) == NULL) {
        return NULL;
     }
 
@@ -204,20 +204,18 @@ mnfree (struct mailname *mp)
     if (!mp)
        return;
 
-    mh_xfree(mp->m_text);
-    mh_xfree(mp->m_pers);
-    mh_xfree(mp->m_mbox);
-    mh_xfree(mp->m_host);
-    mh_xfree(mp->m_path);
-    mh_xfree(mp->m_gname);
-    mh_xfree(mp->m_note);
+    free(mp->m_text);
+    free(mp->m_pers);
+    free(mp->m_mbox);
+    free(mp->m_host);
+    free(mp->m_path);
+    free(mp->m_gname);
+    free(mp->m_note);
 
     free(mp);
 }
 
 
-#define empty(s) ((s) ? (s) : "")
-
 char *
 auxformat (struct mailname *mp, int extras)
 {
@@ -225,15 +223,13 @@ auxformat (struct mailname *mp, int extras)
     static char buffer[BUFSIZ];
 
        if (mp->m_nohost)
-           strncpy (addr, mp->m_mbox ? mp->m_mbox : "", sizeof(addr));
-       else
-
-       if (mp->m_type != UUCPHOST) {
+           strncpy (addr, FENDNULL(mp->m_mbox), sizeof(addr));
+       else if (mp->m_type != UUCPHOST) {
            if (mp->m_host)
-               snprintf (addr, sizeof(addr), "%s%s@%s", empty(mp->m_path),
-                         empty(mp->m_mbox), mp->m_host);
-           else snprintf (addr, sizeof(addr), "%s%s", empty(mp->m_path),
-                          empty(mp->m_mbox));
+               snprintf (addr, sizeof(addr), "%s%s@%s", FENDNULL(mp->m_path),
+                         FENDNULL(mp->m_mbox), mp->m_host);
+           else snprintf (addr, sizeof(addr), "%s%s", FENDNULL(mp->m_path),
+                          FENDNULL(mp->m_mbox));
        } else
            snprintf (addr, sizeof(addr), "%s!%s", mp->m_host, mp->m_mbox);
 
@@ -249,12 +245,10 @@ auxformat (struct mailname *mp, int extras)
            snprintf (buffer, sizeof(buffer), "%s <%s>",
                    legal_person (mp->m_pers ? mp->m_pers : mp->m_mbox),
                    addr);
-    }
+    } else if (mp->m_note)
+        snprintf (buffer, sizeof(buffer), "%s %s", addr, mp->m_note);
     else
-       if (mp->m_note)
-           snprintf (buffer, sizeof(buffer), "%s %s", addr, mp->m_note);
-       else
-           strncpy (buffer, addr, sizeof(buffer));
+        strncpy (buffer, addr, sizeof(buffer));
 
     return buffer;
 }
@@ -355,8 +349,8 @@ ismymbox (struct mailname *np)
            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 : "",
+                      FENDNULL(mp->m_text), mp->m_mbox,
+                      FENDNULL(mp->m_host),
                       snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type,
                                 WBITS));
            }