diff options
| author | bellard <bellard> | 2003-04-16 21:35:02 +0000 |
|---|---|---|
| committer | bellard <bellard> | 2003-04-16 21:35:02 +0000 |
| commit | 410fc57ba05c4e59534d0dfc8ef64c77b62c2810 (patch) | |
| tree | 9179cdd2ee012fc8019e98624f3e0ee443240355 /tcc.c | |
| parent | 066d5e7a849c04c93a98b954f81a4b0585340f00 (diff) | |
| download | tinycc-410fc57ba05c4e59534d0dfc8ef64c77b62c2810.tar.gz tinycc-410fc57ba05c4e59534d0dfc8ef64c77b62c2810.tar.bz2 | |
default output object filename is basename of input filename (same behaviour as gcc)
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -9323,6 +9323,22 @@ int tcc_set_output_type(TCCState *s, int output_type) #if !defined(LIBTCC) +/* extract the basename of a file */ +static const char *tcc_basename(const char *name) +{ + const char *p; + p = strrchr(name, '/'); +#ifdef WIN32 + if (!p) + p = strrchr(name, '\\'); +#endif + if (!p) + p = name; + else + p++; + return p; +} + static int64_t getclock_us(void) { #ifdef WIN32 @@ -9625,8 +9641,10 @@ int main(int argc, char **argv) if (output_type != TCC_OUTPUT_MEMORY && !outfile) { if (output_type == TCC_OUTPUT_OBJ && !reloc_output) { char *ext; + /* strip path */ + pstrcpy(objfilename, sizeof(objfilename) - 1, + tcc_basename(files[0])); /* add .o extension */ - pstrcpy(objfilename, sizeof(objfilename) - 1, files[0]); ext = strrchr(objfilename, '.'); if (!ext) goto default_outfile; |
