Unified · Split
| @@ -9323,6 +9323,22 @@ int tcc_set_output_type(TCCState *s, int output_type) · 9322 unmodified lines | |||
| 9323 | 9323 | ||
| 9324 | #if !defined(LIBTCC) | 9324 | #if !defined(LIBTCC) |
| 9325 | 9325 | ||
| 9326 | /* extract the basename of a file */ | ||
| 9327 | static const char *tcc_basename(const char *name) | ||
| 9328 | { | ||
| 9329 | const char *p; | ||
| 9330 | p = strrchr(name, '/'); | ||
| 9331 | #ifdef WIN32 | ||
| 9332 | if (!p) | ||
| 9333 | p = strrchr(name, '\\'); | ||
| 9334 | #endif | ||
| 9335 | if (!p) | ||
| 9336 | p = name; | ||
| 9337 | else | ||
| 9338 | p++; | ||
| 9339 | return p; | ||
| 9340 | } | ||
| 9341 | |||
| 9326 | static int64_t getclock_us(void) | 9342 | static int64_t getclock_us(void) |
| 9327 | { | 9343 | { |
| 9328 | #ifdef WIN32 | 9344 | #ifdef WIN32 |
| @@ -9625,8 +9641,10 @@ int main(int argc, char **argv) · 296 unmodified lines | |||
| 9625 | if (output_type != TCC_OUTPUT_MEMORY && !outfile) { | 9641 | if (output_type != TCC_OUTPUT_MEMORY && !outfile) { |
| 9626 | if (output_type == TCC_OUTPUT_OBJ && !reloc_output) { | 9642 | if (output_type == TCC_OUTPUT_OBJ && !reloc_output) { |
| 9627 | char *ext; | 9643 | char *ext; |
| 9644 | /* strip path */ | ||
| 9645 | pstrcpy(objfilename, sizeof(objfilename) - 1, | ||
| 9646 | tcc_basename(files[0])); | ||
| 9628 | /* add .o extension */ | 9647 | /* add .o extension */ |
| 9629 | pstrcpy(objfilename, sizeof(objfilename) - 1, files[0]); | ||
| 9630 | ext = strrchr(objfilename, '.'); | 9648 | ext = strrchr(objfilename, '.'); |
| 9631 | if (!ext) | 9649 | if (!ext) |
| 9632 | goto default_outfile; | 9650 | goto default_outfile; |