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

Diff for /src/usr.bin/mail/tty.c between version 1.4 and 1.5

version 1.4, 1997/07/13 23:54:03 version 1.5, 1997/07/14 00:24:31
Line 52 
Line 52 
 #include "extern.h"  #include "extern.h"
 #include <sys/ioctl.h>  #include <sys/ioctl.h>
   
 static  cc_t    c_erase;                /* Current erase char */  static  cc_t            c_erase;        /* Current erase char */
 static  cc_t    c_kill;                 /* Current kill char */  static  cc_t            c_kill;         /* Current kill char */
 static  jmp_buf rewrite;                /* Place to go when continued */  static  sigjmp_buf      rewrite;        /* Place to go when continued */
 static  jmp_buf intjmp;                 /* Place to go when interrupted */  static  sigjmp_buf      intjmp;         /* Place to go when interrupted */
 #ifndef TIOCSTI  #ifndef TIOCSTI
 static  int     ttyset;                 /* We must now do erase/kill */  static  int             ttyset;         /* We must now do erase/kill */
 #endif  #endif
   
 /*  /*
Line 81 
Line 81 
         sig_t savettin;          sig_t savettin;
         int errs;          int errs;
 #ifdef __GNUC__  #ifdef __GNUC__
         /* Avoid longjmp clobbering */          /* Avoid siglongjmp clobbering */
 #ifdef TIOCSTI  #ifdef TIOCSTI
         (void)&extproc;          (void)&extproc;
 #endif  #endif
Line 117 
Line 117 
                         warn("TIOCEXT: off");                          warn("TIOCEXT: off");
         }          }
 # endif /* TIOCEXT */  # endif /* TIOCEXT */
         if (setjmp(intjmp))          if (sigsetjmp(intjmp, 1))
                 goto out;                  goto out;
         saveint = signal(SIGINT, ttyint);          saveint = signal(SIGINT, ttyint);
 #endif  #endif
Line 131 
Line 131 
         }          }
         if (gflags & GSUBJECT) {          if (gflags & GSUBJECT) {
 #ifndef TIOCSTI  #ifndef TIOCSTI
                 if (!ttyset && hp->h_subject != NOSTR)                  if (!ttyset && hp->h_subject != NULL)
                         ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf);                          ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf);
 #endif  #endif
                 hp->h_subject = readtty("Subject: ", hp->h_subject);                  hp->h_subject = readtty("Subject: ", hp->h_subject);
Line 190 
Line 190 
         int c;          int c;
         char *cp, *cp2;          char *cp, *cp2;
 #if __GNUC__  #if __GNUC__
         /* Avoid longjmp clobbering */          /* Avoid siglongjmp clobbering */
         (void)&c;          (void)&c;
         (void)&cp2;          (void)&cp2;
 #endif  #endif
   
         fputs(pr, stdout);          fputs(pr, stdout);
         fflush(stdout);          fflush(stdout);
         if (src != NOSTR && strlen(src) > BUFSIZ - 2) {          if (src != NULL && strlen(src) > BUFSIZ - 2) {
                 puts("too long to edit");                  puts("too long to edit");
                 return(src);                  return(src);
         }          }
 #ifndef TIOCSTI  #ifndef TIOCSTI
         if (src != NOSTR)          if (src != NULL)
                 cp = copy(src, canonb);                  cp = copy(src, canonb);
         else          else
                 cp = copy("", canonb);                  cp = copy("", canonb);
         fputs(canonb, stdout);          fputs(canonb, stdout);
         fflush(stdout);          fflush(stdout);
 #else  #else
         cp = src == NOSTR ? "" : src;          cp = src == NULL ? "" : src;
         while ((c = *cp++) != '\0') {          while ((c = *cp++) != '\0') {
                 if ((c_erase != _POSIX_VDISABLE && c == c_erase) ||                  if ((c_erase != _POSIX_VDISABLE && c == c_erase) ||
                     (c_kill != _POSIX_VDISABLE && c == c_kill)) {                      (c_kill != _POSIX_VDISABLE && c == c_kill)) {
Line 226 
Line 226 
         while (cp2 < canonb + BUFSIZ)          while (cp2 < canonb + BUFSIZ)
                 *cp2++ = 0;                  *cp2++ = 0;
         cp2 = cp;          cp2 = cp;
         if (setjmp(rewrite))          if (sigsetjmp(rewrite, 1))
                 goto redo;                  goto redo;
         signal(SIGTSTP, ttystop);          signal(SIGTSTP, ttystop);
         signal(SIGTTOU, ttystop);          signal(SIGTTOU, ttystop);
Line 244 
Line 244 
         signal(SIGTTIN, SIG_DFL);          signal(SIGTTIN, SIG_DFL);
         if (c == EOF && ferror(stdin)) {          if (c == EOF && ferror(stdin)) {
 redo:  redo:
                 cp = strlen(canonb) > 0 ? canonb : NOSTR;                  cp = strlen(canonb) > 0 ? canonb : NULL;
                 clearerr(stdin);                  clearerr(stdin);
                 return(readtty(pr, cp));                  return(readtty(pr, cp));
         }          }
 #ifndef TIOCSTI  #ifndef TIOCSTI
         if (cp == NOSTR || *cp == '\0')          if (cp == NULL || *cp == '\0')
                 return(src);                  return(src);
         cp2 = cp;          cp2 = cp;
         if (!ttyset)          if (!ttyset)
                 return(strlen(canonb) > 0 ? savestr(canonb) : NOSTR);                  return(strlen(canonb) > 0 ? savestr(canonb) : NULL);
         while (*cp != '\0') {          while (*cp != '\0') {
                 c = *cp++;                  c = *cp++;
                 if (c_erase != _POSIX_VDISABLE && c == c_erase) {                  if (c_erase != _POSIX_VDISABLE && c == c_erase) {
Line 281 
Line 281 
         *cp2 = '\0';          *cp2 = '\0';
 #endif  #endif
         if (equal("", canonb))          if (equal("", canonb))
                 return(NOSTR);                  return(NULL);
         return(savestr(canonb));          return(savestr(canonb));
 }  }
   
Line 301 
Line 301 
         kill(0, s);          kill(0, s);
         sigprocmask(SIG_UNBLOCK, &nset, NULL);          sigprocmask(SIG_UNBLOCK, &nset, NULL);
         signal(s, old_action);          signal(s, old_action);
         longjmp(rewrite, 1);          siglongjmp(rewrite, 1);
 }  }
   
 /*ARGSUSED*/  /*ARGSUSED*/
Line 309 
Line 309 
 ttyint(s)  ttyint(s)
         int s;          int s;
 {  {
         longjmp(intjmp, 1);          siglongjmp(intjmp, 1);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5