=================================================================== RCS file: /home/cvs/OpenXM/misc/packages/Windows/oxapp.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -r1.2 -r1.3 --- OpenXM/misc/packages/Windows/oxapp.c 2002/01/10 03:55:10 1.2 +++ OpenXM/misc/packages/Windows/oxapp.c 2002/01/16 06:47:19 1.3 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/misc/packages/Windows/oxapp.c,v 1.1 2002/01/06 08:47:36 takayama Exp $ */ +/* $OpenXM: OpenXM/misc/packages/Windows/oxapp.c,v 1.2 2002/01/10 03:55:10 takayama Exp $ */ #include #define LINESIZE 4096 @@ -10,31 +10,31 @@ main(int argc,char *argv[]) { int checkLoad = 0; extern ThereIsLoad; for (i=1; i= LINESIZE-1) { - fprintf(stderr,"Too long line.\n"); - exit(20); - } - edit(s); - if (removeSharp && s[0] == '#') { - printf("\n"); - }else{ - printf("%s",s); - } + if (strlen(s) >= LINESIZE-1) { + fprintf(stderr,"Too long line.\n"); + exit(20); + } + edit(s); + if (removeSharp && s[0] == '#') { + printf("\n"); + }else{ + printf("%s",s); + } } if (removeSharp == 0) { - printf("end$\n"); + printf("end$\n"); } if (checkLoad) { - fprintf(stderr,"checkLoad status = %d\n",ThereIsLoad); - if (ThereIsLoad) exit(0); - else exit(1); + fprintf(stderr,"checkLoad status = %d\n",ThereIsLoad); + if (ThereIsLoad) exit(0); + else exit(1); } } @@ -45,45 +45,45 @@ edit(char s[]) { if (strlen(s) == 0) return; t[0] = 0; if ((k = find(s,"load(")) >= 0) { - if (k > 0 && not_separator(s[k-1]) ) return; /* bload */ - /* Heuristic 1 */ - if (k > 0) { - if (s[0] == 'i' && s[1] == 'f') return; /* if ... load */ - } - /* Heuristic 2.A. load(User_asirrc)$ */ - if (find(s,"load(User_asirrc)")>=0) { - s[0] = '\n'; s[1]=0; - return; - } - /* Heuristic 2 */ - if (('A' <= s[k+5]) && (s[k+5] <= 'Z')) { - return; /* load(User_asirrc) */ - } - /* Heuristic 3. load("./"+Fname) in phc */ - if (find(s,"+Fname")>=0) return; + if (k > 0 && not_separator(s[k-1]) ) return; /* bload */ + /* Heuristic 1 */ + if (k > 0) { + if (s[0] == 'i' && s[1] == 'f') return; /* if ... load */ + } + /* Heuristic 2.A. load(User_asirrc)$ */ + if (find(s,"load(User_asirrc)")>=0) { + s[0] = '\n'; s[1]=0; + return; + } + /* Heuristic 2 */ + if (('A' <= s[k+5]) && (s[k+5] <= 'Z')) { + return; /* load(User_asirrc) */ + } + /* Heuristic 3. load("./"+Fname) in phc */ + if (find(s,"+Fname")>=0) return; - for (i=0; i= LINESIZE-1) { - fprintf(stderr,"Too long string %s\n",t); - } - strcpy(s,t); + ThereIsLoad = 1; + j=k+5; + for (i=strlen(t); i= LINESIZE-1) { + fprintf(stderr,"Too long string %s\n",t); + } + strcpy(s,t); } if ((k = find(s,"end$")) >= 0) { - if (k > 0 && not_separator(s[k-1])) return; + if (k > 0 && not_separator(s[k-1])) return; strcpy(s,"\n"); } } @@ -94,17 +94,17 @@ find(char *s,char *substr) { m = strlen(substr); k0 = -1; k = -1; for (i=0; i= 0 && k0 >= 0) { - fprintf(stderr,"More than appearance of %s\n",substr); - exit(20); - } - if (k >= 0) k0 = k; + fprintf(stderr,"More than one appearances of %s\n",substr); + exit(20); + } + if (k >= 0) k0 = k; } return k0; }