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

Diff for /src/usr.bin/less/signal.c between version 1.3 and 1.4

version 1.3, 2001/11/19 19:02:14 version 1.4, 2003/04/13 18:26:26
Line 1 
Line 1 
 /*      $OpenBSD$       */  
   
 /*  /*
  * Copyright (c) 1984,1985,1989,1994,1995  Mark Nudelman   * Copyright (C) 1984-2002  Mark Nudelman
  * All rights reserved.  
  *   *
  * Redistribution and use in source and binary forms, with or without   * You may distribute under the terms of either the GNU General Public
  * modification, are permitted provided that the following conditions   * License or the Less License, as specified in the README file.
  * are met:  
  * 1. Redistributions of source code must retain the above copyright  
  *    notice, this list of conditions and the following disclaimer.  
  * 2. Redistributions in binary form must reproduce the above copyright  
  *    notice in the documentation and/or other materials provided with  
  *    the distribution.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY   * For more information about less, or for information on how to
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   * contact the author, see the README file.
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE  
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  
  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN  
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  */   */
   
   
Line 61 
Line 43 
         int type;          int type;
 {  {
 #if OS2  #if OS2
         SIGNAL(SIGINT, SIG_ACK);          LSIGNAL(SIGINT, SIG_ACK);
 #endif  #endif
         SIGNAL(SIGINT, u_interrupt);          LSIGNAL(SIGINT, u_interrupt);
         sigs |= S_INTERRUPT;          sigs |= S_INTERRUPT;
   #if MSDOS_COMPILER==DJGPPC
           /*
            * If a keyboard has been hit, it must be Ctrl-C
            * (as opposed to Ctrl-Break), so consume it.
            * (Otherwise, Less will beep when it sees Ctrl-C from keyboard.)
            */
           if (kbhit())
                   getkey();
   #endif
         if (reading)          if (reading)
                 intread();                  intread();
 }  }
