version 1.43, 2019/03/28 09:21:40 |
version 1.45, 2019/05/24 02:25:12 |
|
|
/* $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.44 2019/03/28 21:19:49 takayama Exp $ */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
Line 158 static void pngNotAvailable(void); |
|
Line 158 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. |
*/ |
*/ |
Line 502 static char *readString(FILE *fp, char *prolog, char * |
|
Line 506 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 518 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 586 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 ((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 602 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 634 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 661 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 848 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; |
|
} |
|
|