summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2010-05-11 02:07:32 +0200
committerAndreas Gruenbacher <agruen@suse.de>2010-05-11 02:08:34 +0200
commit24753411737ffabc17ef19681f833578d2e1fe2b (patch)
tree5dfff2240fd85cf5b180547e625e89174f1a0af7
parent423d17d562d9e38403a14220d861b4c63abadc7c (diff)
downloadpatch-24753411737ffabc17ef19681f833578d2e1fe2b.tar.gz
Fix read-only file check for ed scripts
* src/patch.c: The read-only file check was not done for ed scripts; fix this.
-rw-r--r--ChangeLog5
-rw-r--r--src/patch.c27
2 files changed, 19 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 192bf34..8d6ea2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-11 Andreas Gruenbacher <agruen@suse.de>
+
+ * src/patch.c: The read-only file check was not done for ed scripts;
+ fix this.
+
2009-05-06 Andreas Gruenbacher <agruen@suse.de>
* tests/corrupt-reject-files, tests/crlf-handling: On Solaris, cat's
diff --git a/src/patch.c b/src/patch.c
index 7c4660b..9056816 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -208,6 +208,20 @@ main (int argc, char **argv)
}
}
+ if (! inerrno && ! S_ISLNK (instat.st_mode)
+ && access (inname, W_OK) != 0)
+ {
+ say ("File %s is read-only; ", quotearg (inname));
+ if (force || batch)
+ say ("trying to patch anyway\n");
+ else
+ {
+ say ("refusing to patch\n");
+ skip_rest_of_patch = true;
+ somefailed = true;
+ }
+ }
+
if (diff_type == ED_DIFF) {
outstate.zero_output = false;
somefailed |= skip_rest_of_patch;
@@ -229,19 +243,6 @@ main (int argc, char **argv)
skip_rest_of_patch = true;
somefailed = true;
}
- if (! inerrno && ! S_ISLNK (instat.st_mode)
- && access (inname, W_OK) != 0)
- {
- say ("File %s is read-only; ", quotearg (inname));
- if (force || batch)
- say ("trying to patch anyway\n");
- else
- {
- say ("refusing to patch\n");
- skip_rest_of_patch = true;
- somefailed = true;
- }
- }
/* initialize the patched file */
if (! skip_rest_of_patch && ! outfile)
{