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