Return to BSD News archive
Xref: sserve comp.os.386bsd.questions:2219 comp.os.386bsd.bugs:687 Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!doc.ic.ac.uk!pipex!uknet!mcsun!fuug!kiae!bitcom!kiae!relcom!newsserv From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su> Newsgroups: comp.os.386bsd.questions,comp.os.386bsd.bugs Subject: Re: [386bsd/PK2.3] stty and pass8 bug Date: Wed, 05 May 93 22:39:47 +0400 Distribution: world Organization: Ha-olahm Yetzirah Message-ID: <jLpd0whOZ2@astral.msk.su> Sender: news-service@newcom.kiae.su Reply-To: ache@astral.msk.su Keywords: stty, cs8, pass8 References: <1s5icaINN9ig@frigate.doc.ic.ac.uk> Lines: 232 In comp.os.386bsd.questions,comp.os.386bsd.bugs article <1s5icaINN9ig@frigate.doc.ic.ac.uk> Kostis Dryllerakis writes: >This problem has insisted on its existance since the first days of 386bsd. >If you want stty to unset the istrip flag and change to cs8 it will do so >happily (stty pass8 will do). But it seems that as soon as a program >accessing the tty is called (e.g. vi, more, less) the settings revert back >to cs7 and istrip! In comp.inix.bsd article <RHbBb9hSE0@astral.msk.su> I write: >Hi, folks. >Main problem are, that in switching to RAW or CBREAK modes and >back tty driver lost some flags and some flags are incorrect. >The most significant bug is lost CS8 character size. > >Advantages: >1) Can preserve CS8 mode >2) Can preserve ISTRIP mode in CS8 mode >3) Can preserve parity modes in CS7 mode >4) LITOUT mode doesn't stuck. >5) Can preserve IXANY mode > >Disadvantages: >1) Using POSIX tty ioctls mixed with old-style ioctl >cause wrong results (present in original driver). >2) Can't handle output parity without corresponding input >parity, if even or odd parity set (impossible in old-style ioctls). >3) Using TIOCLGET after stty and may produce wrong results. >IMHO, it doesn't matter, because all programs I seen first get all >modes, then set. >In original driver using TIOCLGET before gtty may produce wrong results. *** tty_compat.c.was Wed Dec 25 00:24:09 1991 --- tty_compat.c Wed Dec 9 05:45:34 1992 *************** *** 98,104 **** } sg->sg_erase = cc[VERASE]; sg->sg_kill = cc[VKILL]; ! sg->sg_flags = ttcompatgetflags(tp); break; } --- 98,104 ---- } sg->sg_erase = cc[VERASE]; sg->sg_kill = cc[VKILL]; ! sg->sg_flags = tp->t_flags = ttcompatgetflags(tp); break; } *************** *** 195,201 **** return (ttioctl(tp, TIOCSETA, &term, flag)); } case TIOCLGET: ! *(int *)data = ttcompatgetflags(tp)>>16; if (ttydebug) printf("CLGET: returning %x\n", *(int *)data); break; --- 195,203 ---- return (ttioctl(tp, TIOCSETA, &term, flag)); } case TIOCLGET: ! tp->t_flags = ! (ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff); ! *(int *)data = tp->t_flags>>16; if (ttydebug) printf("CLGET: returning %x\n", *(int *)data); break; *************** *** 234,261 **** flags |= TANDEM; if (iflag&ICRNL || oflag&ONLCR) flags |= CRMOD; ! if (cflag&PARENB) { ! if (iflag&INPCK) { if (cflag&PARODD) flags |= ODDP; else 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; } if (oflag&OXTABS) flags |= XTABS; if (lflag&ECHOE) --- 236,262 ---- flags |= TANDEM; if (iflag&ICRNL || oflag&ONLCR) flags |= CRMOD; ! if ((cflag&CSIZE) == CS8) { ! flags |= PASS8; ! if (iflag&ISTRIP) ! flags |= ANYP; ! } ! else if (iflag&INPCK || cflag&PARENB) { if (cflag&PARODD) flags |= ODDP; else flags |= EVENP; } if ((lflag&ICANON) == 0) { /* fudge */ ! if (oflag&OPOST || iflag&ISTRIP || iflag&IXON || lflag&ISIG || lflag&IEXTEN || cflag&PARENB || iflag&INPCK || (cflag&CSIZE) != CS8) flags |= CBREAK; else flags |= RAW; } + if (!(flags&RAW) && !(oflag&OPOST) && (!(cflag&PARENB) || (cflag&CSIZE) == CS8)) + flags |= LITOUT; if (oflag&OXTABS) flags |= XTABS; if (lflag&ECHOE) *************** *** 285,291 **** register long cflag = t->c_cflag; if (flags & RAW) { ! iflag &= IXOFF; oflag &= ~OPOST; lflag &= ~(ECHOCTL|ISIG|ICANON|IEXTEN); } else { --- 286,292 ---- register long cflag = t->c_cflag; if (flags & RAW) { ! iflag &= (IXOFF|IXANY); oflag &= ~OPOST; lflag &= ~(ECHOCTL|ISIG|ICANON|IEXTEN); } else { *************** *** 313,328 **** else lflag &= ~ECHO; - if (flags&(RAW|LITOUT|PASS8)) { cflag &= ~(CSIZE|PARENB); cflag |= CS8; ! if ((flags&(RAW|PASS8)) == 0) iflag |= ISTRIP; else iflag &= ~ISTRIP; } else { ! cflag &= ~CSIZE; ! cflag |= CS7|PARENB; iflag |= ISTRIP; } if ((flags&(EVENP|ODDP)) == EVENP) { --- 314,330 ---- else lflag &= ~ECHO; cflag &= ~(CSIZE|PARENB); + if (flags&(RAW|LITOUT|PASS8)) { cflag |= CS8; ! if (!(flags&(RAW|PASS8)) || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP)) iflag |= ISTRIP; else iflag &= ~ISTRIP; } else { ! cflag |= CS7; ! if ((flags&(EVENP|ODDP)) && (flags&ANYP) != ANYP) ! cflag |= PARENB; iflag |= ISTRIP; } if ((flags&(EVENP|ODDP)) == EVENP) { *************** *** 377,394 **** lflag &= ~IXANY; lflag &= ~(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH); lflag |= flags&(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH); - if (flags&(LITOUT|PASS8)) { - iflag &= ~ISTRIP; cflag &= ~(CSIZE|PARENB); cflag |= CS8; ! if (flags&LITOUT) oflag &= ~OPOST; ! if ((flags&(PASS8|RAW)) == 0) iflag |= ISTRIP; } else if ((flags&RAW) == 0) { ! cflag &= ~CSIZE; ! cflag |= CS7|PARENB; ! oflag |= OPOST; } t->c_iflag = iflag; t->c_oflag = oflag; --- 379,400 ---- lflag &= ~IXANY; lflag &= ~(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH); lflag |= flags&(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH); cflag &= ~(CSIZE|PARENB); + if (flags&(LITOUT|PASS8)) { cflag |= CS8; ! if (flags&(LITOUT|RAW)) oflag &= ~OPOST; ! else ! oflag |= OPOST; ! if (!(flags&(RAW|PASS8)) || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP)) iflag |= ISTRIP; + else + iflag &= ~ISTRIP; } else if ((flags&RAW) == 0) { ! cflag |= CS7; ! if ((flags&(EVENP|ODDP)) && (flags&ANYP) != ANYP) ! cflag |= PARENB; ! oflag |= ISTRIP|OPOST; } t->c_iflag = iflag; t->c_oflag = oflag; -- In-This-Life: Andrew A. Chernov | "Hay mas dicha, mas contento Internet: ache@astral.msk.su | "Que adorar una hermosura FIDOnet: 2:5020/23.34 | "Brujuleada entre los lejos RELCOM Development Team, Moscow, Russia | "De lo imposible?!" (Calderon)