[L4alpha-cvscommit] CVS: dite/src edit.c,1.27,1.28
Status: Beta
Brought to you by:
dpotts
|
From: Simon W. <sj...@us...> - 2002-06-07 02:32:50
|
Update of /cvsroot/l4alpha/dite/src
In directory usw-pr-cvs1:/tmp/cvs-serv27877/src
Modified Files:
edit.c
Log Message:
Removed 'in-place' flag.
Index: edit.c
===================================================================
RCS file: /cvsroot/l4alpha/dite/src/edit.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** edit.c 3 Jun 2002 08:44:47 -0000 1.27
--- edit.c 7 Jun 2002 02:32:45 -0000 1.28
***************
*** 2,6 ****
* Project: EDIT --- Extended DIT
* Created: 12/07/2000 19:46:03 by Simon Winwood (sjw)
! * Last Modified: 03/06/2002 15:55:13 by Simon Winwood (sjw)
* Version info: $Revision$
* Description:
--- 2,6 ----
* Project: EDIT --- Extended DIT
* Created: 12/07/2000 19:46:03 by Simon Winwood (sjw)
! * Last Modified: 07/06/2002 12:30:15 by (sjw)
* Version info: $Revision$
* Description:
***************
*** 18,21 ****
--- 18,24 ----
*
* $Log$
+ * Revision 1.28 2002/06/07 02:32:45 sjw_
+ * Removed 'in-place' flag.
+ *
* Revision 1.27 2002/06/03 08:44:47 sjw_
* MIPS changes
***************
*** 220,224 ****
{"execute", no_argument, NULL, 'x'},
{"resource", no_argument, NULL, 'r'},
- {"in-place", no_argument, NULL, 'i'},
{0, 0, 0, 0}
};
--- 223,226 ----
***************
*** 235,239 ****
" -v --verbose : Verbose\n"
" -q --quiet : Quiet\n"
- " -i --in-place : Modify file in place (actually uses tmpfile())\n"
"\n"
" Target\n"
--- 237,240 ----
***************
*** 398,403 ****
char *logfile = "-"; /* Default to stdout */
enum loglevel loglevel = LOG_NORMAL;
- int inplace = 0;
- char tmpfilename[L_tmpnam];
unsigned int target_alignment = 1;
int num_sources = 0, tmp;
--- 399,402 ----
***************
*** 445,455 ****
loglevel = LOG_CRITICAL;
break;
-
- case 'i': /* in place */
- inplace = 1;
- /* Wish someone would explain why I should
- * 'Never use this function - I can't use mkstmp, not portable */
- target.filename = tmpnam(tmpfilename);
- break;
/* Target */
--- 444,447 ----
***************
*** 549,555 ****
arches[sources[i].arch], (sources[i].endianness == LSB ? "little" : "big"));
target.entry = (target.entry == 0 ? sources[i].entry : target.entry);
sources[i].offset = target.offset;
!
if(sources[i].objtype != OBJ_RAW) {
target.objtype = (target.objtype == OBJ_INVALID ? sources[i].objtype : target.objtype);
--- 541,550 ----
arches[sources[i].arch], (sources[i].endianness == LSB ? "little" : "big"));
+ /* Do any target related checks */
target.entry = (target.entry == 0 ? sources[i].entry : target.entry);
sources[i].offset = target.offset;
! if(target.filename && !strcmp(target.filename, sources[i].filename))
! target.flags |= FL_UPDATE;
!
if(sources[i].objtype != OBJ_RAW) {
target.objtype = (target.objtype == OBJ_INVALID ? sources[i].objtype : target.objtype);
***************
*** 612,624 ****
// dump_efile(&target);
// print_dit(&target);
target.write_file(&target);
-
- /* This is a bit of a hack, but I'm keeping mods to a minimum
- * Copy the tmpfile to the base input file */
- if (inplace){
- unlink(sources[num_sources].filename);
- rename(target.filename, sources[num_sources].filename);
- }
return 0;
--- 607,616 ----
// dump_efile(&target);
// print_dit(&target);
+
+ /* If we are updating an existing file, unlink it so we can overwrite it without losing data */
+ if(target.flags & FL_UPDATE)
+ unlink(target.filename);
target.write_file(&target);
return 0;
|