home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / bsd / 10151 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  7.1 KB

  1. Path: sparky!uunet!mcsun!fuug!kiae!demos!newsserv
  2. From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
  3. Resent-From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
  4. Newsgroups: comp.unix.bsd
  5. Subject: [386bsd] 3rd patch for tty COMPAT_43 modes (great win!)
  6. Date: Wed, 09 Dec 92 23:11:17 +0300
  7. Distribution: world
  8. Organization: Ha-oh-lahm Yetzirah
  9. Message-ID: <RHbBb9hSE0@astral.msk.su>
  10. Sender: news-service@newcom.kiae.su
  11. Reply-To: ache@astral.msk.su
  12. Lines: 243
  13.  
  14. Hi, folks.
  15. Main problem are, that in switching to RAW or CBREAK modes and
  16. back tty driver lost some flags and some flags are incorrect.
  17. The most significant bug is lost CS8 character size.
  18.  
  19. I produce two patches to fix it, but problem are deeper.
  20. In 3rd patch I decide return back to original driver concept,
  21. use tp->t_flag field and completely rewrite old patches.
  22. Now, if program call gtty, modes stored into tp->t_flag,
  23. for later stty call.
  24.  
  25. Advantages:
  26. 1) Can preserve CS8 mode
  27. 2) Can preserve ISTRIP mode in CS8 mode
  28. 3) Can preserve parity modes in CS7 mode
  29. 4) LITOUT mode doesn't stuck.
  30. 5) Can preserve IXANY mode
  31.  
  32. Disadvantages:
  33. 1) Using POSIX tty ioctls mixed with old-style ioctl
  34. cause wrong results (present in original driver).
  35. 2) Can't handle output parity without corresponding input
  36. parity, if even or odd parity set (impossible in old-style ioctls).
  37. 3) Using TIOCLGET after stty and may produce wrong results.
  38. IMHO, it doesn't matter, because all programs I seen first get all
  39. modes, then set.
  40. In original driver using TIOCLGET before gtty may produce wrong results.
  41.  
  42. WARNING: apply this patch ONLY if two previous my patches installed.
  43. Because my patches goes so far I just produce united (1-3) patch
  44. in separate message.
  45.  
  46. *** tty_compat.c.was2    Wed Dec  2 23:05:17 1992
  47. --- tty_compat.c    Wed Dec  9 05:45:34 1992
  48. ***************
  49. *** 98,104 ****
  50.           }
  51.           sg->sg_erase = cc[VERASE];
  52.           sg->sg_kill = cc[VKILL];
  53. !         sg->sg_flags = ttcompatgetflags(tp);
  54.           break;
  55.       }
  56.   
  57. --- 98,104 ----
  58.           }
  59.           sg->sg_erase = cc[VERASE];
  60.           sg->sg_kill = cc[VKILL];
  61. !         sg->sg_flags = tp->t_flags = ttcompatgetflags(tp);
  62.           break;
  63.       }
  64.   
  65. ***************
  66. *** 119,125 ****
  67.               term.c_ospeed = compatspcodes[speed];
  68.           term.c_cc[VERASE] = sg->sg_erase;
  69.           term.c_cc[VKILL] = sg->sg_kill;
  70. !         tp->t_flags = ttcompatgetflags(tp)&0xffff0000 | sg->sg_flags&0xffff;
  71.           ttcompatsetflags(tp, &term);
  72.           return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA, 
  73.               &term, flag));
  74. --- 119,125 ----
  75.               term.c_ospeed = compatspcodes[speed];
  76.           term.c_cc[VERASE] = sg->sg_erase;
  77.           term.c_cc[VKILL] = sg->sg_kill;
  78. !         tp->t_flags = tp->t_flags&0xffff0000 | sg->sg_flags&0xffff;
  79.           ttcompatsetflags(tp, &term);
  80.           return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA, 
  81.               &term, flag));
  82. ***************
  83. *** 182,190 ****
  84.   
  85.           term = tp->t_termios;
  86.           if (com == TIOCLSET)
  87. !             tp->t_flags = (ttcompatgetflags(tp)&0xffff) | *(int *)data<<16;
  88.           else {
  89. !             tp->t_flags = ttcompatgetflags(tp);
  90.               if (com == TIOCLBIS)
  91.                   tp->t_flags |= *(int *)data<<16;
  92.               else
  93. --- 182,191 ----
  94.   
  95.           term = tp->t_termios;
  96.           if (com == TIOCLSET)
  97. !             tp->t_flags = (tp->t_flags&0xffff) | *(int *)data<<16;
  98.           else {
  99. !             tp->t_flags = 
  100. !              (ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff);
  101.               if (com == TIOCLBIS)
  102.                   tp->t_flags |= *(int *)data<<16;
  103.               else
  104. ***************
  105. *** 194,200 ****
  106.           return (ttioctl(tp, TIOCSETA, &term, flag));
  107.       }
  108.       case TIOCLGET:
  109. !         *(int *)data = ttcompatgetflags(tp)>>16;
  110.           if (ttydebug)
  111.               printf("CLGET: returning %x\n", *(int *)data);
  112.           break;
  113. --- 195,203 ----
  114.           return (ttioctl(tp, TIOCSETA, &term, flag));
  115.       }
  116.       case TIOCLGET:
  117. !         tp->t_flags =
  118. !          (ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff);
  119. !         *(int *)data = tp->t_flags>>16;
  120.           if (ttydebug)
  121.               printf("CLGET: returning %x\n", *(int *)data);
  122.           break;
  123. ***************
  124. *** 233,253 ****
  125.           flags |= TANDEM;
  126.       if (iflag&ICRNL || oflag&ONLCR)
  127.           flags |= CRMOD;
  128. !     if (cflag&PARENB) {
  129. !         if (iflag&INPCK) {
  130.               if (cflag&PARODD)
  131.                   flags |= ODDP;
  132.               else
  133.                   flags |= EVENP;
  134. -         } else
  135. -             flags |= EVENP | ODDP;
  136.       }
  137. -     if ((cflag&CSIZE) == CS8 && !(iflag&ISTRIP))
  138. -         flags |= PASS8;
  139.       
  140.       if ((lflag&ICANON) == 0) {    
  141.           /* fudge */
  142. !         if (oflag&OPOST || iflag&ISTRIP || iflag&IXON || lflag&ISIG || lflag&IEXTEN || (cflag&PARENB) && (cflag&CSIZE) != CS8)
  143.               flags |= CBREAK;
  144.           else
  145.               flags |= RAW;
  146. --- 236,256 ----
  147.           flags |= TANDEM;
  148.       if (iflag&ICRNL || oflag&ONLCR)
  149.           flags |= CRMOD;
  150. !     if ((cflag&CSIZE) == CS8) {
  151. !         flags |= PASS8;
  152. !         if (iflag&ISTRIP)
  153. !             flags |= ANYP;
  154. !     }
  155. !     else if (iflag&INPCK || cflag&PARENB) {
  156.           if (cflag&PARODD)
  157.               flags |= ODDP;
  158.           else
  159.               flags |= EVENP;
  160.       }
  161.       
  162.       if ((lflag&ICANON) == 0) {    
  163.           /* fudge */
  164. !         if (oflag&OPOST || iflag&ISTRIP || iflag&IXON || lflag&ISIG || lflag&IEXTEN || cflag&PARENB || iflag&INPCK || (cflag&CSIZE) != CS8)
  165.               flags |= CBREAK;
  166.           else
  167.               flags |= RAW;
  168. ***************
  169. *** 311,327 ****
  170.       else
  171.           lflag &= ~ECHO;
  172.           
  173. -     if (flags&(RAW|LITOUT|PASS8)) {
  174.           cflag &= ~(CSIZE|PARENB);
  175.           cflag |= CS8;
  176. !         if ((flags&(RAW|PASS8)) == 0)
  177.               iflag |= ISTRIP;
  178.           else
  179.               iflag &= ~ISTRIP;
  180.       } else {
  181. -         cflag &= ~CSIZE;
  182.           cflag |= CS7;
  183. !         if (flags&(ODDP|EVENP))
  184.               cflag |= PARENB;
  185.           iflag |= ISTRIP;
  186.       }
  187. --- 314,329 ----
  188.       else
  189.           lflag &= ~ECHO;
  190.           
  191.       cflag &= ~(CSIZE|PARENB);
  192. +     if (flags&(RAW|LITOUT|PASS8)) {
  193.           cflag |= CS8;
  194. !         if (!(flags&(RAW|PASS8)) || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP))
  195.               iflag |= ISTRIP;
  196.           else
  197.               iflag &= ~ISTRIP;
  198.       } else {
  199.           cflag |= CS7;
  200. !         if ((flags&(EVENP|ODDP)) && (flags&ANYP) != ANYP)
  201.               cflag |= PARENB;
  202.           iflag |= ISTRIP;
  203.       }
  204. ***************
  205. *** 377,396 ****
  206.           lflag &= ~IXANY;
  207.       lflag &= ~(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
  208.       lflag |= flags&(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
  209. -     if (flags&(LITOUT|PASS8)) {
  210. -         iflag &= ~ISTRIP;
  211.           cflag &= ~(CSIZE|PARENB);
  212.           cflag |= CS8;
  213. !         if (flags&LITOUT)
  214.               oflag &= ~OPOST;
  215. !         if ((flags&(PASS8|RAW)) == 0)
  216.               iflag |= ISTRIP;
  217.       } else if ((flags&RAW) == 0) {
  218. -         cflag &= ~CSIZE;
  219.           cflag |= CS7;
  220. !         if (flags&(ODDP|EVENP))
  221.               cflag |= PARENB;
  222. !         oflag |= OPOST;
  223.       }
  224.       t->c_iflag = iflag;
  225.       t->c_oflag = oflag;
  226. --- 379,400 ----
  227.           lflag &= ~IXANY;
  228.       lflag &= ~(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
  229.       lflag |= flags&(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
  230.       cflag &= ~(CSIZE|PARENB);
  231. +     if (flags&(LITOUT|PASS8)) {
  232.           cflag |= CS8;
  233. !         if (flags&(LITOUT|RAW))
  234.               oflag &= ~OPOST;
  235. !         else
  236. !             oflag |= OPOST;
  237. !         if (!(flags&(RAW|PASS8)) || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP))
  238.               iflag |= ISTRIP;
  239. +         else
  240. +             iflag &= ~ISTRIP;
  241.       } else if ((flags&RAW) == 0) {
  242.           cflag |= CS7;
  243. !         if ((flags&(EVENP|ODDP)) && (flags&ANYP) != ANYP)
  244.               cflag |= PARENB;
  245. !         oflag |= ISTRIP|OPOST;
  246.       }
  247.       t->c_iflag = iflag;
  248.       t->c_oflag = oflag;
  249. -- 
  250. In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
  251. Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
  252. Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
  253.                Moscow, Russia       |  "De lo imposible?!"  (Calderon)
  254.  
  255.  
  256.  
  257.