[BACK]Return to ttyio.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/ttyio.c between version 1.23 and 1.24

version 1.23, 2002/09/15 14:08:57 version 1.24, 2003/11/09 00:23:01
Line 22 
Line 22 
 #define TCSASOFT        0  #define TCSASOFT        0
 #endif  #endif
   
   int     ttstarted;
 char    obuf[NOBUF];                    /* Output buffer. */  char    obuf[NOBUF];                    /* Output buffer. */
 int     nobuf;                          /* Buffer count. */  int     nobuf;                          /* Buffer count. */
 struct  termios oldtty;                 /* POSIX tty settings. */  struct  termios oldtty;                 /* POSIX tty settings. */
Line 37 
Line 38 
 void  void
 ttopen(void)  ttopen(void)
 {  {
   
         if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))          if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
                 panic("standard input and output must be a terminal");                  panic("standard input and output must be a terminal");
   
Line 55 
Line 55 
 int  int
 ttraw(void)  ttraw(void)
 {  {
   
         if (tcgetattr(0, &oldtty) < 0) {          if (tcgetattr(0, &oldtty) < 0) {
                 ewprintf("ttopen can't get terminal attributes");                  ewprintf("ttopen can't get terminal attributes");
                 return (FALSE);                  return (FALSE);
Line 82 
Line 81 
                 ewprintf("ttopen can't tcsetattr");                  ewprintf("ttopen can't tcsetattr");
                 return (FALSE);                  return (FALSE);
         }          }
           ttstarted = 1;
   
         return (TRUE);          return (TRUE);
 }  }
   
Line 94 
Line 95 
 void  void
 ttclose(void)  ttclose(void)
 {  {
         if (ttcooked() == FALSE)          if (ttstarted) {
                 panic("");              /* ttcooked() already printf'd */                  if (ttcooked() == FALSE)
                           panic("");      /* ttcooked() already printf'd */
                   ttstarted = 0;
           }
 }  }
   
 /*  /*
Line 187 
Line 191 
 void  void
 panic(char *s)  panic(char *s)
 {  {
           ttclose();
         (void) fputs("panic: ", stderr);          (void) fputs("panic: ", stderr);
         (void) fputs(s, stderr);          (void) fputs(s, stderr);
         (void) fputc('\n', stderr);          (void) fputc('\n', stderr);

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24