Line 78 
Line 69 
 stop(type)  stop(type)
         int type;          int type;
 {  {
         SIGNAL(SIGTSTP, stop);          LSIGNAL(SIGTSTP, stop);
         sigs |= S_STOP;          sigs |= S_STOP;
         if (reading)          if (reading)
                 intread();                  intread();
Line 94 
Line 85 
 winch(type)  winch(type)
         int type;          int type;
 {  {
         SIGNAL(SIGWINCH, winch);          LSIGNAL(SIGWINCH, winch);
         sigs |= S_WINCH;          sigs |= S_WINCH;
         if (reading)          if (reading)
                 intread();                  intread();
Line 109 
Line 100 
 winch(type)  winch(type)
         int type;          int type;
 {  {
         SIGNAL(SIGWIND, winch);          LSIGNAL(SIGWIND, winch);
         sigs |= S_WINCH;          sigs |= S_WINCH;
         if (reading)          if (reading)
                 intread();                  intread();
Line 117 
Line 108 
 #endif  #endif
 #endif  #endif
   
   #if MSDOS_COMPILER==WIN32C
 /*  /*
    * Handle CTRL-C and CTRL-BREAK keys.
    */
   #include "windows.h"
   
           static BOOL WINAPI
   wbreak_handler(dwCtrlType)
           DWORD dwCtrlType;
   {
           switch (dwCtrlType)
           {
           case CTRL_C_EVENT:
           case CTRL_BREAK_EVENT:
                   sigs |= S_INTERRUPT;
                   return (TRUE);
           default:
                   break;
           }
           return (FALSE);
   }
   #endif
   
   /*
  * Set up the signal handlers.   * Set up the signal handlers.
  */   */
         public void          public void
Line 129 
Line 143 
                 /*                  /*
                  * Set signal handlers.                   * Set signal handlers.
                  */                   */
                 (void) SIGNAL(SIGINT, u_interrupt);                  (void) LSIGNAL(SIGINT, u_interrupt);
   #if MSDOS_COMPILER==WIN32C
                   SetConsoleCtrlHandler(wbreak_handler, TRUE);
   #endif
 #ifdef SIGTSTP  #ifdef SIGTSTP
                 (void) SIGNAL(SIGTSTP, stop);                  (void) LSIGNAL(SIGTSTP, stop);
 #endif  #endif
 #ifdef SIGWINCH  #ifdef SIGWINCH
                 (void) SIGNAL(SIGWINCH, winch);                  (void) LSIGNAL(SIGWINCH, winch);
 #else  #else
 #ifdef SIGWIND  #ifdef SIGWIND
                 (void) SIGNAL(SIGWIND, winch);                  (void) LSIGNAL(SIGWIND, winch);
 #endif  #endif
   #ifdef SIGQUIT
                   (void) LSIGNAL(SIGQUIT, SIG_IGN);
 #endif  #endif
   #endif
         } else          } else
         {          {
                 /*                  /*
                  * Restore signals to defaults.                   * Restore signals to defaults.
                  */                   */
                 (void) SIGNAL(SIGINT, SIG_DFL);                  (void) LSIGNAL(SIGINT, SIG_DFL);
   #if MSDOS_COMPILER==WIN32C
                   SetConsoleCtrlHandler(wbreak_handler, FALSE);
   #endif
 #ifdef SIGTSTP  #ifdef SIGTSTP
                 (void) SIGNAL(SIGTSTP, SIG_DFL);                  (void) LSIGNAL(SIGTSTP, SIG_DFL);
 #endif  #endif
 #ifdef SIGWINCH  #ifdef SIGWINCH
                 (void) SIGNAL(SIGWINCH, SIG_IGN);                  (void) LSIGNAL(SIGWINCH, SIG_IGN);
 #endif  #endif
 #ifdef SIGWIND  #ifdef SIGWIND
                 (void) SIGNAL(SIGWIND, SIG_IGN);                  (void) LSIGNAL(SIGWIND, SIG_IGN);
 #endif  #endif
   #ifdef SIGQUIT
                   (void) LSIGNAL(SIGQUIT, SIG_DFL);
   #endif
         }          }
 }  }
   
Line 165 
Line 191 
         public void          public void
 psignals()  psignals()
 {  {
         int tsignals;          register int tsignals;
   
         if ((tsignals = sigs) == 0)          if ((tsignals = sigs) == 0)
                 return;                  return;
Line 178 
Line 204 
                  * Clean up the terminal.                   * Clean up the terminal.
                  */                   */
 #ifdef SIGTTOU  #ifdef SIGTTOU
                 SIGNAL(SIGTTOU, SIG_IGN);                  LSIGNAL(SIGTTOU, SIG_IGN);
 #endif  #endif
                 clear_bot();                  clear_bot();
                 deinit();                  deinit();
                 flush();                  flush();
                 raw_mode(0);                  raw_mode(0);
 #ifdef SIGTTOU  #ifdef SIGTTOU
                 SIGNAL(SIGTTOU, SIG_DFL);                  LSIGNAL(SIGTTOU, SIG_DFL);
 #endif  #endif
                 SIGNAL(SIGTSTP, SIG_DFL);                  LSIGNAL(SIGTSTP, SIG_DFL);
                 kill(getpid(), SIGTSTP);                  kill(getpid(), SIGTSTP);
                 /*                  /*
                  * ... Bye bye. ...                   * ... Bye bye. ...
Line 195 
Line 221 
                  * Reset the terminal and arrange to repaint the                   * Reset the terminal and arrange to repaint the
                  * screen when we get back to the main command loop.                   * screen when we get back to the main command loop.
                  */                   */
                 SIGNAL(SIGTSTP, stop);                  LSIGNAL(SIGTSTP, stop);
                 raw_mode(1);                  raw_mode(1);
                 init();                  init();
                 screen_trashed = 1;                  screen_trashed = 1;

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