diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2010-05-11 02:07:32 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2010-05-11 02:08:34 +0200 |
commit | 24753411737ffabc17ef19681f833578d2e1fe2b (patch) | |
tree | 5dfff2240fd85cf5b180547e625e89174f1a0af7 | |
parent | 423d17d562d9e38403a14220d861b4c63abadc7c (diff) | |
download | patch-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-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/patch.c | 27 |
2 files changed, 19 insertions, 13 deletions
@@ -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) { |