[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] [PATCH 5/7] tcc: Always compute default outfile name
From: |
Kirill Smelkov |
Subject: |
[Tinycc-devel] [PATCH 5/7] tcc: Always compute default outfile name |
Date: |
Thu, 17 Jun 2010 00:38:48 +0400 |
Since for upcoming -MD support default _compile_ output file be needed
even when preprocesssing (tcc -E), let's move this code out of condition
block and always compute outfile_default.
---
tcc.c | 45 +++++++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/tcc.c b/tcc.c
index 759151a..5138937 100644
--- a/tcc.c
+++ b/tcc.c
@@ -393,7 +393,7 @@ int main(int argc, char **argv)
int i;
TCCState *s;
int nb_objfiles, ret, optind;
- char objfilename[1024];
+ char outfile_default[1024];
int64_t start_time = 0;
s = tcc_new();
@@ -437,6 +437,26 @@ int main(int argc, char **argv)
error("cannot specify libraries with -c");
}
+ /* compute default outfile name */
+ {
+ char *ext;
+ const char *name =
+ strcmp(files[0], "-") == 0 ? "a" : tcc_basename(files[0]);
+ pstrcpy(outfile_default, sizeof(outfile_default), name);
+ ext = tcc_fileextension(outfile_default);
+#ifdef TCC_TARGET_PE
+ if (output_type == TCC_OUTPUT_DLL)
+ strcpy(ext, ".dll");
+ else
+ if (output_type == TCC_OUTPUT_EXE)
+ strcpy(ext, ".exe");
+ else
+#endif
+ if (output_type == TCC_OUTPUT_OBJ && !reloc_output && *ext)
+ strcpy(ext, ".o");
+ else
+ pstrcpy(outfile_default, sizeof(outfile_default), "a.out");
+ }
if (output_type == TCC_OUTPUT_PREPROCESS) {
if (!outfile) {
@@ -447,27 +467,8 @@ int main(int argc, char **argv)
error("could not open '%s'", outfile);
}
} else if (output_type != TCC_OUTPUT_MEMORY) {
- if (!outfile) {
- /* compute default outfile name */
- char *ext;
- const char *name =
- strcmp(files[0], "-") == 0 ? "a" : tcc_basename(files[0]);
- pstrcpy(objfilename, sizeof(objfilename), name);
- ext = tcc_fileextension(objfilename);
-#ifdef TCC_TARGET_PE
- if (output_type == TCC_OUTPUT_DLL)
- strcpy(ext, ".dll");
- else
- if (output_type == TCC_OUTPUT_EXE)
- strcpy(ext, ".exe");
- else
-#endif
- if (output_type == TCC_OUTPUT_OBJ && !reloc_output && *ext)
- strcpy(ext, ".o");
- else
- pstrcpy(objfilename, sizeof(objfilename), "a.out");
- outfile = objfilename;
- }
+ if (!outfile)
+ outfile = outfile_default;
}
if (do_bench) {
--
1.7.1.334.gebb7bc.dirty
[Tinycc-devel] [PATCH 5/7] tcc: Always compute default outfile name,
Kirill Smelkov <=
[Tinycc-devel] [PATCH 3/7] chmod a-x i386-gen.c, Kirill Smelkov, 2010/06/16
[Tinycc-devel] [PATCH 1/7] .cvsignore -> .gitignore, Kirill Smelkov, 2010/06/16
[Tinycc-devel] [PATCH 6/7] tcc: Draft suppoprt for -MD/-MF options, Kirill Smelkov, 2010/06/16
[Tinycc-devel] [PATCH 4/7] tcc: Fix typo in error (it's '%s', not '%s), Kirill Smelkov, 2010/06/16