=================================================================== RCS file: /home/cvs/OpenXM/src/k097/ki.c,v retrieving revision 1.1.1.1 retrieving revision 1.11 diff -u -p -r1.1.1.1 -r1.11 --- OpenXM/src/k097/ki.c 1999/10/08 02:12:15 1.1.1.1 +++ OpenXM/src/k097/ki.c 2016/03/31 06:34:29 1.11 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/k097/ki.c,v 1.10 2016/03/31 05:27:34 takayama Exp $ */ /* ki.c ( kx interpreter ) */ #include @@ -10,14 +11,27 @@ #include "gradedset.h" #include #include +#include +#include +#include "mysig.h" char *getLOAD_K_PATH(); /* from d.h */ +#if defined(__CYGWIN__) +#define JMP_BUF sigjmp_buf +#define SETJMP(env) sigsetjmp(env,1) +#define LONGJMP(env,p) siglongjmp(env,p) +#else +#define JMP_BUF jmp_buf +#define SETJMP(env) setjmp(env) +#define LONGJMP(env,p) longjmp(env,p) +#endif + #ifdef CALLASIR #include "ak0.h" #endif -extern jmp_buf KCenvOfParser; +extern JMP_BUF KCenvOfParser; char Ktmp[10240]; int Ksize = 10240; @@ -31,30 +45,32 @@ extern int DebugMode; sendKan(int p) { static int n = 2; extern int Interactive; - struct object obj; + struct object obj = OINIT; int result; - signal(SIGINT,SIG_IGN); /* Don't jump to ctrlC(). */ - if (p == 10) {printf("In(%d)=",n++); return;} + extern int InSendmsg2; + result=0; + mysignal(SIGINT,SIG_IGN); /* Don't jump to ctrlC(). */ + if (p == 10) {printf("In(%d)= ",n++); return 0;} if (p == 0 && DebugCompiler) printf("sendKan[%s]\n",Kbuff); /* printf("sendKan[%s]\n",Kbuff); */ if (strlen(Kbuff) != 0) { - signal(SIGINT,SIG_DFL); + mysignal(SIGINT,SIG_DFL); result = KSexecuteString(Kbuff); /* fprintf(stderr,"r=%d ",result); */ - signal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ + mysignal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ } /* fprintf(stderr,"r=%d ",result); */ if (result == -1) { - K00recoverFromError(); + K00recoverFromError(); InSendmsg2 = 0; fprintf(stderr,"--- Engine error or interrupt : "); if (DebugMode) { - signal(SIGINT,SIG_DFL); + mysignal(SIGINT,SIG_DFL); KSexecuteString("db.DebugStack setstack "); - signal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ + mysignal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ obj = KSpop(); - signal(SIGINT,SIG_DFL); + mysignal(SIGINT,SIG_DFL); KSexecuteString("stdstack "); - signal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ + mysignal(SIGINT,SIG_IGN); /* Reset SIGINT. Don't jump to ctrlC(). */ if (obj.tag == Sdollar) { fprintf(stderr,"%s\n",obj.lc.str); fprintf(stderr,"\n"); @@ -66,7 +82,8 @@ sendKan(int p) { } #define AFO #ifdef AFO - if (setjmp(KCenvOfParser)) { + if (SETJMP(KCenvOfParser)) { + InSendmsg2=0; fprintf(stderr,"Error: Goto the top level.\n"); parseAfile(stdin); KCparse(); @@ -75,7 +92,7 @@ sendKan(int p) { /* However, it should be rewrited in a future. */ }else{ /* fprintf(stderr,"setjmp\n"); */ } #endif - if (p == 0 && Interactive) printf("In(%d)=",n++); + if (p == 0 && Interactive) printf("In(%d)= ",n++); Kpt=0; Kbuff[0] = '\0'; } @@ -87,7 +104,7 @@ char *s; if (strlen(s)+Kpt >= Ksize) { Ksize = Ksize*2; t = (char *)GC_malloc(sizeof(char)*Ksize); - if (t == (char *)NULL) { fprintf(stderr,"No memory."); exit();} + if (t == (char *)NULL) { fprintf(stderr,"No memory."); exit(1);} strcpy(t,Kbuff); Kbuff = t; } strcpy(&(Kbuff[Kpt]),s); @@ -144,7 +161,7 @@ execFile(char *s) fprintf(stderr,"Fatal error: Cannot open the system macro %s in %s, %s, %s nor %s.\n", s,tname2,tname3,tname4,tname); exit(11); - return; + return 0; } } }