From: Hans-Bernhard B. <br...@us...> - 2004-02-12 18:18:24
|
Update of /cvsroot/cscope/cscope/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30676/src Modified Files: display.c Log Message: Fix Ctrl-C handler working only once per session. Index: display.c =================================================================== RCS file: /cvsroot/cscope/cscope/src/display.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** display.c 8 Jan 2004 14:07:20 -0000 1.23 --- display.c 12 Feb 2004 18:13:14 -0000 1.24 *************** *** 55,58 **** --- 55,64 ---- #include <stdarg.h> + #ifndef HAVE_SIGSETJMP + # define sigsetjmp(a,b) setjmp(a) + # define siglongjmp(a,b) longjmp(a,b) + # typedef jmp_buf sigjmp_buf; + #endif + static char const rcsid[] = "$Id$"; *************** *** 77,81 **** static int fldline; /* input field line */ ! static jmp_buf env; /* setjmp/longjmp buffer */ static int lastdispline; /* last displayed reference line */ static char lastmsg[MSGLEN + 1]; /* last message displayed */ --- 83,87 ---- static int fldline; /* input field line */ ! static sigjmp_buf env; /* setjmp/longjmp buffer */ static int lastdispline; /* last displayed reference line */ static char lastmsg[MSGLEN + 1]; /* last message displayed */ *************** *** 400,404 **** * helps... */ signal(sig, jumpback); ! longjmp(env, 1); } --- 406,410 ---- * helps... */ signal(sig, jumpback); ! siglongjmp(env, 1); } *************** *** 414,418 **** BOOL funcexist = YES; /* find "function" error */ FINDINIT rc = NOERROR; /* findinit return code */ ! RETSIGTYPE (*savesig)(int); /* old value of signal */ FP f; /* searching function */ int c, i; --- 420,424 ---- BOOL funcexist = YES; /* find "function" error */ FINDINIT rc = NOERROR; /* findinit return code */ ! sighandler_t savesig; /* old value of signal */ FP f; /* searching function */ int c, i; *************** *** 427,437 **** } searchcount = 0; ! if (setjmp(env) == 0) { ! savesig = signal(SIGINT, jumpback); f = fields[field].findfcn; if (f == findregexp || f == findstring) { findresult = (*f)(pattern); ! } ! else { if ((nonglobalrefs = myfopen(temp2, "wb")) == NULL) { cannotopen(temp2); --- 433,442 ---- } searchcount = 0; ! savesig = signal(SIGINT, jumpback); ! if (sigsetjmp(env,1) == 0) { f = fields[field].findfcn; if (f == findregexp || f == findstring) { findresult = (*f)(pattern); ! } else { if ((nonglobalrefs = myfopen(temp2, "wb")) == NULL) { cannotopen(temp2); *************** *** 447,453 **** /* append the non-global references */ (void) fclose(nonglobalrefs); ! if ( (nonglobalrefs = myfopen(temp2, "rb")) == NULL) { ! cannotopen(temp2); ! return(NO); } while ((c = getc(nonglobalrefs)) != EOF) { --- 452,459 ---- /* append the non-global references */ (void) fclose(nonglobalrefs); ! if ((nonglobalrefs = myfopen(temp2, "rb")) ! == NULL) { ! cannotopen(temp2); ! return(NO); } while ((c = getc(nonglobalrefs)) != EOF) { *************** *** 465,469 **** /* reopen the references found file for reading */ (void) fclose(refsfound); ! if ( (refsfound = myfopen(temp1, "rb")) == NULL) { cannotopen(temp1); return(NO); --- 471,475 ---- /* reopen the references found file for reading */ (void) fclose(refsfound); ! if ((refsfound = myfopen(temp1, "rb")) == NULL) { cannotopen(temp1); return(NO); *************** *** 477,498 **** if (findresult != NULL) { (void) sprintf(lastmsg, "Egrep %s in this pattern: %s", ! findresult, pattern); ! } ! else if (rc == NOTSYMBOL) { (void) sprintf(lastmsg, "This is not a C symbol: %s", ! pattern); ! } ! else if (rc == REGCMPERROR) { (void) sprintf(lastmsg, "Error in this regcomp(3) regular expression: %s", ! pattern); ! } ! else if (funcexist == NO) { (void) sprintf(lastmsg, "Function definition does not exist: %s", ! pattern); ! } ! else { (void) sprintf(lastmsg, "Could not find the %s: %s", ! fields[field].text2, pattern); } return(NO); --- 483,500 ---- if (findresult != NULL) { (void) sprintf(lastmsg, "Egrep %s in this pattern: %s", ! findresult, pattern); ! } else if (rc == NOTSYMBOL) { (void) sprintf(lastmsg, "This is not a C symbol: %s", ! pattern); ! } else if (rc == REGCMPERROR) { (void) sprintf(lastmsg, "Error in this regcomp(3) regular expression: %s", ! pattern); ! } else if (funcexist == NO) { (void) sprintf(lastmsg, "Function definition does not exist: %s", ! pattern); ! } else { (void) sprintf(lastmsg, "Could not find the %s: %s", ! fields[field].text2, pattern); } return(NO); |