summaryrefslogtreecommitdiff
path: root/bk_man.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2009-10-24 09:33:21 +0000
committerSimon Tatham <anakin@pobox.com>2009-10-24 09:33:21 +0000
commit6c481aff452a0eed147fc73144b461fe7c263d9e (patch)
tree750470ca4dd8e2406eb7ab1af67971917f9de614 /bk_man.c
parentccb035ab284dcce968d948a5f04eef96c9cc541d (diff)
downloadhalibut-6c481aff452a0eed147fc73144b461fe7c263d9e.zip
halibut-6c481aff452a0eed147fc73144b461fe7c263d9e.tar.gz
halibut-6c481aff452a0eed147fc73144b461fe7c263d9e.tar.bz2
halibut-6c481aff452a0eed147fc73144b461fe7c263d9e.tar.xz
Allow a hastily selected subset of the output formats to also accept
"-" as a special file name meaning standard output. I've restricted it to just those output formats which can predictably output only one file, just for the sake of not having to faff too much with the others. Probably what I should have done for all of this would have been to write a set of wrappers around fopen, fclose and everything in between, and use them everywhere. Those wrappers would uniformly detect "-" and convert it into stdin or stdout as appropriate, would avoid fclosing those files for real when told to close them, and would also be able to handle reading a little bit of data from the start of a file and then pushing it all back even if the file were not seekable (which would allow input.c to lose the ugly special case whereby it can't currently read font files from standard input). [originally from svn r8729]
Diffstat (limited to 'bk_man.c')
-rw-r--r--bk_man.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bk_man.c b/bk_man.c
index dce77d4..bb4e5b5 100644
--- a/bk_man.c
+++ b/bk_man.c
@@ -235,7 +235,10 @@ void man_backend(paragraph *sourceform, keywordlist *keywords,
/*
* Open the output file.
*/
- fp = fopen(conf.filename, "w");
+ if (!strcmp(conf.filename, "-"))
+ fp = stdout;
+ else
+ fp = fopen(conf.filename, "w");
if (!fp) {
error(err_cantopenw, conf.filename);
return;
@@ -425,7 +428,8 @@ void man_backend(paragraph *sourceform, keywordlist *keywords,
/*
* Tidy up.
*/
- fclose(fp);
+ if (fp != stdout)
+ fclose(fp);
man_conf_cleanup(conf);
}