Fossil SCM

Refactor to fix an unused var warning in debug build

ashepilko 2018-08-02 06:54 trunk
Commit 811333a5010ec2bf32be050a26e4efc1b8c65bb4fc98a44ba6c21be512353571
1 file changed +25 -18
+25 -18
--- src/translate.c
+++ src/translate.c
@@ -203,37 +203,44 @@
203203
fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
204204
}
205205
}
206206
}
207207
}
208
+
209
+static void print_source_ref(const char *zSrcFile, FILE *out){
210
+/* Set source line reference to the original source file.
211
+ * This makes compiler show the original file name in the compile error
212
+ * messages, instead of referring to the translated file.
213
+ * NOTE: This somewhat complicates stepping in debugger, as the resuling
214
+ * code would not match the referenced sources.
215
+ */
216
+#ifndef FOSSIL_DEBUG
217
+ const char *arg;
218
+ if( !*zSrcFile ){
219
+ return;
220
+ }
221
+ fprintf(out,"#line 1 \"");
222
+ for(arg=zSrcFile; *arg; arg++){
223
+ if( *arg!='\\' ){
224
+ fprintf(out,"%c", *arg);
225
+ }else{
226
+ fprintf(out,"\\\\");
227
+ }
228
+ }
229
+ fprintf(out,"\"\n");
230
+#endif
231
+}
208232
209233
int main(int argc, char **argv){
210234
if( argc==2 ){
211
- char *arg;
212235
FILE *in = fopen(argv[1], "r");
213236
if( in==0 ){
214237
fprintf(stderr,"can not open %s\n", argv[1]);
215238
exit(1);
216239
}
217240
zInFile = argv[1];
218
-#ifndef FOSSIL_DEBUG
219
- /* Set source line reference to the original source file.
220
- * This makes compiler show the original file name in the compile error
221
- * messages, instead of referring to the translated file.
222
- * NOTE: This somewhat complicates stepping in debugger, as the resuling
223
- * code would not match the referenced sources.
224
- */
225
- printf("#line 1 \"");
226
- for(arg=argv[1]; *arg; arg++){
227
- if( *arg!='\\' ){
228
- printf("%c", *arg);
229
- }else{
230
- printf("\\\\");
231
- }
232
- }
233
- printf("\"\n");
234
-#endif
241
+ print_source_ref(zInFile, stdout);
235242
trans(in, stdout);
236243
fclose(in);
237244
}else{
238245
trans(stdin, stdout);
239246
}
240247
--- src/translate.c
+++ src/translate.c
@@ -203,37 +203,44 @@
203 fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
204 }
205 }
206 }
207 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
209 int main(int argc, char **argv){
210 if( argc==2 ){
211 char *arg;
212 FILE *in = fopen(argv[1], "r");
213 if( in==0 ){
214 fprintf(stderr,"can not open %s\n", argv[1]);
215 exit(1);
216 }
217 zInFile = argv[1];
218 #ifndef FOSSIL_DEBUG
219 /* Set source line reference to the original source file.
220 * This makes compiler show the original file name in the compile error
221 * messages, instead of referring to the translated file.
222 * NOTE: This somewhat complicates stepping in debugger, as the resuling
223 * code would not match the referenced sources.
224 */
225 printf("#line 1 \"");
226 for(arg=argv[1]; *arg; arg++){
227 if( *arg!='\\' ){
228 printf("%c", *arg);
229 }else{
230 printf("\\\\");
231 }
232 }
233 printf("\"\n");
234 #endif
235 trans(in, stdout);
236 fclose(in);
237 }else{
238 trans(stdin, stdout);
239 }
240
--- src/translate.c
+++ src/translate.c
@@ -203,37 +203,44 @@
203 fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline);
204 }
205 }
206 }
207 }
208
209 static void print_source_ref(const char *zSrcFile, FILE *out){
210 /* Set source line reference to the original source file.
211 * This makes compiler show the original file name in the compile error
212 * messages, instead of referring to the translated file.
213 * NOTE: This somewhat complicates stepping in debugger, as the resuling
214 * code would not match the referenced sources.
215 */
216 #ifndef FOSSIL_DEBUG
217 const char *arg;
218 if( !*zSrcFile ){
219 return;
220 }
221 fprintf(out,"#line 1 \"");
222 for(arg=zSrcFile; *arg; arg++){
223 if( *arg!='\\' ){
224 fprintf(out,"%c", *arg);
225 }else{
226 fprintf(out,"\\\\");
227 }
228 }
229 fprintf(out,"\"\n");
230 #endif
231 }
232
233 int main(int argc, char **argv){
234 if( argc==2 ){
 
235 FILE *in = fopen(argv[1], "r");
236 if( in==0 ){
237 fprintf(stderr,"can not open %s\n", argv[1]);
238 exit(1);
239 }
240 zInFile = argv[1];
241 print_source_ref(zInFile, stdout);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242 trans(in, stdout);
243 fclose(in);
244 }else{
245 trans(stdin, stdout);
246 }
247

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button