diff -rc ../../../src/usr.bin/mail/tty.c usr.bin/mail/tty.c *** ../../../src/usr.bin/mail/tty.c Mon May 1 20:40:17 1995 --- usr.bin/mail/tty.c Wed Jun 16 22:10:48 1999 *************** *** 45,57 **** #include "rcv.h" #include "extern.h" - 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 /* * Read all relevant header fields. --- 45,52 ---- *************** *** 62,72 **** struct header *hp; int gflags; { - struct termios ttybuf; sig_t saveint; - #ifndef TIOCSTI - sig_t savequit; - #endif sig_t savetstp; sig_t savettou; sig_t savettin; --- 57,63 ---- *************** *** 77,131 **** savettou = signal(SIGTTOU, SIG_DFL); savettin = signal(SIGTTIN, SIG_DFL); errs = 0; ! #ifndef TIOCSTI ! ttyset = 0; ! #endif ! if (tcgetattr(fileno(stdin), &ttybuf) < 0) { ! perror("tcgetattr"); ! return(-1); ! } ! c_erase = ttybuf.c_cc[VERASE]; ! c_kill = ttybuf.c_cc[VKILL]; ! #ifndef TIOCSTI ! ttybuf.c_cc[VERASE] = 0; ! ttybuf.c_cc[VKILL] = 0; ! if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL) ! signal(SIGINT, SIG_DFL); ! if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL) ! signal(SIGQUIT, SIG_DFL); ! #else if (setjmp(intjmp)) goto out; saveint = signal(SIGINT, ttyint); - #endif if (gflags & GTO) { - #ifndef TIOCSTI - if (!ttyset && hp->h_to != NIL) - ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); - #endif hp->h_to = extract(readtty("To: ", detract(hp->h_to, 0)), GTO); } 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); } if (gflags & GCC) { - #ifndef TIOCSTI - if (!ttyset && hp->h_cc != NIL) - ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); - #endif hp->h_cc = extract(readtty("Cc: ", detract(hp->h_cc, 0)), GCC); } if (gflags & GBCC) { - #ifndef TIOCSTI - if (!ttyset && hp->h_bcc != NIL) - ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); - #endif hp->h_bcc = extract(readtty("Bcc: ", detract(hp->h_bcc, 0)), GBCC); } --- 68,89 ---- savettou = signal(SIGTTOU, SIG_DFL); savettin = signal(SIGTTIN, SIG_DFL); errs = 0; ! if (setjmp(intjmp)) goto out; saveint = signal(SIGINT, ttyint); if (gflags & GTO) { hp->h_to = extract(readtty("To: ", detract(hp->h_to, 0)), GTO); } if (gflags & GSUBJECT) { hp->h_subject = readtty("Subject: ", hp->h_subject); } if (gflags & GCC) { hp->h_cc = extract(readtty("Cc: ", detract(hp->h_cc, 0)), GCC); } if (gflags & GBCC) { hp->h_bcc = extract(readtty("Bcc: ", detract(hp->h_bcc, 0)), GBCC); } *************** *** 133,145 **** signal(SIGTSTP, savetstp); signal(SIGTTOU, savettou); signal(SIGTTIN, savettin); - #ifndef TIOCSTI - ttybuf.c_cc[VERASE] = c_erase; - ttybuf.c_cc[VKILL] = c_kill; - if (ttyset) - tcsetattr(fileno(stdin), TCSADRAIN, &ttybuf); - signal(SIGQUIT, savequit); - #endif signal(SIGINT, saveint); return(errs); } --- 91,96 ---- *************** *** 159,164 **** --- 110,116 ---- int c; register char *cp, *cp2; void ttystop(); + struct ttyinput ti; fputs(pr, stdout); fflush(stdout); *************** *** 166,192 **** printf("too long to edit\n"); 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++) { ! if ((c_erase != _POSIX_VDISABLE && c == c_erase) || ! (c_kill != _POSIX_VDISABLE && c == c_kill)) { ! ch = '\\'; ! ioctl(0, TIOCSTI, &ch); ! } ! ch = c; ! ioctl(0, TIOCSTI, &ch); } cp = canonb; *cp = 0; - #endif cp2 = cp; while (cp2 < canonb + BUFSIZ) *cp2++ = 0; --- 118,140 ---- printf("too long to edit\n"); return(src); } ! ! /* ! * Removed workarounds for truly ancient tty drivers; changed ! * editing to use TIOCSINPUT instead of faking a keystroke for ! * each character in the line (and trying to escape control ! * characters with backslashes, which hasn't worked in ages). ! */ ! ! if (src != NOSTR) { ! ti.ti_text = src; ! ti.ti_len = strlen(src); ! ti.ti_magic = 0; /* force override */ ! ioctl (0, TIOCSINPUT, &ti); } + cp = canonb; *cp = 0; cp2 = cp; while (cp2 < canonb + BUFSIZ) *cp2++ = 0; *************** *** 213,250 **** 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) { - if (cp2 == canonb) - continue; - if (cp2[-1] == '\\') { - cp2[-1] = c; - continue; - } - cp2--; - continue; - } - if (c_kill != _POSIX_VDISABLE && c == c_kill) { - if (cp2 == canonb) - continue; - if (cp2[-1] == '\\') { - cp2[-1] = c; - continue; - } - cp2 = canonb; - continue; - } - *cp2++ = c; - } - *cp2 = '\0'; - #endif if (equal("", canonb)) return(NOSTR); return(savestr(canonb)); --- 161,166 ---- Only in usr.bin/mail: tty.o Only in usr.bin/mail: v7.local.o Only in usr.bin/mail: vars.o Only in usr.bin/mail: version.o