From 0fcdcb91886d295168c7b4fc9dca7264aa516956 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 13 May 2003 11:15:59 +0000 Subject: [PATCH] Treat identical src/dst file names as if only one entered. One Windows creating an output file of the same name as the input file will delete the input file before it is read. --- binutils/ChangeLog | 6 ++++++ binutils/objcopy.c | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 7819fb8b592..10dbaaf2a99 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2003-05-13 Michael Eager + + * objcopy.c: Treat identical src/dst file names as if only one + entered. One Windows creating an output file of the same name as + the input file will delete the input file before it is read. + 2003-05-12 Salvador Eduardo Tropea * debug.c (debug_get_real_type): Extend test for circular debug diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 45072495c1e..27c844fbb75 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -2733,9 +2733,10 @@ copy_main (argc, argv) if (stat (input_filename, & statbuf) < 0) fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno)); - /* If there is no destination file then create a temp and rename - the result into the input. */ - if (output_filename == (char *) NULL) + /* If there is no destination file, or the source and destination files + are the same, then create a temp and rename the result into the input. */ + if ((output_filename == (char *) NULL) || + (strcmp (input_filename, output_filename) == 0)) { char *tmpname = make_tempname (input_filename); -- 2.30.2