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

Diff for /OpenXM/src/kxx/ox_texmacs.c between version 1.43 and 1.48

version 1.43, 2019/03/28 09:21:40 version 1.48, 2020/10/07 07:47:23
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kxx/ox_texmacs.c,v 1.42 2018/09/07 01:21:31 takayama Exp $ */  /* $OpenXM: OpenXM/src/kxx/ox_texmacs.c,v 1.47 2019/09/25 06:30:37 takayama Exp $ */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 19 
Line 19 
 #define LONGJMP(env,p)  MYLONGJMP(env,p)  #define LONGJMP(env,p)  MYLONGJMP(env,p)
 #endif  #endif
   
   void KSstart(); // kan96xx/Kan/datatype.h
   void KSstart_quiet(); // kan96xx/Kan/datatype.h
   int KSexecuteString(char *s); // kan96xx/Kan/datatype.h
   
   
 /*  /*
 #define DEBUG  #define DEBUG
 */  */
Line 158  static void pngNotAvailable(void);
Line 163  static void pngNotAvailable(void);
 static char *pngGetResult();  static char *pngGetResult();
   
 static void flushSm1();  static void flushSm1();
   static int is_substr_of(char a[],char s[]);
   static void hexout(FILE *fp,char s[]);
   static int mystrncmp(char a[],char s[]);
   
   
 /* tail -f /tmp/debug-texmacs.txt  /* tail -f /tmp/debug-texmacs.txt
    Debug output to understand the timing problem of pipe interface.     Debug output to understand the timing problem of pipe interface.
 */  */
 FILE *Dfp;  FILE *Dfp;
   
 main(int argc,char *argv[]) {  void main(int argc,char *argv[]) {
   char *s;    char *s;
   char *r;    char *r;
   char *sys;    char *sys;
Line 502  static char *readString(FILE *fp, char *prolog, char *
Line 511  static char *readString(FILE *fp, char *prolog, char *
         }          }
       }        }
       */        */
         if (View == V_JUPYTER) {
           s[n++] = c; s[n] = 0;  m++;
           INC_BUF ;
         }
       break;        break;
     }      }
     if ( c == '\v') c=' ';      if ( c == '\v') c=' ';
Line 510  static char *readString(FILE *fp, char *prolog, char *
Line 523  static char *readString(FILE *fp, char *prolog, char *
   }    }
   if ((c == EOF) && (start == n)) exit(0);    if ((c == EOF) && (start == n)) exit(0);
   /* Check the escape sequence */    /* Check the escape sequence */
   if (strcmp(&(s[start]),"!quit;") == 0) {    if (mystrncmp(&(s[start]),"!quit;") == 0) {
     printv("Terminated the process ox_texmacs.\n");      printv("Terminated the process ox_texmacs.\n");
     exit(0);      exit(0);
   }    }
   if (((View == V_JUPYTER) || (View == V_SAGE)) &&    if (((View == V_JUPYTER) || (View == V_SAGE)) &&
       ((strcmp(&(s[start]),"quit")==0) || (strcmp(&(s[start]),"quit()")==0))) {        ((mystrncmp(&(s[start]),"quit")==0) || (mystrncmp(&(s[start]),"quit()")==0))) {
     printv("Terminated the process ox_texmacs.\n");      printv("Terminated the process ox_texmacs.\n");
     exit(0);      exit(0);
   }    }
   if ((View == V_JUPYTER) &&    if ((View == V_JUPYTER) &&
       (strcmp(&(s[start]),"version")==0)) {        (mystrncmp(&(s[start]),"version")==0)) {
       strcpy(&(s[start]),"version");
     s[n=strlen(s)]='('; s[++n]=0; INC_BUF;      s[n=strlen(s)]='('; s[++n]=0; INC_BUF;
     s[n++]=')'; s[n]=0; INC_BUF;      s[n++]=')'; s[n]=0; INC_BUF;
   }    }
