=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/signal.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/less/signal.c 2001/11/19 19:02:14 1.3 --- src/usr.bin/less/signal.c 2003/04/13 18:26:26 1.4 *************** *** 1,29 **** - /* $OpenBSD: signal.c,v 1.3 2001/11/19 19:02:14 mpech Exp $ */ - /* ! * Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman ! * All rights reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * 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 ! * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ! * 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. */ --- 1,11 ---- /* ! * Copyright (C) 1984-2002 Mark Nudelman * ! * You may distribute under the terms of either the GNU General Public ! * License or the Less License, as specified in the README file. * ! * For more information about less, or for information on how to ! * contact the author, see the README file. */ *************** *** 61,70 **** int type; { #if OS2 ! SIGNAL(SIGINT, SIG_ACK); #endif ! SIGNAL(SIGINT, u_interrupt); sigs |= S_INTERRUPT; if (reading) intread(); } --- 43,61 ---- int type; { #if OS2 ! LSIGNAL(SIGINT, SIG_ACK); #endif ! LSIGNAL(SIGINT, u_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) intread(); } *************** *** 78,84 **** stop(type) int type; { ! SIGNAL(SIGTSTP, stop); sigs |= S_STOP; if (reading) intread(); --- 69,75 ---- stop(type) int type; { ! LSIGNAL(SIGTSTP, stop); sigs |= S_STOP; if (reading) intread(); *************** *** 94,100 **** winch(type) int type; { ! SIGNAL(SIGWINCH, winch); sigs |= S_WINCH; if (reading) intread(); --- 85,91 ---- winch(type) int type; { ! LSIGNAL(SIGWINCH, winch); sigs |= S_WINCH; if (reading) intread(); *************** *** 109,115 **** winch(type) int type; { ! SIGNAL(SIGWIND, winch); sigs |= S_WINCH; if (reading) intread(); --- 100,106 ---- winch(type) int type; { ! LSIGNAL(SIGWIND, winch); sigs |= S_WINCH; if (reading) intread(); *************** *** 117,123 **** --- 108,137 ---- #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. */ public void *************** *** 129,160 **** /* * Set signal handlers. */ ! (void) SIGNAL(SIGINT, u_interrupt); #ifdef SIGTSTP ! (void) SIGNAL(SIGTSTP, stop); #endif #ifdef SIGWINCH ! (void) SIGNAL(SIGWINCH, winch); #else #ifdef SIGWIND ! (void) SIGNAL(SIGWIND, winch); #endif #endif } else { /* * Restore signals to defaults. */ ! (void) SIGNAL(SIGINT, SIG_DFL); #ifdef SIGTSTP ! (void) SIGNAL(SIGTSTP, SIG_DFL); #endif #ifdef SIGWINCH ! (void) SIGNAL(SIGWINCH, SIG_IGN); #endif #ifdef SIGWIND ! (void) SIGNAL(SIGWIND, SIG_IGN); #endif } } --- 143,186 ---- /* * Set signal handlers. */ ! (void) LSIGNAL(SIGINT, u_interrupt); ! #if MSDOS_COMPILER==WIN32C ! SetConsoleCtrlHandler(wbreak_handler, TRUE); ! #endif #ifdef SIGTSTP ! (void) LSIGNAL(SIGTSTP, stop); #endif #ifdef SIGWINCH ! (void) LSIGNAL(SIGWINCH, winch); #else #ifdef SIGWIND ! (void) LSIGNAL(SIGWIND, winch); #endif + #ifdef SIGQUIT + (void) LSIGNAL(SIGQUIT, SIG_IGN); #endif + #endif } else { /* * Restore signals to defaults. */ ! (void) LSIGNAL(SIGINT, SIG_DFL); ! #if MSDOS_COMPILER==WIN32C ! SetConsoleCtrlHandler(wbreak_handler, FALSE); ! #endif #ifdef SIGTSTP ! (void) LSIGNAL(SIGTSTP, SIG_DFL); #endif #ifdef SIGWINCH ! (void) LSIGNAL(SIGWINCH, SIG_IGN); #endif #ifdef SIGWIND ! (void) LSIGNAL(SIGWIND, SIG_IGN); #endif + #ifdef SIGQUIT + (void) LSIGNAL(SIGQUIT, SIG_DFL); + #endif } } *************** *** 165,171 **** public void psignals() { ! int tsignals; if ((tsignals = sigs) == 0) return; --- 191,197 ---- public void psignals() { ! register int tsignals; if ((tsignals = sigs) == 0) return; *************** *** 178,193 **** * Clean up the terminal. */ #ifdef SIGTTOU ! SIGNAL(SIGTTOU, SIG_IGN); #endif clear_bot(); deinit(); flush(); raw_mode(0); #ifdef SIGTTOU ! SIGNAL(SIGTTOU, SIG_DFL); #endif ! SIGNAL(SIGTSTP, SIG_DFL); kill(getpid(), SIGTSTP); /* * ... Bye bye. ... --- 204,219 ---- * Clean up the terminal. */ #ifdef SIGTTOU ! LSIGNAL(SIGTTOU, SIG_IGN); #endif clear_bot(); deinit(); flush(); raw_mode(0); #ifdef SIGTTOU ! LSIGNAL(SIGTTOU, SIG_DFL); #endif ! LSIGNAL(SIGTSTP, SIG_DFL); kill(getpid(), SIGTSTP); /* * ... Bye bye. ... *************** *** 195,201 **** * Reset the terminal and arrange to repaint the * screen when we get back to the main command loop. */ ! SIGNAL(SIGTSTP, stop); raw_mode(1); init(); screen_trashed = 1; --- 221,227 ---- * Reset the terminal and arrange to repaint the * screen when we get back to the main command loop. */ ! LSIGNAL(SIGTSTP, stop); raw_mode(1); init(); screen_trashed = 1;