]> diplodocus.org Git - nmh/blobdiff - uip/aliasbr.c
h/mhparse.h: Move mhfree.c's free_content prototype to new header.
[nmh] / uip / aliasbr.c
index 039344165e22ed57f15d3bbc378b5bb8c711f380..ab2130efc18f470fda4f5f9f3cc196f531fb7669 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * aliasbr.c -- new aliasing mechanism
+/* aliasbr.c -- new aliasing mechanism
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -112,7 +110,9 @@ akval (struct aka *ak, char *s)
     for (; ak; ak = ak->ak_next) {
        if (aleq (s, ak->ak_name)) {
            return akresult (ak);
     for (; ak; ak = ak->ak_next) {
        if (aleq (s, ak->ak_name)) {
            return akresult (ak);
-       } else if (strchr (s, ':')) {
+       }
+
+        if (strchr (s, ':')) {
            /* The first address in a blind list will contain the
               alias name, so try to match, but just with just the
               address (not including the list name).  If there's a
            /* The first address in a blind list will contain the
               alias name, so try to match, but just with just the
               address (not including the list name).  If there's a
@@ -130,6 +130,8 @@ akval (struct aka *ak, char *s)
                if (mp  &&  mp->m_ingrp) {
                    char *gname = add (mp->m_gname, NULL);
 
                if (mp  &&  mp->m_ingrp) {
                    char *gname = add (mp->m_gname, NULL);
 
+                    /* FIXME: gname must be true;  add() never returns NULL.
+                    * Is some other test required? */
                    if (gname  &&  aleq (name, ak->ak_name)) {
                        /* Will leak cp. */
                        cp = concat (gname, akresult (ak), NULL);
                    if (gname  &&  aleq (name, ak->ak_name)) {
                        /* Will leak cp. */
                        cp = concat (gname, akresult (ak), NULL);
@@ -158,14 +160,13 @@ aleq (char *string, char *aliasent)
 {
     char c;
 
 {
     char c;
 
-    while ((c = *string++))
+    while ((c = *string++)) {
        if (*aliasent == '*')
            return 1;
        if (*aliasent == '*')
            return 1;
-       else
-           if ((c | 040) != (*aliasent | 040))
-               return 0;
-           else
-               aliasent++;
+        if (tolower((unsigned char)c) != tolower((unsigned char)*aliasent))
+            return 0;
+        aliasent++;
+    }
 
     return (*aliasent == 0 || *aliasent == '*');
 }
 
     return (*aliasent == 0 || *aliasent == '*');
 }
@@ -181,7 +182,7 @@ alias (char *file)
     FILE *fp;
 
     if (*file != '/'
     FILE *fp;
 
     if (*file != '/'
-           && (strncmp (file, "./", 2) && strncmp (file, "../", 3)))
+            && !has_prefix(file, "./") && !has_prefix(file, "../"))
        file = etcpath (file);
     if ((fp = fopen (file, "r")) == NULL) {
        akerrst = file;
        file = etcpath (file);
     if ((fp = fopen (file, "r")) == NULL) {
        akerrst = file;
@@ -201,7 +202,7 @@ alias (char *file)
                    fclose (fp);
                    return i;
                }
                    fclose (fp);
                    return i;
                }
-
+               /* FALLTHRU */
            case ':':           /* comment */
            case ';': 
            case '#':
            case ':':           /* comment */
            case ';': 
            case '#':