=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mail/tty.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/mail/tty.c 1997/07/13 23:54:03 1.4 --- src/usr.bin/mail/tty.c 1997/07/14 00:24:31 1.5 *************** *** 1,4 **** ! /* $OpenBSD: tty.c,v 1.4 1997/07/13 23:54:03 millert Exp $ */ /* $NetBSD: tty.c,v 1.7 1997/07/09 05:25:46 mikel Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: tty.c,v 1.5 1997/07/14 00:24:31 millert Exp $ */ /* $NetBSD: tty.c,v 1.7 1997/07/09 05:25:46 mikel Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 4/20/95"; #else ! static char rcsid[] = "$OpenBSD: tty.c,v 1.4 1997/07/13 23:54:03 millert Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 4/20/95"; #else ! static char rcsid[] = "$OpenBSD: tty.c,v 1.5 1997/07/14 00:24:31 millert Exp $"; #endif #endif /* not lint */ *************** *** 52,63 **** #include "extern.h" #include ! static cc_t c_erase; /* Current erase char */ ! static cc_t c_kill; /* Current kill char */ ! static jmp_buf rewrite; /* Place to go when continued */ ! static jmp_buf intjmp; /* Place to go when interrupted */ #ifndef TIOCSTI ! static int ttyset; /* We must now do erase/kill */ #endif /* --- 52,63 ---- #include "extern.h" #include ! static cc_t c_erase; /* Current erase char */ ! static cc_t c_kill; /* Current kill char */ ! static sigjmp_buf rewrite; /* Place to go when continued */ ! static sigjmp_buf intjmp; /* Place to go when interrupted */ #ifndef TIOCSTI ! static int ttyset; /* We must now do erase/kill */ #endif /* *************** *** 81,87 **** sig_t savettin; int errs; #ifdef __GNUC__ ! /* Avoid longjmp clobbering */ #ifdef TIOCSTI (void)&extproc; #endif --- 81,87 ---- sig_t savettin; int errs; #ifdef __GNUC__ ! /* Avoid siglongjmp clobbering */ #ifdef TIOCSTI (void)&extproc; #endif *************** *** 117,123 **** warn("TIOCEXT: off"); } # endif /* TIOCEXT */ ! if (setjmp(intjmp)) goto out; saveint = signal(SIGINT, ttyint); #endif --- 117,123 ---- warn("TIOCEXT: off"); } # endif /* TIOCEXT */ ! if (sigsetjmp(intjmp, 1)) goto out; saveint = signal(SIGINT, ttyint); #endif *************** *** 131,137 **** } if (gflags & GSUBJECT) { #ifndef TIOCSTI ! if (!ttyset && hp->h_subject != NOSTR) ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); #endif hp->h_subject = readtty("Subject: ", hp->h_subject); --- 131,137 ---- } if (gflags & GSUBJECT) { #ifndef TIOCSTI ! if (!ttyset && hp->h_subject != NULL) ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); #endif hp->h_subject = readtty("Subject: ", hp->h_subject); *************** *** 190,215 **** int c; char *cp, *cp2; #if __GNUC__ ! /* Avoid longjmp clobbering */ (void)&c; (void)&cp2; #endif fputs(pr, stdout); fflush(stdout); ! if (src != NOSTR && strlen(src) > BUFSIZ - 2) { puts("too long to edit"); return(src); } #ifndef TIOCSTI ! if (src != NOSTR) cp = copy(src, canonb); else cp = copy("", canonb); fputs(canonb, stdout); fflush(stdout); #else ! cp = src == NOSTR ? "" : src; while ((c = *cp++) != '\0') { if ((c_erase != _POSIX_VDISABLE && c == c_erase) || (c_kill != _POSIX_VDISABLE && c == c_kill)) { --- 190,215 ---- int c; char *cp, *cp2; #if __GNUC__ ! /* Avoid siglongjmp clobbering */ (void)&c; (void)&cp2; #endif fputs(pr, stdout); fflush(stdout); ! if (src != NULL && strlen(src) > BUFSIZ - 2) { puts("too long to edit"); return(src); } #ifndef TIOCSTI ! if (src != NULL) cp = copy(src, canonb); else cp = copy("", canonb); fputs(canonb, stdout); fflush(stdout); #else ! cp = src == NULL ? "" : src; while ((c = *cp++) != '\0') { if ((c_erase != _POSIX_VDISABLE && c == c_erase) || (c_kill != _POSIX_VDISABLE && c == c_kill)) { *************** *** 226,232 **** while (cp2 < canonb + BUFSIZ) *cp2++ = 0; cp2 = cp; ! if (setjmp(rewrite)) goto redo; signal(SIGTSTP, ttystop); signal(SIGTTOU, ttystop); --- 226,232 ---- while (cp2 < canonb + BUFSIZ) *cp2++ = 0; cp2 = cp; ! if (sigsetjmp(rewrite, 1)) goto redo; signal(SIGTSTP, ttystop); signal(SIGTTOU, ttystop); *************** *** 244,259 **** signal(SIGTTIN, SIG_DFL); if (c == EOF && ferror(stdin)) { redo: ! cp = strlen(canonb) > 0 ? canonb : NOSTR; clearerr(stdin); return(readtty(pr, cp)); } #ifndef TIOCSTI ! if (cp == NOSTR || *cp == '\0') return(src); cp2 = cp; if (!ttyset) ! return(strlen(canonb) > 0 ? savestr(canonb) : NOSTR); while (*cp != '\0') { c = *cp++; if (c_erase != _POSIX_VDISABLE && c == c_erase) { --- 244,259 ---- signal(SIGTTIN, SIG_DFL); if (c == EOF && ferror(stdin)) { redo: ! cp = strlen(canonb) > 0 ? canonb : NULL; clearerr(stdin); return(readtty(pr, cp)); } #ifndef TIOCSTI ! if (cp == NULL || *cp == '\0') return(src); cp2 = cp; if (!ttyset) ! return(strlen(canonb) > 0 ? savestr(canonb) : NULL); while (*cp != '\0') { c = *cp++; if (c_erase != _POSIX_VDISABLE && c == c_erase) { *************** *** 281,287 **** *cp2 = '\0'; #endif if (equal("", canonb)) ! return(NOSTR); return(savestr(canonb)); } --- 281,287 ---- *cp2 = '\0'; #endif if (equal("", canonb)) ! return(NULL); return(savestr(canonb)); } *************** *** 301,307 **** kill(0, s); sigprocmask(SIG_UNBLOCK, &nset, NULL); signal(s, old_action); ! longjmp(rewrite, 1); } /*ARGSUSED*/ --- 301,307 ---- kill(0, s); sigprocmask(SIG_UNBLOCK, &nset, NULL); signal(s, old_action); ! siglongjmp(rewrite, 1); } /*ARGSUSED*/ *************** *** 309,313 **** ttyint(s) int s; { ! longjmp(intjmp, 1); } --- 309,313 ---- ttyint(s) int s; { ! siglongjmp(intjmp, 1); }