=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/ox_texmacs.c,v retrieving revision 1.44 retrieving revision 1.48 diff -u -p -r1.44 -r1.48 --- OpenXM/src/kxx/ox_texmacs.c 2019/03/28 21:19:49 1.44 +++ OpenXM/src/kxx/ox_texmacs.c 2020/10/07 07:47:23 1.48 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kxx/ox_texmacs.c,v 1.43 2019/03/28 09:21:40 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kxx/ox_texmacs.c,v 1.47 2019/09/25 06:30:37 takayama Exp $ */ #include #include @@ -19,6 +19,11 @@ #define LONGJMP(env,p) MYLONGJMP(env,p) #endif +void KSstart(); // kan96xx/Kan/datatype.h +void KSstart_quiet(); // kan96xx/Kan/datatype.h +int KSexecuteString(char *s); // kan96xx/Kan/datatype.h + + /* #define DEBUG */ @@ -158,13 +163,17 @@ static void pngNotAvailable(void); static char *pngGetResult(); 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 Debug output to understand the timing problem of pipe interface. */ FILE *Dfp; -main(int argc,char *argv[]) { +void main(int argc,char *argv[]) { char *s; char *r; char *sys; @@ -502,6 +511,10 @@ static char *readString(FILE *fp, char *prolog, char * } } */ + if (View == V_JUPYTER) { + s[n++] = c; s[n] = 0; m++; + INC_BUF ; + } break; } if ( c == '\v') c=' '; @@ -510,17 +523,18 @@ static char *readString(FILE *fp, char *prolog, char * } if ((c == EOF) && (start == n)) exit(0); /* Check the escape sequence */ - if (strcmp(&(s[start]),"!quit;") == 0) { + if (mystrncmp(&(s[start]),"!quit;") == 0) { printv("Terminated the process ox_texmacs.\n"); exit(0); } 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"); exit(0); } 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++]=')'; s[n]=0; INC_BUF; } @@ -577,8 +591,8 @@ static char *readString(FILE *fp, char *prolog, char * } /* 2019.03.28 for jupyter */ - if ((strncmp(&(s[start]),"base_prompt",strlen("base_prompt")) != 0) - &&(strncmp(&(s[start]),"version()",strlen("version()")) != 0)) { + if ((View == V_JUPYTER) && (mystrncmp(&(s[start]),"base_prompt") != 0) + &&(mystrncmp(&(s[start]),"version()") != 0)) { if (Sss == NULL) { Sss = (char *)sGC_malloc(Sss_size); Sss[0] = 0; @@ -625,6 +639,9 @@ static char *readString(FILE *fp, char *prolog, char * s[n++] = epilog[i]; s[n] = 0; INC_BUF ; } +#ifdef DEBUG2 + fprintf(Dfp,"#By normal readString:%s\n",s); hexout(Dfp,s); fprintf(Dfp,"\n"); fflush(Dfp); +#endif return s; } @@ -649,7 +666,7 @@ static void printv(char *s) { printf("%s",s); printf("%s",Data_end[View]); #ifdef DEBUG2 - fprintf(Dfp,"<%s>",s); fflush(Dfp); + fprintf(Dfp,"printv:<%s>",s); fflush(Dfp); #endif fflush(NULL); } @@ -836,3 +853,30 @@ static void pngNotAvailable(void) { 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