]> diplodocus.org Git - nmh/blobdiff - uip/ali.c
Simplified m_strn() per Ralph's suggestions.
[nmh] / uip / ali.c
index db536214f71788dfefe552a1147dfd2bb81dd068..a75edf3644b97deef7e80128f1046e0830f7f0b1 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
@@ -1,6 +1,4 @@
-
-/*
- * ali.c -- list nmh mail aliases
+/* ali.c -- list nmh mail aliases
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -117,11 +115,10 @@ main (int argc, char **argv)
        if ((cp = context_find ("Aliasfile"))) {
            char *dp = NULL;
 
-           for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++)
+           for (ap = brkstring(dp = mh_xstrdup(cp), " ", "\n"); ap && *ap; ap++)
                if ((i = alias (*ap)) != AK_OK)
                    adios (NULL, "aliasing error in %s - %s", *ap, akerror (i));
-           if (dp)
-               free(dp);
+            mh_xfree(dp);
        }
        alias (AliasFile);
     }
@@ -144,9 +141,13 @@ main (int argc, char **argv)
        } else {
            /* print them all */
            for (ak = akahead; ak; ak = ak->ak_next) {
+                char *res;
+
                printf ("%s: ", ak->ak_name);
                pos += strlen (ak->ak_name) + 1;
-               print_aka (akresult (ak), list, pos);
+                res = akresult(ak);
+               print_aka(res, list, pos);
+                free(res);
            }
        }
     }
@@ -162,7 +163,7 @@ print_aka (char *p, int list, int margin)
     char c;
 
     if (p == NULL) {
-       printf ("<empty>\n");
+       puts("<empty>");
        return;
     }
 
@@ -199,9 +200,9 @@ print_aka (char *p, int list, int margin)
 static void
 print_usr (char *s, int list)
 {
-    register char *cp, *pp, *vp;
-    register struct aka *ak;
-    register struct mailname *mp, *np;
+    char *cp, *pp, *vp;
+    struct aka *ak;
+    struct mailname *mp, *np;
 
     if ((pp = getname (s)) == NULL)
        adios (NULL, "no address in \"%s\"", s);
@@ -216,10 +217,10 @@ print_usr (char *s, int list)
        while ((cp = getname (pp))) {
            if ((np = getm (cp, NULL, 0, NULL, 0)) == NULL)
                continue;
-           if (!strcasecmp (mp->m_host ? mp->m_host : "",
-                            np->m_host ? np->m_host : "")  &&
-               !strcasecmp (mp->m_mbox ? mp->m_mbox : "",
-                            np->m_mbox ? np->m_mbox : "")) {
+           if (!strcasecmp (FENDNULL(mp->m_host),
+                            FENDNULL(np->m_host))  &&
+               !strcasecmp (FENDNULL(mp->m_mbox),
+                            FENDNULL(np->m_mbox))) {
                vp = vp ? add (ak->ak_name, add (",", vp))
                    : getcpy (ak->ak_name);
                mnfree (np);
@@ -234,6 +235,5 @@ print_usr (char *s, int list)
 
     print_aka (vp ? vp : s, list, 0);
 
-    if (vp)
-       free (vp);
+    mh_xfree(vp);
 }