[BACK]Return to collect.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mail

Diff for /src/usr.bin/mail/collect.c between version 1.7 and 1.8

version 1.7, 1997/07/13 23:53:58 version 1.8, 1997/07/14 00:24:25
Line 71 
Line 71 
 static  FILE    *collf;                 /* File for saving away */  static  FILE    *collf;                 /* File for saving away */
 static  int     hadintr;                /* Have seen one SIGINT so far */  static  int     hadintr;                /* Have seen one SIGINT so far */
   
 static  jmp_buf colljmp;                /* To get back to work */  static  sigjmp_buf      colljmp;        /* To get back to work */
 static  int     colljmp_p;              /* whether to long jump */  static  int             colljmp_p;      /* whether to long jump */
 static  jmp_buf collabort;              /* To end collection with error */  static  sigjmp_buf      collabort;      /* To end collection with error */
   
 FILE *  FILE *
 collect(hp, printheaders)  collect(hp, printheaders)
Line 90 
Line 90 
         int longline, lastlong, rc;     /* Can deal with lines > LINESIZE */          int longline, lastlong, rc;     /* Can deal with lines > LINESIZE */
   
 #if __GNUC__  #if __GNUC__
         /* Avoid longjmp clobbering */          /* Avoid siglongjmp clobbering */
         (void)&escape;          (void)&escape;
         (void)&eofcount;          (void)&eofcount;
         (void)&getsub;          (void)&getsub;
Line 110 
Line 110 
         savetstp = signal(SIGTSTP, collstop);          savetstp = signal(SIGTSTP, collstop);
         savettou = signal(SIGTTOU, collstop);          savettou = signal(SIGTTOU, collstop);
         savettin = signal(SIGTTIN, collstop);          savettin = signal(SIGTTIN, collstop);
         if (setjmp(collabort) || setjmp(colljmp)) {          if (sigsetjmp(collabort, 1) || sigsetjmp(colljmp, 1)) {
                 rm(tempMail);                  rm(tempMail);
                 goto err;                  goto err;
         }          }
Line 130 
Line 130 
          */           */
         t = GTO|GSUBJECT|GCC|GNL;          t = GTO|GSUBJECT|GCC|GNL;
         getsub = 0;          getsub = 0;
         if (hp->h_subject == NOSTR && value("interactive") != NOSTR &&          if (hp->h_subject == NULL && value("interactive") != NULL &&
             (value("ask") != NOSTR || value("asksub") != NOSTR))              (value("ask") != NULL || value("asksub") != NULL))
                 t &= ~GNL, getsub++;                  t &= ~GNL, getsub++;
         if (printheaders) {          if (printheaders) {
                 puthead(hp, stdout, t);                  puthead(hp, stdout, t);
                 fflush(stdout);                  fflush(stdout);
         }          }
         if ((cp = value("escape")) != NOSTR)          if ((cp = value("escape")) != NULL)
                 escape = *cp;                  escape = *cp;
         else          else
                 escape = ESCAPE;                  escape = ESCAPE;
