BSD 4_3_Tahoe release
[unix-history] / usr / src / ucb / Mail / optim.c
index 750f94a..ce388b2 100644 (file)
@@ -1,12 +1,18 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
  */
 
  */
 
-#ifndef lint
-static char *sccsid = "@(#)optim.c     5.5 (Berkeley) 11/2/85";
-#endif not lint
+#ifdef notdef
+static char sccsid[] = "@(#)optim.c    5.9 (Berkeley) 2/18/88";
+#endif /* notdef */
 
 /*
  * Mail -- a program for sending and receiving mail.
 
 /*
  * Mail -- a program for sending and receiving mail.
@@ -16,7 +22,6 @@ static char *sccsid = "@(#)optim.c    5.5 (Berkeley) 11/2/85";
 
 #include "rcv.h"
 #include "configdefs.h"
 
 #include "rcv.h"
 #include "configdefs.h"
-#include <ctype.h>
 
 /*
  * Map a name into the correct network "view" of the
 
 /*
  * Map a name into the correct network "view" of the
@@ -46,51 +51,15 @@ netmap(name, from)
        if (cp == nbuf)
                return(name);
        *++cp = 0;
        if (cp == nbuf)
                return(name);
        *++cp = 0;
-       strcat(nbuf, revarpa(name));
+       if ((cp = revarpa(name)) != NOSTR)
+               strcat(nbuf, cp);
        optim(nbuf, ret);
        cp = revarpa(ret);
        optim(nbuf, ret);
        cp = revarpa(ret);
-       if (!icequal(name, cp))
+       if (cp && !icequal(name, cp))
                return(savestr(cp));
        return(name);
 }
 
                return(savestr(cp));
        return(name);
 }
 
-/*
- * Rename the given network path to use
- * the kinds of names that we would right here.
- */
-
-char *
-rename(str)
-       char str[];
-{
-       register char *cp, *cp2;
-       char buf[BUFSIZ], path[BUFSIZ];
-       register int c, host;
-
-       cp = str;
-       strcpy(path, "");
-       for (;;) {
-               if ((c = *cp++) == 0)
-                       break;
-               cp2 = buf;
-               while (!any(c, metanet) && c != 0) {
-                       *cp2++ = c;
-                       c = *cp++;
-               }
-               *cp2 = 0;
-               if (c == 0) {
-                       strcat(path, buf);
-                       break;
-               }
-               host = netlook(buf, ntype(c));
-               strcat(path, netname(host));
-               stradd(path, c);
-       }
-       if (strcmp(str, path) != 0)
-               return(savestr(path));
-       return(str);
-}
-
 /*
  * Turn a network machine name into a unique character
  */
 /*
  * Turn a network machine name into a unique character
  */
@@ -190,7 +159,7 @@ arpafix(name, from)
        if (cp == NOSTR)
                cp = rindex(name, '%');
        if (cp == NOSTR) {
        if (cp == NOSTR)
                cp = rindex(name, '%');
        if (cp == NOSTR) {
-               fprintf(stderr, "Somethings amiss -- no @ or % in arpafix\n");
+               fprintf(stderr, "Somethings amiss -- no @ or %% in arpafix\n");
                return(name);
        }
        cp++;
                return(name);
        }
        cp++;
@@ -269,7 +238,6 @@ short       midfree;                        /* Next free machine id */
 minit()
 {
        register struct xtrahash *xp, **tp;
 minit()
 {
        register struct xtrahash *xp, **tp;
-       register int i;
 
        midfree = 0;
        tp = &xtab[0];
 
        midfree = 0;
        tp = &xtab[0];
@@ -469,7 +437,7 @@ err:
                        printf("Made up bad net name\n");
                        printf("Machine code %c (0%o)\n", cp[-1], cp[-1]);
                        printf("Sorry -- dumping now.  Alert K. Shoens\n");
                        printf("Made up bad net name\n");
                        printf("Machine code %c (0%o)\n", cp[-1], cp[-1]);
                        printf("Sorry -- dumping now.  Alert K. Shoens\n");
-                       core(0);
+                       core();
                        goto err;
                }
                strcat(name, cp2);
                        goto err;
                }
                strcat(name, cp2);
@@ -577,7 +545,6 @@ optimex(net, name)
 {
        register char *cp, *rp;
        register int m;
 {
        register char *cp, *rp;
        register int m;
-       char *rindex();
 
        strcpy(name, net);
        cp = name;
 
        strcpy(name, net);
        cp = name;
@@ -872,17 +839,3 @@ yylex()
        yylval = dot;
        return(WORD);
 }
        yylval = dot;
        return(WORD);
 }
-
-/*
- * Add a single character onto a string.
- */
-
-stradd(str, c)
-       register char *str;
-       register int c;
-{
-
-       str += strlen(str);
-       *str++ = c;
-       *str = 0;
-}