install in /etc
[unix-history] / usr / src / usr.bin / mail / aux.c
index 31483fb..056306a 100644 (file)
@@ -11,7 +11,7 @@
  * Auxiliary functions.
  */
 
  * Auxiliary functions.
  */
 
-static char *SccsId = "@(#)aux.c       1.1 %G%";
+static char *SccsId = "@(#)aux.c       1.3 %G%";
 
 /*
  * Return a pointer to a dynamic copy of the argument.
 
 /*
  * Return a pointer to a dynamic copy of the argument.
@@ -98,8 +98,14 @@ prs(str)
 
 touch(mesg)
 {
 
 touch(mesg)
 {
-       if (mesg >= 1 && mesg <= msgCount)
-               message[mesg-1].m_flag |= MTOUCH;
+       register struct message *mp;
+
+       if (mesg < 1 || mesg > msgCount)
+               return;
+       mp = &message[mesg-1];
+       mp->m_flag |= MTOUCH;
+       if ((mp->m_flag & MREAD) == 0)
+               mp->m_flag |= MREAD|MSTATUS;
 }
 
 /*
 }
 
 /*
@@ -374,7 +380,10 @@ icequal(s1, s2)
  */
 
 static int     ssp = -1;               /* Top of file stack */
  */
 
 static int     ssp = -1;               /* Top of file stack */
-static FILE    *sstack[_NFILE];        /* Saved input files */
+struct sstack {
+       FILE    *s_file;                /* File we were in. */
+       int     s_cond;                 /* Saved state of conditionals */
+} sstack[_NFILE];
 
 /*
  * Pushdown current input file and switch to a new one.
 
 /*
  * Pushdown current input file and switch to a new one.
@@ -396,7 +405,9 @@ source(name)
                fclose(fi);
                return(1);
        }
                fclose(fi);
                return(1);
        }
-       sstack[++ssp] = input;
+       sstack[++ssp].s_file = input;
+       sstack[ssp].s_cond = cond;
+       cond = CANY;
        input = fi;
        sourcing++;
        return(0);
        input = fi;
        sourcing++;
        return(0);
@@ -430,7 +441,10 @@ unstack()
                return(1);
        }
        fclose(input);
                return(1);
        }
        fclose(input);
-       input = sstack[ssp--];
+       if (cond != CANY)
+               printf("Unmatched \"if\"\n");
+       cond = sstack[ssp].s_cond;
+       input = sstack[ssp--].s_file;
        if (ssp < 0)
                sourcing = 0;
        return(0);
        if (ssp < 0)
                sourcing = 0;
        return(0);