Fossil SCM
Refactor to fix an unused var warning in debug build
Commit
811333a5010ec2bf32be050a26e4efc1b8c65bb4fc98a44ba6c21be512353571
Parent
ccc6676374be472…
1 file changed
+25
-18
+25
-18
| --- src/translate.c | ||
| +++ src/translate.c | ||
| @@ -203,37 +203,44 @@ | ||
| 203 | 203 | fprintf(out,"\n%*s\"%s%s\"",indent+5, "", zOut, zNewline); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 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 | +} | |
| 208 | 232 | |
| 209 | 233 | int main(int argc, char **argv){ |
| 210 | 234 | if( argc==2 ){ |
| 211 | - char *arg; | |
| 212 | 235 | FILE *in = fopen(argv[1], "r"); |
| 213 | 236 | if( in==0 ){ |
| 214 | 237 | fprintf(stderr,"can not open %s\n", argv[1]); |
| 215 | 238 | exit(1); |
| 216 | 239 | } |
| 217 | 240 | 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); | |
| 235 | 242 | trans(in, stdout); |
| 236 | 243 | fclose(in); |
| 237 | 244 | }else{ |
| 238 | 245 | trans(stdin, stdout); |
| 239 | 246 | } |
| 240 | 247 |
| --- 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 |