1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* convertor from generated LOG files to the corresponding TeX sources
this program is for unix-systems */
#include <stdio.h>
#include <strings.h>
void error(char *txt){
puts(txt);
exit(1);
}
void main(int argc,char** argv){
FILE *fi,*fo;
char line[200];
if(argc>=2)
strcpy(line,argv[1]);
else{
printf("input: ");
scanf("%s",line);
}
strcat(line,".log");
fi=fopen(line,"r");
if(!fi)
error("can not open input file");
while(!feof(fi)){
fscanf(fi,"%s",line);
if(line[0]=='$'
&& line[1]=='#'
&& line[2]=='@'
&& line[3]=='!'){
int i=4;
do{
line[i-4]=line[i];
i++;
}while(line[i-1]);
strcat(line,".tex");
fo=fopen(line,"w");
if(!fo)
error("can not open output file");
break;
}
}
while(!feof(fi)){
fgets(line,200,fi);
if(line[0]=='!'
&& line[1]=='@'
&& line[2]=='#'
&& line[3]=='$'){
int i=4;
do{
line[i-4]=line[i];
i++;
}while(line[i-1]);
fputs(line,fo);
}
}
fclose(fo);
fclose(fi);
}
|