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

Diff for /OpenXM/src/kxx/sm1stackmachine.c between version 1.1.1.1 and 1.9

version 1.1.1.1, 1999/10/08 02:12:13 version 1.9, 2020/10/07 07:47:23
Line 1 
Line 1 
 #include <stdio.h>  #include <stdio.h>
 #include <setjmp.h>  #include <setjmp.h>
   #include <stdlib.h>
 #include "ox_kan.h"  #include "ox_kan.h"
 #include "serversm.h"  #include "serversm.h"
 extern int OXprintMessage;  extern int OXprintMessage;
   extern char *MsgStackTrace;
   extern char *MsgSourceTrace;
   extern struct object *MsgStackTraceInArrayp;
   
   void KSstart(); // kan96xx/Kan/datatype.h
   int KSexecuteString(char *s); // kan96xx/Kan/datatype.h
   int Kan_pushCMOFromStream(FILE2 *fp); //kan96xx/Kan/plugin.h
   int Kan_popCMOToStream(FILE2 *fp,int serial); //
   int KgetCmoTagOfObject(struct object obj);    //
   int KSstackPointer(void); //kan96xx/Kan/extern.h
   int Kan_setMathCapToStream(FILE2 *fp,struct object ob); // kan96xx/plugin/cmo.c
   
   
 /*  server stack machine */  /*  server stack machine */
   
 int Sm1_start(int argc, char *fnames[],char *myname) {  int Sm1_start(int argc, char *fnames[],char *myname) {
Line 31  int Sm1_start(int argc, char *fnames[],char *myname) {
Line 44  int Sm1_start(int argc, char *fnames[],char *myname) {
     for (i=0; i<argc; i++) {      for (i=0; i<argc; i++) {
       /* load files from the search path */        /* load files from the search path */
       if (strlen(fnames[i]) > 1024) {        if (strlen(fnames[i]) > 1024) {
         fprintf(stderr,"Too long name for sm1 library file to load.\n");          fprintf(stderr,"Too long name for sm1 library file to load.\n");
         exit(10);          exit(10);
       }        }
       sprintf(cmd," [(parse) (%s) pushfile ] extension pop ",fnames[i]);        sprintf(cmd," [(parse) (%s) pushfile ] extension pop ",fnames[i]);
       KSexecuteString(cmd);        KSexecuteString(cmd);
Line 57  int Sm1_setMathCap(ox_stream os) {
Line 70  int Sm1_setMathCap(ox_stream os) {
   /* Set the mathcap data of the client in the server. */    /* Set the mathcap data of the client in the server. */
   /*  sm1 <====== ox_sm1  mathcap is set in ox_stream = FILE2 * */    /*  sm1 <====== ox_sm1  mathcap is set in ox_stream = FILE2 * */
   /* The mathcap data is on the stack. */    /* The mathcap data is on the stack. */
   struct object ob;    struct object ob = OINIT;
   struct object ob2;    struct object ob2 = OINIT;
   int n,i;    int n,i;
   ob = KSpop();    ob = KSpop();
   KSpush(ob);  KSexecuteString(" (mathcap data is ) message message ");    KSpush(ob);  KSexecuteString(" (mathcap data is ) message message ");
Line 93  char *Sm1_popString(void) {
Line 106  char *Sm1_popString(void) {
 int Sm1_setName(void)  int Sm1_setName(void)
 {  {
   char *s;    char *s;
   struct object ob;    struct object ob = OINIT;
   s = Sm1_popString();    s = Sm1_popString();
   if (s == NULL) {    if (s == NULL) {
     printf("NULL argument for setName.\n");      printf("NULL argument for setName.\n");
Line 109  int Sm1_setName(void)
Line 122  int Sm1_setName(void)
 int Sm1_evalName(void)  int Sm1_evalName(void)
 {  {
   char *s;    char *s;
   struct object ob;    struct object ob = OINIT;
   s = Sm1_popString();    s = Sm1_popString();
   if (s == NULL) {    if (s == NULL) {
     printf("NULL argument for evalName.\n");      printf("NULL argument for evalName.\n");
Line 137  int Sm1_popCMO(ox_stream fp,int serial)
Line 150  int Sm1_popCMO(ox_stream fp,int serial)
   
 int Sm1_pushError2(int serial, int no, char *s)  int Sm1_pushError2(int serial, int no, char *s)
 {  {
   struct object ob;    struct object ob = OINIT;
   ob = KnewErrorPacket(serial,no,s);    struct object core = OINIT;
     struct object core1 = OINIT;
     char *ss;
   
     ss = (char *)sGC_malloc(strlen(s)+1);
     strcpy(ss,s);
     /*
     char *error_message="<ox103:error_message>";
     char *message="<ox103:message>";
     char *stack_trace="<ox103:stack_trace>";
     char *source_trace="<ox103:source_trace>";
     char *error_message2="</ox103:error_message>";
     char *message2="</ox103:message>";
     char *stack_trace2="</ox103:stack_trace>";
     char *source_trace2="</ox103:source_trace>";
     ss = (char *) sGC_malloc(strlen(s)+strlen(MsgStackTrace)+
                              strlen(MsgSourceTrace)+
                              strlen(error_message)+strlen(error_message2)+
                              strlen(message)+strlen(message2)+
                              strlen(stack_trace)+strlen(stack_trace2)+
                              strlen(source_trace)+strlen(source_trace2)+2);
   
     strcat(ss,error_message);
     strcat(ss,message);
     strcat(ss,s);
     strcat(ss,message2);
     if (MsgStackTrace != NULL) {
           strcat(ss,stack_trace);
           strcat(ss,MsgStackTrace);
           strcat(ss,stack_trace2);
     }
     if (MsgSourceTrace != NULL) {
           strcat(ss,source_trace);
           strcat(ss,MsgSourceTrace);
           strcat(ss,source_trace2);
     }
     strcat(ss,error_message2);
     */
   
     if (MsgStackTraceInArrayp != NULL) {
           core = KSnewObjectArray(2);
           core1 = KSnewObjectArray(2);
           putoa(core1,0,KpoString("where"));  /* keyword */
           putoa(core1,1,(*MsgStackTraceInArrayp));
       putoa(core,0,core1);
       core1 = KSnewObjectArray(2);
           putoa(core1,0,KpoString("reason_of_error")); /* keyword */
           putoa(core1,1,KpoString(s));
           putoa(core,1,core1);
     }else{
           core = KSnewObjectArray(0);
     }
     ob = KSnewObjectArray(4);
     putoa(ob,0,KpoInteger(serial)); putoa(ob,1,KpoInteger(no));
     putoa(ob,2,KpoString(ss));
     putoa(ob,3,core);
   
     ob = KnewErrorPacketObj(ob);
   KSpush(ob);    KSpush(ob);
 }  }
   
Line 176  void Sm1_dupErrors(void) {
Line 246  void Sm1_dupErrors(void) {
   KSpush(KSdupErrors());    KSpush(KSdupErrors());
 }  }
   
   void Sm1_pushCMOtag(int serial) {
     struct object obj = OINIT;
     int t;
     obj = KSpeek(0);
     t = KgetCmoTagOfObject(obj);
     if (t != -1) {
       KSpush(KpoInteger(t));
     }else{
       Sm1_pushError2(serial,-1,"The top object on the server stack cannot be translated to cmo.");
     }
   }
   
   

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.9

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