[BACK]Return to serv2.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_math

Diff for /OpenXM/src/ox_math/Attic/serv2.c between version 1.17 and 1.18

version 1.17, 2000/11/28 20:16:03 version 1.18, 2000/12/03 15:19:23
Line 1 
Line 1 
 /* -*- mode: C; coding: euc-japan -*- */  /* -*- mode: C; coding: euc-japan -*- */
 /* $OpenXM: OpenXM/src/ox_math/serv2.c,v 1.16 2000/10/10 19:58:30 ohara Exp $ */  /* $OpenXM: OpenXM/src/ox_math/serv2.c,v 1.17 2000/11/28 20:16:03 ohara Exp $ */
   
 /*  /*
    Copyright (C) Katsuyoshi OHARA, 2000.     Copyright (C) Katsuyoshi OHARA, 2000.
Line 26 
Line 26 
 extern int flag_mlo_symbol;  extern int flag_mlo_symbol;
   
 /* MathLink independent */  /* MathLink independent */
 #define INIT_S_SIZE 2048  
 #define EXT_S_SIZE  2048  
   
 static int stack_size = 0;  
 static int stack_pointer = 0;  
 static cmo **stack = NULL;  static cmo **stack = NULL;
   static int stack_size = 0;
   static int stack_ptr = 0;
   OXFILE *stack_oxfp = NULL;
   
 int initialize_stack()  #define DIFFERENCE_OF_STACK  1024
 {  
     stack_pointer = 0;  
         stack_size = INIT_S_SIZE;  
         stack = malloc(stack_size*sizeof(cmo*));  
 }  
   
 static int extend_stack()  static void stack_extend()
 {  {
         int size2 = stack_size + EXT_S_SIZE;      int newsize = stack_size + DIFFERENCE_OF_STACK;
         cmo **stack2 = malloc(size2*sizeof(cmo*));      cmo **newstack = (cmo **)malloc(sizeof(cmo *)*newsize);
         memcpy(stack2, stack, stack_size*sizeof(cmo *));      if (stack != NULL) {
         free(stack);          memcpy(newstack, stack, sizeof(cmo *)*stack_size);
         stack = stack2;          free(stack);
         stack_size = size2;      }
       stack_size = newsize;
       stack = newstack;
 }  }
   
 int push(cmo* m)  int push(cmo* m)
Line 62  int push(cmo* m)
Line 57  int push(cmo* m)
         fprintf(stderr, "ox_math:: a %s was pushed.\n", symbol_get_key(symp));          fprintf(stderr, "ox_math:: a %s was pushed.\n", symbol_get_key(symp));
     }      }
 #endif  #endif
     stack[stack_pointer] = m;      if (stack_ptr >= stack_size) {
     stack_pointer++;          stack_extend();
     if (stack_pointer >= stack_size) {  
                 extend_stack();  
     }      }
       stack[stack_ptr] = m;
       stack_ptr++;
 }  }
   
 /* if the stack is empty, then pop() returns (CMO_NULL). */  /* if the stack is empty, then pop() returns (CMO_NULL). */
 cmo* pop()  cmo* pop()
 {  {
     if (stack_pointer > 0) {      if (stack_ptr > 0) {
         stack_pointer--;          return stack[--stack_ptr];
         return stack[stack_pointer];  
     }      }
     return new_cmo_null();      return new_cmo_null();
 }  }
   
 void pops(int n)  void pops(int n)
 {  {
     stack_pointer -= n;      stack_ptr -= n;
     if (stack_pointer < 0) {      if (stack_ptr < 0) {
         stack_pointer = 0;          stack_ptr = 0;
     }      }
 }  }
   
   void push_error(int errcode, cmo* pushback)
   {
       return push((cmo *)make_error_object(errcode, pushback));
   }
   
 /*  /*
    if error occurs, then a sm_*() function returns non-zero and     if error occurs, then a sm_*() function returns non-zero and
    an error obect is set by a function which calls sm_*().     an error obect is set by a function which calls sm_*().
Line 173  int sm_executeStringByLocalParser(OXFILE* oxfp)
Line 172  int sm_executeStringByLocalParser(OXFILE* oxfp)
             /* for mathematica */              /* for mathematica */
             /* Sending the string `s' to mathematica for its evaluation. */              /* Sending the string `s' to mathematica for its evaluation. */
             ml_evaluateStringByLocalParser(s);              ml_evaluateStringByLocalParser(s);
                         ml_select();              ml_select();
             push(receive_mlo());              push(receive_mlo());
         }          }
         return 0;          return 0;
Line 207  int sm_executeFunction(OXFILE* oxfp)
Line 206  int sm_executeFunction(OXFILE* oxfp)
         argv[i] = pop();          argv[i] = pop();
     }      }
     ml_executeFunction(func, argc, argv);      ml_executeFunction(func, argc, argv);
         ml_select();      ml_select();
     push(receive_mlo());      push(receive_mlo());
     return 0;      return 0;
 }  }

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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