[BACK]Return to stackmachine.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Diff for /OpenXM/src/kan96xx/Kan/stackmachine.c between version 1.33 and 1.39

version 1.33, 2005/07/18 10:55:16 version 1.39, 2015/10/08 11:49:37
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/stackmachine.c,v 1.32 2005/07/03 11:08:54 ohara Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/stackmachine.c,v 1.38 2015/09/29 01:52:14 takayama Exp $ */
 /*   stackmachin.c */  /*   stackmachin.c */
   
 #include <stdio.h>  #include <stdio.h>
Line 12 
Line 12 
 #include <signal.h>  #include <signal.h>
 #include <sys/types.h>  #include <sys/types.h>
   
   /* The msys2 seems to make a buffer overflow of  EnvOfStackmachine[].
   The code
   [(x) ring_of_differential_operators 11] define_ring
   ( Dx*(x+Dx) ) /ff set
   causes the segfault because Mp_zero is borken. Is it a bug of msys2?
   Anyway, the following definition seems to be a workaround. 2015.09
   Singnals do not work properly on msys2. (gcc -dM -E ... to see macros defs)
   See stackm.h
   */
   
 /* #define OPERAND_STACK_SIZE  2000 */  /* #define OPERAND_STACK_SIZE  2000 */
 #define OPERAND_STACK_SIZE 30000  #define OPERAND_STACK_SIZE 30000
Line 89  int OXlockSaved = 0;
Line 98  int OXlockSaved = 0;
 char *UD_str;  char *UD_str;
 int  UD_attr;  int  UD_attr;
   
   struct object *MsgStackTraceInArrayp = NULL;
 char *MsgStackTrace = NULL;  char *MsgStackTrace = NULL;
 char *MsgSourceTrace = NULL;  char *MsgSourceTrace = NULL;
   
Line 791  void scanner() {
Line 801  void scanner() {
   initSystemDictionary();    initSystemDictionary();
   
 #if defined(__CYGWIN__)  #if defined(__CYGWIN__)
   if (sigsetjmp(EnvOfStackMachine,1)) {    if (MYSIGSETJMP(EnvOfStackMachine,1)) {
 #else  #else
   if (setjmp(EnvOfStackMachine)) {    if (MYSETJMP(EnvOfStackMachine)) {
 #endif  #endif
     /* do nothing in the case of error */      /* do nothing in the case of error */
     fprintf(stderr,"An error or interrupt in reading macros, files and command strings.\n");      fprintf(stderr,"An error or interrupt in reading macros, files and command strings.\n");
Line 855  void scanner() {
Line 865  void scanner() {
   
   for (;;) {    for (;;) {
 #if defined(__CYGWIN__)  #if defined(__CYGWIN__)
     if (jval=sigsetjmp(EnvOfStackMachine,1)) {      if (jval=MYSIGSETJMP(EnvOfStackMachine,1)) {
 #else  #else
     if (jval=setjmp(EnvOfStackMachine)) {      if (jval=MYSETJMP(EnvOfStackMachine)) {
 #endif  #endif
       /* ***  The following does not work properly.  ****        /* ***  The following does not work properly.  ****
          if (jval == 2) {           if (jval == 2) {
Line 953  void ctrlC(sig)
Line 963  void ctrlC(sig)
   getokenSM(INIT); /* It might fix the bug above. 1992/11/14 */    getokenSM(INIT); /* It might fix the bug above. 1992/11/14 */
   signal(SIGINT,ctrlC);    signal(SIGINT,ctrlC);
 #if defined(__CYGWIN__)  #if defined(__CYGWIN__)
   siglongjmp(EnvOfStackMachine,2);    MYSIGLONGJMP(EnvOfStackMachine,2);
 #else  #else
   longjmp(EnvOfStackMachine,2); /* returns 2 for ctrl-C */    MYLONGJMP(EnvOfStackMachine,2); /* returns 2 for ctrl-C */
 #endif  #endif
 }  }
   
Line 1064  int executeToken(token)
Line 1074  int executeToken(token)
             return(0); /* normal exit.*/              return(0); /* normal exit.*/
           }            }
                 }                  }
         if (WarningMessageMode == 1 || WarningMessageMode == 2) {          {
           char tmpc[1024];            char tmpc[1024];
           if (strlen(token.token) < 900) {            if (strlen(token.token) < 900) {
             sprintf(tmpc,"\n%%Warning: The identifier <<%s>> is not in the system dictionary\n%%   nor in the user dictionaries. Push NullObject.\n",token.token);              sprintf(tmpc,"\n>>Warning: The identifier <<%s>> is not in the system dictionary\n>>   nor in the user dictionaries. Push NullObject.\n",token.token);
           }else {strcpy(tmpc,"Warning: identifier is not in the dictionaries.");}            }else {strcpy(tmpc,"\n>>Warning: identifier is not in the dictionaries.\n");}
           pushErrorStack(KnewErrorPacket(SerialCurrent,-1,tmpc));            /* do not use %% in a string. tmpc will be used as  fprintf(stderr,tmpc); */
             if (WarningMessageMode == 1 || WarningMessageMode == 2) {
               pushErrorStack(KnewErrorPacket(SerialCurrent,-1,tmpc));
             }
             if (WarningMessageMode != 1) {
               fprintf(Fstack,"%s",tmpc);
               /*fprintf(Fstack,"(%d,%d)\n",h0,h1);*/
             }
             if (Strict) {
               errorStackmachine(tmpc);
             }
             Kpush(NullObject);
         }          }
         if (WarningMessageMode != 1) {  
           fprintf(Fstack,"\n%%Warning: The identifier <<%s>> is not in the system dictionary\n%%   nor in the user dictionaries. Push NullObject.\n",token.token);  
           /*fprintf(Fstack,"(%d,%d)\n",h0,h1);*/  
         }  
         if (Strict) {  
           errorStackmachine("Warning: identifier is not in the dictionaries");  
         }  
         Kpush(NullObject);  
       }        }
     }      }
   } else if (token.kind == EXECUTABLE_STRING) {    } else if (token.kind == EXECUTABLE_STRING) {
Line 1149  errorStackmachine(str)
Line 1162  errorStackmachine(str)
       fprintf(stderr,str);        fprintf(stderr,str);
     }      }
     fprintf(stderr,"\n");      fprintf(stderr,"\n");
           MsgStackTraceInArrayp = traceNameStackToArrayp();
     MsgStackTrace = traceShowStack();      MsgStackTrace = traceShowStack();
     MsgSourceTrace = traceShowScannerBuf();      MsgSourceTrace = traceShowScannerBuf();
   }    }