Line 146 
Line 146 
         lastlong = 0;          lastlong = 0;
         longline = 0;          longline = 0;
   
         if (!setjmp(colljmp)) {          if (!sigsetjmp(colljmp, 1)) {
                 if (getsub)                  if (getsub)
                         grabh(hp, GSUBJECT);                          grabh(hp, GSUBJECT);
         } else {          } else {
Line 172 
Line 172 
                 c = readline(stdin, linebuf, LINESIZE);                  c = readline(stdin, linebuf, LINESIZE);
                 colljmp_p = 0;                  colljmp_p = 0;
                 if (c < 0) {                  if (c < 0) {
                         if (value("interactive") != NOSTR &&                          if (value("interactive") != NULL &&
                             value("ignoreeof") != NOSTR && ++eofcount < 25) {                              value("ignoreeof") != NULL && ++eofcount < 25) {
                                 puts("Use \".\" to terminate letter");                                  puts("Use \".\" to terminate letter");
                                 continue;                                  continue;
                         }                          }
Line 184 
Line 184 
                 eofcount = 0;                  eofcount = 0;
                 hadintr = 0;                  hadintr = 0;
                 if (linebuf[0] == '.' && linebuf[1] == '\0' &&                  if (linebuf[0] == '.' && linebuf[1] == '\0' &&
                     value("interactive") != NOSTR && !lastlong &&                      value("interactive") != NULL && !lastlong &&
                     (value("dot") != NOSTR || value("ignoreeof") != NOSTR))                      (value("dot") != NULL || value("ignoreeof") != NULL))
                         break;                          break;
                 if (linebuf[0] != escape || value("interactive") == NOSTR ||                  if (linebuf[0] != escape || value("interactive") == NULL ||
                     lastlong) {                      lastlong) {
                         if (putline(collf, linebuf, !longline) < 0)                          if (putline(collf, linebuf, !longline) < 0)
                                 goto err;                                  goto err;
Line 292 
Line 292 
                                 break;                                  break;
                         }                          }
                         cp = expand(cp);                          cp = expand(cp);
                         if (cp == NOSTR)                          if (cp == NULL)
                                 break;                                  break;
                         if (isdir(cp)) {                          if (isdir(cp)) {
                                 printf("%s: Directory\n", cp);                                  printf("%s: Directory\n", cp);
Line 330 
Line 330 
                                 fputs("Write what file!?\n", stderr);                                  fputs("Write what file!?\n", stderr);
                                 break;                                  break;
                         }                          }
                         if ((cp = expand(cp)) == NOSTR)                          if ((cp = expand(cp)) == NULL)
                                 break;                                  break;
                         rewind(collf);                          rewind(collf);
                         exwrite(cp, collf, 1);                          exwrite(cp, collf, 1);
Line 434 
Line 434 
                 return(-1);                  return(-1);
         }          }
         if ((of = Fopen(name, "w")) == NULL) {          if ((of = Fopen(name, "w")) == NULL) {
                 warn(NOSTR);                  warn(NULL);
                 return(-1);                  return(-1);
         }          }
         lc = 0;          lc = 0;
Line 501 
Line 501 
          * stdin = current message.           * stdin = current message.
          * stdout = new message.           * stdout = new message.
          */           */
         if ((shell = value("SHELL")) == NOSTR)          if ((shell = value("SHELL")) == NULL)
                 shell = _PATH_CSHELL;                  shell = _PATH_CSHELL;
         if (run_command(shell,          if (run_command(shell,
             0, fileno(fp), fileno(nf), "-c", cmd, NOSTR) < 0) {              0, fileno(fp), fileno(nf), "-c", cmd, NULL) < 0) {
                 (void)Fclose(nf);                  (void)Fclose(nf);
                 goto out;                  goto out;
         }          }
Line 543 
Line 543 
         char *tabst;          char *tabst;
   
         msgvec = (int *)salloc((msgCount+1) * sizeof(*msgvec));          msgvec = (int *)salloc((msgCount+1) * sizeof(*msgvec));
         if (msgvec == (int *)NOSTR)          if (msgvec == NULL)
                 return(0);                  return(0);
         if (getmsglist(ms, msgvec, 0) < 0)          if (getmsglist(ms, msgvec, 0) < 0)
                 return(0);                  return(0);
Line 556 
Line 556 
                 msgvec[1] = NULL;                  msgvec[1] = NULL;
         }          }
         if (f == 'f' || f == 'F')          if (f == 'f' || f == 'F')
                 tabst = NOSTR;                  tabst = NULL;
         else if ((tabst = value("indentprefix")) == NOSTR)          else if ((tabst = value("indentprefix")) == NULL)
                 tabst = "\t";                  tabst = "\t";
         ig = isupper(f) ? NULL : ignore;          ig = isupper(f) ? NULL : ignore;
         fputs("Interpolating:", stdout);          fputs("Interpolating:", stdout);
Line 595 
Line 595 
         if (colljmp_p) {          if (colljmp_p) {
                 colljmp_p = 0;                  colljmp_p = 0;
                 hadintr = 0;                  hadintr = 0;
                 longjmp(colljmp, 1);                  siglongjmp(colljmp, 1);
         }          }
 }  }
   
Line 612 
Line 612 
          * the control flow is subtle, because we can be called from ~q.           * the control flow is subtle, because we can be called from ~q.
          */           */
         if (hadintr == 0 && isatty(0)) {          if (hadintr == 0 && isatty(0)) {
                 if (value("ignore") != NOSTR) {                  if (value("ignore") != NULL) {
                         puts("@");                          puts("@");
                         fflush(stdout);                          fflush(stdout);
                         clearerr(stdin);                          clearerr(stdin);
                         return;                          return;
                 }                  }
                 hadintr = 1;                  hadintr = 1;
                 longjmp(colljmp, 1);                  siglongjmp(colljmp, 1);
         }          }
         rewind(collf);          rewind(collf);
         if (value("nosave") == NOSTR)          if (value("nosave") == NULL)
                 savedeadletter(collf);                  savedeadletter(collf);
         longjmp(collabort, 1);          siglongjmp(collabort, 1);
 }  }
   
 /*ARGSUSED*/  /*ARGSUSED*/

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8