Line 577  static char *readString(FILE *fp, char *prolog, char *
Line 591  static char *readString(FILE *fp, char *prolog, char *
     }      }
   
     /* 2019.03.28 for jupyter */      /* 2019.03.28 for jupyter */
     if ((strncmp(&(s[start]),"base_prompt",strlen("base_prompt")) != 0)      if ((View == V_JUPYTER) && (mystrncmp(&(s[start]),"base_prompt") != 0)
         &&(strncmp(&(s[start]),"version()",strlen("version()")) != 0)) {          &&(mystrncmp(&(s[start]),"version()") != 0)) {
       if (Sss == NULL) {        if (Sss == NULL) {
           Sss = (char *)sGC_malloc(Sss_size);            Sss = (char *)sGC_malloc(Sss_size);
           Sss[0] = 0;            Sss[0] = 0;
Line 593  static char *readString(FILE *fp, char *prolog, char *
Line 607  static char *readString(FILE *fp, char *prolog, char *
       strcpy(&(Sss[strlen(Sss)]),&(s[start]));        strcpy(&(Sss[strlen(Sss)]),&(s[start]));
       for (i=strlen(Sss); i>=0; i--) {        for (i=strlen(Sss); i>=0; i--) {
         if (Sss[i] < 0x20) continue;          if (Sss[i] < 0x20) continue;
         if (Sss[i] == '#') {          if ((Sss[i] == ';') && (Sss[i-1] == ';')) {
           /* construct s and return s */            /* construct s and return s */
           Sss[i] = ' ';            Sss[i] = ' ';
           s = (char *) sGC_malloc(strlen(Sss)+strlen(prolog)+strlen(epilog)+10);            s = (char *) sGC_malloc(strlen(Sss)+strlen(prolog)+strlen(epilog)+10);
Line 625  static char *readString(FILE *fp, char *prolog, char *
Line 639  static char *readString(FILE *fp, char *prolog, char *
     s[n++] = epilog[i];  s[n] = 0;      s[n++] = epilog[i];  s[n] = 0;
     INC_BUF ;      INC_BUF ;
   }    }
   #ifdef DEBUG2
     fprintf(Dfp,"#By normal readString:%s\n",s); hexout(Dfp,s); fprintf(Dfp,"\n"); fflush(Dfp);
   #endif
   return s;    return s;
 }  }
   
Line 649  static void printv(char *s) {
Line 666  static void printv(char *s) {
   printf("%s",s);    printf("%s",s);
   printf("%s",Data_end[View]);    printf("%s",Data_end[View]);
 #ifdef DEBUG2  #ifdef DEBUG2
   fprintf(Dfp,"<%s>",s); fflush(Dfp);    fprintf(Dfp,"printv:<%s>",s); fflush(Dfp);
 #endif  #endif
   fflush(NULL);    fflush(NULL);
 }  }
Line 836  static void pngNotAvailable(void) {
Line 853  static void pngNotAvailable(void) {
   fflush(NULL);    fflush(NULL);
 }  }
   
   /* Check if a is a substring of s */
   static int is_substr_of(char a[],char s[]) {
     int n,m,i,j;
     n = strlen(s);
     m = strlen(a);
     for (i=0; i<n-m; i++) {
           for (j=0; j<m; j++) {
             if (s[i+j] != a[j]) break;
             if (j == m-1) return 1;
           }
     }
     return 0;
   }
   
   static void hexout(FILE *fp,char s[]) {
     int i;
     for (i=0; i<strlen(s); i++) fprintf(fp,"%2x ",(unsigned char)s[i]);
   }
   static int mystrncmp(char a[],char s[]) {
     int r;
     r=strncmp(a,s,strlen(s));
   #ifdef DEBUG2
     fprintf(Dfp,"mystrncmp(%s,%s)=%d\n",a,s,r); fflush(Dfp);
   #endif
     return r;
   }
   

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.48

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