diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2009-04-08 06:22:43 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2009-04-08 06:23:11 +0200 |
commit | 2e583114c723b678977579dd7156049867832c29 (patch) | |
tree | f1a1dd206925f1cbdaa7d079640793fa97be9600 | |
parent | 7e2373f0623423b5e9098b0c65903bbbd5db74ed (diff) | |
download | patch-2e583114c723b678977579dd7156049867832c29.tar.gz |
Add support for sending output to standard output
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | patch.man | 6 | ||||
-rw-r--r-- | src/patch.c | 13 |
3 files changed, 18 insertions, 6 deletions
@@ -1,6 +1,9 @@ 2009-04-08 Andreas Gruenbacher <agruen@suse.de> - * src/patch.c (main): Remove redundant check. + * src/patch.c (create_output_file): Add support for sending output + to standard output. + (main): Allow -o -. Remove redundant check. + * patch.man: Document the new use of -o. 2009-04-07 Andreas Gruenbacher <agruen@suse.de> @@ -425,9 +425,9 @@ this: .RS .nf .B <<<<<<< -lines from the original file +.I lines from the original file .B ======= -lines from the patch +.I lines from the patch .B >>>>>>> .RE .fi @@ -451,6 +451,8 @@ instead of patching files in place. Do not use this option if .I outfile is one of the files to be patched. +When \fIoutfile\fP is \fB\-\fP, send output to standard output, and send any +messages that would usually go to standard output to standard error. .TP \fB\-p\fP\fInum\fP or \fB\*=strip\fP\fB=\fP\fInum\fP Strip the smallest prefix containing diff --git a/src/patch.c b/src/patch.c index b2ad822..ffc5e39 100644 --- a/src/patch.c +++ b/src/patch.c @@ -737,8 +737,6 @@ get_some_switches (void) noreverse = true; break; case 'o': - if (strcmp (optarg, "-") == 0) - fatal ("can't output patches to standard output"); outfile = savestr (optarg); break; case 'p': @@ -1343,7 +1341,16 @@ create_output_file (char const *name, int open_flags) static void init_output (char const *name, int open_flags, struct outstate *outstate) { - outstate->ofp = name ? create_output_file (name, open_flags) : (FILE *) 0; + if (! name) + outstate->ofp = (FILE *) 0; + else if (strcmp (name, "-") != 0) + outstate->ofp = create_output_file (name, open_flags); + else + { + outstate->ofp = stdout; + stdout = stderr; + } + outstate->after_newline = true; outstate->zero_output = true; } |