History

default output object filename is basename of input filename (same behaviour as gcc)

bellard committed 23 years ago

Commit 410fc571 parent 066d5e71 file · +19 −1Browse files

Unified · Split

tcc.c+19−1
@@ -9323,6 +9323,22 @@ int tcc_set_output_type(TCCState *s, int output_type) · 9322 unmodified lines
93239323
93249324 #if !defined(LIBTCC)
93259325
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+
93269342 static int64_t getclock_us(void)
93279343 {
93289344 #ifdef WIN32
@@ -9625,8 +9641,10 @@ int main(int argc, char **argv) · 296 unmodified lines
96259641 if (output_type != TCC_OUTPUT_MEMORY && !outfile) {
96269642 if (output_type == TCC_OUTPUT_OBJ && !reloc_output) {
96279643 char *ext;
9644+ /* strip path */
9645+ pstrcpy(objfilename, sizeof(objfilename) - 1,
9646+ tcc_basename(files[0]));
96289647 /* add .o extension */
9629− pstrcpy(objfilename, sizeof(objfilename) - 1, files[0]);
96309648 ext = strrchr(objfilename, '.');
96319649 if (!ext)
96329650 goto default_outfile;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t