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.
This commit is contained in:
Nick Clifton 2003-05-13 11:15:59 +00:00
parent 3959a22a50
commit 0fcdcb9188
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2003-05-13 Michael Eager <eager@mvista.com>
* 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 <salvador@inti.gov.ar> 2003-05-12 Salvador Eduardo Tropea <salvador@inti.gov.ar>
* debug.c (debug_get_real_type): Extend test for circular debug * debug.c (debug_get_real_type): Extend test for circular debug

View file

@ -2733,9 +2733,10 @@ copy_main (argc, argv)
if (stat (input_filename, & statbuf) < 0) if (stat (input_filename, & statbuf) < 0)
fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno)); fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno));
/* If there is no destination file then create a temp and rename /* If there is no destination file, or the source and destination files
the result into the input. */ are the same, then create a temp and rename the result into the input. */
if (output_filename == (char *) NULL) if ((output_filename == (char *) NULL) ||
(strcmp (input_filename, output_filename) == 0))
{ {
char *tmpname = make_tempname (input_filename); char *tmpname = make_tempname (input_filename);