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

Diff for /src/usr.bin/less/screen.c between version 1.4 and 1.5

version 1.4, 1997/11/12 04:40:51 version 1.5, 1997/11/12 06:28:26
Line 107 
Line 107 
         *sc_deinit;             /* Exit terminal de-initialization */          *sc_deinit;             /* Exit terminal de-initialization */
   
 static int init_done = 0;  static int init_done = 0;
   static int tty_fd = -1;
   
 public int auto_wrap;           /* Terminal does \r\n when write past margin */  public int auto_wrap;           /* Terminal does \r\n when write past margin */
 public int ignaw;               /* Terminal ignores \n immediately after wrap */  public int ignaw;               /* Terminal ignores \n immediately after wrap */
Line 165 
Line 166 
   
         if (on == curr_on)          if (on == curr_on)
                 return;                  return;
   
           if (tty_fd == -1 && (tty_fd = open("/dev/tty", O_RDWR)) < 0)
                   tty_fd = 2;
   
 #if OS2  #if OS2
         signal(SIGINT, SIG_IGN);          signal(SIGINT, SIG_IGN);
         erase_char = '\b';          erase_char = '\b';
Line 180 
Line 185 
                 /*                  /*
                  * Get terminal modes.                   * Get terminal modes.
                  */                   */
                 tcgetattr(2, &s);                  if (tcgetattr(tty_fd, &s) == -1)
                           return;
   
                 /*                  /*
                  * Save modes and set certain variables dependent on modes.                   * Save modes and set certain variables dependent on modes.
Line 318 
Line 324 
                  */                   */
                 s = save_term;                  s = save_term;
         }          }
         tcsetattr(2, TCSANOW, &s);          if (tcsetattr(tty_fd, TCSANOW, &s) == -1)
                   return;
     }      }
 #else  #else
 #ifdef TCGETA  #ifdef TCGETA
Line 331 
Line 338 
                 /*                  /*
                  * Get terminal modes.                   * Get terminal modes.
                  */                   */
                 ioctl(2, TCGETA, &s);                  ioctl(tty_fd, TCGETA, &s);
   
                 /*                  /*
                  * Save modes and set certain variables dependent on modes.                   * Save modes and set certain variables dependent on modes.
Line 363 
Line 370 
                  */                   */
                 s = save_term;                  s = save_term;
         }          }
         ioctl(2, TCSETAW, &s);          ioctl(tty_fd, TCSETAW, &s);
     }      }
 #else  #else
     {      {
Line 375 
Line 382 
                 /*                  /*
                  * Get terminal modes.                   * Get terminal modes.
                  */                   */
                 ioctl(2, TIOCGETP, &s);                  ioctl(tty_fd, TIOCGETP, &s);
   
                 /*                  /*
                  * Save modes and set certain variables dependent on modes.                   * Save modes and set certain variables dependent on modes.
Line 400 
Line 407 
                  */                   */
                 s = save_term;                  s = save_term;
         }          }
         ioctl(2, TIOCSETN, &s);          ioctl(tty_fd, TIOCSETN, &s);
     }      }
 #endif  #endif
 #endif  #endif
Line 453 
Line 460 
 #endif  #endif
 #endif  #endif
   
           if (tty_fd == -1 && (tty_fd = open("/dev/tty", O_RDWR)) < 0)
                   tty_fd = 2;
   
 #ifdef TIOCGWINSZ  #ifdef TIOCGWINSZ
         if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)          if (ioctl(tty_fd, TIOCGWINSZ, &w) == 0 && w.ws_row > 0)
                 sc_height = w.ws_row;                  sc_height = w.ws_row;
         else          else
 #else  #else
 #ifdef WIOCGETD  #ifdef WIOCGETD
         if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0)          if (ioctl(tty_fd, WIOCGETD, &w) == 0 && w.uw_height > 0)
                 sc_height = w.uw_height/w.uw_vs;                  sc_height = w.uw_height/w.uw_vs;
         else          else
 #endif  #endif
Line 473 
Line 483 
                 sc_height = 24;                  sc_height = 24;
   
 #ifdef TIOCGWINSZ  #ifdef TIOCGWINSZ
         if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_col > 0)          if (ioctl(tty_fd, TIOCGWINSZ, &w) == 0 && w.ws_col > 0)
                 sc_width = w.ws_col;                  sc_width = w.ws_col;
         else          else
 #ifdef WIOCGETD  #ifdef WIOCGETD
         if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_width > 0)          if (ioctl(tty_fd, WIOCGETD, &w) == 0 && w.uw_width > 0)
                 sc_width = w.uw_width/w.uw_hs;                  sc_width = w.uw_width/w.uw_hs;
         else          else
 #endif  #endif

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5