summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenis Vlasenko2007-04-05 21:25:15 +0000
committerDenis Vlasenko2007-04-05 21:25:15 +0000
commit1bb552b1d9da749050274e0a9cb10b672db22d77 (patch)
treea638c7bbef95bd2c9d72c2e16a5cf4f7b6298458 /editors
parent9020d850bf2b0fd547b545e5e366c7ed284a33cb (diff)
downloadbusybox-1bb552b1d9da749050274e0a9cb10b672db22d77.zip
busybox-1bb552b1d9da749050274e0a9cb10b672db22d77.tar.gz
libbb: add xunlink()
patch: do not try to delete same file twice
Diffstat (limited to 'editors')
-rw-r--r--editors/patch.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/editors/patch.c b/editors/patch.c
index 2c90804..4d1425e 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -260,12 +260,9 @@ int patch_main(int argc, char **argv)
}
if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
/* The new patched file is empty, remove it */
- if (unlink(new_filename) == -1) {
- bb_perror_msg_and_die("cannot remove file %s", new_filename);
- }
- if (unlink(original_filename) == -1) {
- bb_perror_msg_and_die("cannot remove original file %s", new_filename);
- }
+ xunlink(new_filename);
+ if (strcmp(new_filename, original_filename) != 0)
+ xunlink(original_filename);
}
}
}