Fossil

Check-in [811333a5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Refactor to fix an unused var warning in debug build
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:811333a5010ec2bf32be050a26e4efc1b8c65bb4fc98a44ba6c21be512353571
User & Date: ashepilko 2018-08-02 06:54:31
Context
2018-08-02
11:56
Use the native directory separator for the extra files in the MSVC makefile. check-in: 774bdc83 user: mistachkin tags: trunk
08:32
Merge from trunk. check-in: 19997e99 user: ashepilko tags: cmake-ide
06:54
Refactor to fix an unused var warning in debug build check-in: 811333a5 user: ashepilko tags: trunk
03:53
Exit with error status when halt is triggered on error check-in: ccc66763 user: ashepilko tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/translate.c.

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;
}