Line 1160  errorStackmachine(str)
Line 1174  errorStackmachine(str)
   stdOperandStack(); contextControl(CCRESTORE);    stdOperandStack(); contextControl(CCRESTORE);
   getokenSM(INIT); /* It might fix the bug. 1996/3/10 */    getokenSM(INIT); /* It might fix the bug. 1996/3/10 */
   /* fprintf(stderr,"Now, Long jump!\n"); */    /* fprintf(stderr,"Now, Long jump!\n"); */
   longjmp(EnvOfStackMachine,1);    MYLONGJMP(EnvOfStackMachine,1);
 }  }
   
 warningStackmachine(str)  warningStackmachine(str)
Line 1212  KSexecuteString(s)
Line 1226  KSexecuteString(s)
   if (KSPushEnvMode) {    if (KSPushEnvMode) {
     *saved_EnvOfStackMachine = *EnvOfStackMachine;      *saved_EnvOfStackMachine = *EnvOfStackMachine;
 #if defined(__CYGWIN__)  #if defined(__CYGWIN__)
     if (jval = sigsetjmp(EnvOfStackMachine,1)) {      if (jval = MYSIGSETJMP(EnvOfStackMachine,1)) {
 #else  #else
     if (jval = setjmp(EnvOfStackMachine)) {      if (jval = MYSETJMP(EnvOfStackMachine)) {
 #endif  #endif
       *EnvOfStackMachine = *saved_EnvOfStackMachine;        *EnvOfStackMachine = *saved_EnvOfStackMachine;
       if (jval == 2) {        if (jval == 2) {
Line 1236  KSexecuteString(s)
Line 1250  KSexecuteString(s)
   }else{    }else{
     if (recursive == 0) {      if (recursive == 0) {
 #if defined(__CYGWIN__)  #if defined(__CYGWIN__)
       if (jval=sigsetjmp(EnvOfStackMachine,1)) {        if (jval=MYSIGSETJMP(EnvOfStackMachine,1)) {
 #else  #else
       if (jval=setjmp(EnvOfStackMachine)) {        if (jval=MYSETJMP(EnvOfStackMachine)) {
 #endif  #endif
         if (jval == 2) {          if (jval == 2) {
           if (ErrorMessageMode == 1 || ErrorMessageMode == 2) {            if (ErrorMessageMode == 1 || ErrorMessageMode == 2) {
Line 1310  void KSstart() {
Line 1324  void KSstart() {
   /* The following line may cause a core dump, if you do not setjmp properly    /* The following line may cause a core dump, if you do not setjmp properly
      after calling KSstart().*/       after calling KSstart().*/
   /*    /*
     if (setjmp(EnvOfStackMachine)) {      if (MYSETJMP(EnvOfStackMachine)) {
     fprintf(stderr,"KSstart(): An error or interrupt in reading macros, files and command strings.\n");      fprintf(stderr,"KSstart(): An error or interrupt in reading macros, files and command strings.\n");
     exit(10);      exit(10);
     } else {  }  */      } else {  }  */
Line 1395  char *KSpopBinary(int *size) {
Line 1409  char *KSpopBinary(int *size) {
   return((char *)NULL);    return((char *)NULL);
 }  }
   
   struct object KSnewObjectArray(int k) {
      return newObjectArray(k);
   }
   
 int pushErrorStack(struct object obj)  int pushErrorStack(struct object obj)
 {  {
   if (CurrentOperandStack == &ErrorStack) {    if (CurrentOperandStack == &ErrorStack) {
Line 1633  void traceClearStack(void) {
Line 1651  void traceClearStack(void) {
 char *tracePopName(void) {  char *tracePopName(void) {
   if (TraceNameStackp <= 0) return (char *) NULL;    if (TraceNameStackp <= 0) return (char *) NULL;
   return TraceNameStack[--TraceNameStackp];    return TraceNameStack[--TraceNameStackp];
   }
   struct object *traceNameStackToArrayp(void) {
     int n,i;
     struct object *op;
     op = sGC_malloc(sizeof(struct object));
     n = TraceNameStackp; if (n < 0) n = 0;
     *op = newObjectArray(n);
     for (i=0; i<n; i++) {
           putoa((*op),i, KpoString(TraceNameStack[i]));
     }
     return op;
 }  }
 #define TRACE_MSG_SIZE 320  #define TRACE_MSG_SIZE 320
 char *traceShowStack(void) {  char *traceShowStack(void) {

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.39

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>