17 IncFile(char *s,int st) {strcpy(filename,s);start=st;len=0;};
22 IncFile *findTrueLine(int ln, int *trueline)
29 if (inc.isEmpty()) { *trueline=ln;return(NULL);}
32 if (pom->start>ln) {*trueline=ln;return(NULL);}
34 while ( (pom!=NULL) && (ln>pom->start))
37 if (ln<pom->start+pom->len) {*trueline=ln-pom->start;
46 while (pom1!=NULL) { c1+=pom1->len;pom1=pl.next(); }
47 *trueline=ln-c1; return(NULL);
51 pom1=inc.first();c1=0;
52 while (pom1!=NULL) { c1+=pom1->len;pom1=inc.next(); }
53 *trueline=ln-c1; return(NULL);
58 int main(int argc,char **argv)
61 char mydir[255],ss[255],fname[255];
62 QString poms,poms1,poms2;
70 poms.sprintf("%s",argv[1]);
71 i=poms.findRev('/',poms.length()-1,FALSE);
74 //******* get home directory
78 strcpy(homedir,poms1.data());
80 else strcpy(homedir,"");
82 poms.sprintf("%s",argv[0]);
83 i=poms.findRev('/',poms.length()-1,FALSE);
84 if (i!=-1) poms1=poms.left(i);
85 else poms1.sprintf(".");
86 strcpy(mydir,poms1.data());
88 poms.sprintf("%s",argv[1]);
89 i=poms.findRev(".log",poms.length()-1,FALSE);
91 strcpy(fname,poms1.data());
94 // ********************
96 poms.sprintf("%s/.cmp00",mydir);
97 poms1.sprintf("%s/cmp01.log",mydir);
101 QFile compfile(poms1.data());
102 QFile srcfile(argv[1]);
105 if (!compfile.open(IO_WriteOnly))
106 {fprintf(stdout,"Cannot open temp file to write %s\n",poms1.data());exit(1);}
108 if (!srcfile.open(IO_ReadOnly))
109 {fprintf(stdout,"Cannot open file\n");exit(1);}
111 QTextStream comps(&compfile);
112 QTextStream src(&srcfile);
117 poms = src.readLine();
118 i=poms.find("#include");
120 { // get include file
122 if (i!=-1) j=poms.find('"',i+1);
123 if ((i!=-1) && (j!=-1))
126 poms1=poms.mid(i+1,j-i-1);
127 p=new IncFile((char*)poms1.ascii(),currentline);
128 poms2.sprintf("%s%s",homedir,poms1.data());
129 QFile pomf(poms2.data());
130 if (!pomf.open(IO_ReadOnly))
132 fprintf(stdout,"Cannot open include file: %s\n",poms2.data());
135 QTextStream pomstream(&pomf);
136 while (!pomstream.eof())
138 poms1=pomstream.readLine();
161 poms.sprintf("%s/cmp01.lcd",mydir);
164 sprintf(ss,"%s/loglan %s/cmp01 > %s/.cmp00",mydir,mydir,mydir);
167 fprintf(stdout,"Cannot execute compiler\n");
172 poms1.sprintf("%s.lcd",fname);
174 if (QFile::exists(poms.data()))
176 rename(poms.data(),poms1.data());
178 fprintf(stdout,"Compile ok\n");
179 sprintf(ss,"%s/gen %s",mydir,fname);
182 fprintf(stdout,"Cannot execute generator\n");
185 poms.sprintf("%s.ccd",fname);
186 if (QFile::exists(poms.data())) {unlink(poms1.data());}
190 fprintf(stdout,"Errors\n");
192 poms.sprintf("%s/.cmp00",mydir);
193 QFile err(poms.data());
195 if (!err.open(IO_ReadOnly))
196 { fprintf(stdout,"Cannot open error file\n");
199 QTextStream errstream(&err);
202 poms=errstream.readLine();
203 i=poms.find("LOGLAN-82");
204 while( (!errstream.eof()) && (i==-1))
206 poms=errstream.readLine();
207 i=poms.find("LOGLAN-82");
210 while (!errstream.eof())
212 poms=errstream.readLine();
213 i=poms.find("ERROR");
217 j=poms.findRev(' ',i);
218 poms1=poms.mid(j+1,i-j);
220 fl = findTrueLine(line,&tline);
221 poms2=poms.right(poms.length()-i-1);
222 if (fl!=NULL) fprintf(stdout,"%s: ",fl->filename);
223 fprintf(stdout,"%d %s\n",tline,poms2.data());
229 poms.sprintf("%s/cmp01.log",mydir);
231 poms.sprintf("%s/.cmp00",mydir);