/* $OpenXM: OpenXM/misc/packages/Windows/oxapp.c,v 1.3 2002/01/16 06:47:19 takayama Exp $ */ #include #define LINESIZE 4096 int ThereIsLoad = 0; main(int argc,char *argv[]) { char s[LINESIZE]; int i; int removeSharp = 0; 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 (removeSharp == 0) { printf("end$\n"); } if (checkLoad) { fprintf(stderr,"checkLoad status = %d\n",ThereIsLoad); if (ThereIsLoad) exit(0); else exit(1); } } edit(char s[]) { int k,i,j; char t[LINESIZE*2]; extern int ThereIsLoad; 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; for (i=0; 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; strcpy(s,"\n"); } } find(char *s,char *substr) { int n,m,i,j,k,k0; n = strlen(s); m = strlen(substr); k0 = -1; k = -1; for (i=0; i= 0 && k0 >= 0) { fprintf(stderr,"More than one appearances of %s\n",substr); exit(20); } if (k >= 0) k0 = k; } return k0; } not_separator(c) { if (c >='A' && c <='Z') return 1; if (c >='a' && c <='z') return 1; if (c >='0' && c <='9') return 1; if (c =='_') return 1; return 0; }