Return to BSD News archive
Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.hawaii.edu!ames!sun-barr!cs.utexas.edu!uunet!mcsun!fuug!kiae!demos!newsserv From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su> Newsgroups: comp.unix.bsd Subject: Patch tty driver for correct handle COMPAT_43 tty modes Date: Fri, 27 Nov 92 00:33:59 +0300 Distribution: world Organization: Ha-oh-lahm Yetzirah Message-ID: <hF7BK5hiH1@astral.msk.su> Sender: news-service@newcom.kiae.su Reply-To: ache@astral.msk.su Keywords: COMPAT_43 386bsd tty driver Lines: 153 Hi, I found this bug in following situation: my current tty modes: -parity cs8 -istrip When I call any program that use CBREAK (COMPAT_43) mode, tty modes resets to: cs7 parenb istrip, so, I lost my 8-bit characters. I produce this patch to fix this and some more situations. I made COMPAT_43 modes and POSIX modes as close as possible. *** tty_compat.c.was Wed Dec 25 01:24:09 1991 --- tty_compat.c Thu Nov 26 22:38:06 1992 *************** *** 119,125 **** term.c_ospeed = compatspcodes[speed]; term.c_cc[VERASE] = sg->sg_erase; term.c_cc[VKILL] = sg->sg_kill; ! tp->t_flags = tp->t_flags&0xffff0000 | sg->sg_flags&0xffff; ttcompatsetflags(tp, &term); return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA, &term, flag)); --- 119,125 ---- term.c_ospeed = compatspcodes[speed]; term.c_cc[VERASE] = sg->sg_erase; term.c_cc[VKILL] = sg->sg_kill; ! tp->t_flags = ttcompatgetflags(tp)&0xffff0000 | sg->sg_flags&0xffff; ttcompatsetflags(tp, &term); return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA, &term, flag)); *************** *** 182,191 **** term = tp->t_termios; if (com == TIOCLSET) ! tp->t_flags = (tp->t_flags&0xffff) | *(int *)data<<16; else { ! tp->t_flags = ! (ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff); if (com == TIOCLBIS) tp->t_flags |= *(int *)data<<16; else --- 182,190 ---- term = tp->t_termios; if (com == TIOCLSET) ! tp->t_flags = (ttcompatgetflags(tp)&0xffff) | *(int *)data<<16; else { ! tp->t_flags = ttcompatgetflags(tp); if (com == TIOCLBIS) tp->t_flags |= *(int *)data<<16; else *************** *** 242,257 **** flags |= EVENP; } else flags |= EVENP | ODDP; - } else { - if ((tp->t_flags&LITOUT) && !(oflag&OPOST)) - flags |= LITOUT; - if (tp->t_flags&PASS8) - flags |= PASS8; } if ((lflag&ICANON) == 0) { /* fudge */ ! if (iflag&IXON || lflag&ISIG || lflag&IEXTEN || cflag&PARENB) flags |= CBREAK; else flags |= RAW; --- 241,255 ---- flags |= EVENP; } else flags |= EVENP | ODDP; } + if (!(oflag&OPOST) && (!(cflag&PARENB) || (cflag&CSIZE) == CS8)) + flags |= LITOUT; + if ((cflag&CSIZE) == CS8 && !(iflag&ISTRIP)) + flags |= PASS8; if ((lflag&ICANON) == 0) { /* fudge */ ! if (oflag&OPOST || iflag&ISTRIP || iflag&IXON || lflag&ISIG || lflag&IEXTEN || (cflag&PARENB) && (cflag&CSIZE) != CS8) flags |= CBREAK; else flags |= RAW; *************** *** 322,328 **** iflag &= ~ISTRIP; } else { cflag &= ~CSIZE; ! cflag |= CS7|PARENB; iflag |= ISTRIP; } if ((flags&(EVENP|ODDP)) == EVENP) { --- 320,328 ---- iflag &= ~ISTRIP; } else { cflag &= ~CSIZE; ! cflag |= CS7; ! if (flags&(ODDP|EVENP)) ! cflag |= PARENB; iflag |= ISTRIP; } if ((flags&(EVENP|ODDP)) == EVENP) { *************** *** 387,393 **** iflag |= ISTRIP; } else if ((flags&RAW) == 0) { cflag &= ~CSIZE; ! cflag |= CS7|PARENB; oflag |= OPOST; } t->c_iflag = iflag; --- 387,395 ---- iflag |= ISTRIP; } else if ((flags&RAW) == 0) { cflag &= ~CSIZE; ! cflag |= CS7; ! if (flags&(ODDP|EVENP)) ! cflag |= PARENB; oflag |= OPOST; } t->c_iflag = iflag; *** tty_tb.c.was Thu Nov 26 21:21:46 1992 --- tty_tb.c Thu Nov 26 21:29:48 1992 *************** *** 117,123 **** tp->t_inbuf = 0; bzero((caddr_t)&tbp->rets, sizeof (tbp->rets)); tp->T_LINEP = (caddr_t)tbp; ! tp->t_flags |= LITOUT; return (0); } --- 117,127 ---- tp->t_inbuf = 0; bzero((caddr_t)&tbp->rets, sizeof (tbp->rets)); tp->T_LINEP = (caddr_t)tbp; ! tp->t_flags = ttcompatgetflags(tp); ! if (!(tp->t_flags&(LITOUT|RAW))) { ! tp->t_flags |= LITOUT; ! ttcompatsetlflags(tp, &(tp->t_termios)); ! } return (0); } -- In-This-Life: Andrew A. Chernov | "Hay mas dicha, mas contento Internet: ache@astral.msk.su | "Que adorar una hermosura Organization: The RELCOM Corp., | "Brujuleada entre los lejos Moscow, Russia | "De lo imposible?!" (Calderon)