201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
inPrint = 1;
}else{
fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
}
}
}
}
int main(int argc, char **argv){
if( argc==2 ){
char *arg;
FILE *in = fopen(argv[1], "r");
if( in==0 ){
fprintf(stderr,"can not open %s\n", argv[1]);
exit(1);
}
zInFile = argv[1];
#ifndef FOSSIL_DEBUG
/* Set source line reference to the original source file.
* This makes compiler show the original file name in the compile error
* messages, instead of referring to the translated file.
* NOTE: This somewhat complicates stepping in debugger, as the resuling
* code would not match the referenced sources.
*/
printf("#line 1 \"");
for(arg=argv[1]; *arg; arg++){
if( *arg!='\\' ){
printf("%c", *arg);
}else{
printf("\\\\");
}
}
printf("\"\n");
#endif
trans(in, stdout);
fclose(in);
}else{
trans(stdin, stdout);
}
return 0;
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
|
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
inPrint = 1;
}else{
fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
}
}
}
}
static void print_source_ref(const char *zSrcFile, FILE *out){
/* Set source line reference to the original source file.
* This makes compiler show the original file name in the compile error
* messages, instead of referring to the translated file.
* NOTE: This somewhat complicates stepping in debugger, as the resuling
* code would not match the referenced sources.
*/
#ifndef FOSSIL_DEBUG
const char *arg;
if( !*zSrcFile ){
return;
}
fprintf(out,"#line 1 \"");
for(arg=zSrcFile; *arg; arg++){
if( *arg!='\\' ){
fprintf(out,"%c", *arg);
}else{
fprintf(out,"\\\\");
}
}
fprintf(out,"\"\n");
#endif
}
int main(int argc, char **argv){
if( argc==2 ){
FILE *in = fopen(argv[1], "r");
if( in==0 ){
fprintf(stderr,"can not open %s\n", argv[1]);
exit(1);
}
zInFile = argv[1];
print_source_ref(zInFile, stdout);
trans(in, stdout);
fclose(in);
}else{
trans(stdin, stdout);
}
return 0;
}
|