From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6388 invoked from network); 30 Mar 2021 17:17:29 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 30 Mar 2021 17:17:29 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id def988ad for ; Tue, 30 Mar 2021 12:17:25 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 58754ec5 for ; Tue, 30 Mar 2021 12:17:25 -0500 (EST) Date: Tue, 30 Mar 2021 12:17:25 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Append .html suffix to temporary files enabling browsers to X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- Append .html suffix to temporary files enabling browsers to recognise it. Occasionally one might read a manual page in a webbrowser, e.g. "MANPAGER=firefox man -T html jq", however temporary files created for pagers lack file extensions and most web browsers are unable to detect a file's content without it. Special case mandoc(1)'s HTML output format by appending the ".html" suffix to file names such that browsers will actually render HTML as such instead of showing it as plain text. Idea and patch from kn@, with minor help from me. Modified Files: -------------- mandoc: main.c term_tag.c term_tag.h Revision Data ------------- Index: term_tag.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/term_tag.h,v retrieving revision 1.3 retrieving revision 1.4 diff -Lterm_tag.h -Lterm_tag.h -u -p -r1.3 -r1.4 --- term_tag.h +++ term_tag.h @@ -28,7 +28,7 @@ struct tag_files { }; -struct tag_files *term_tag_init(const char *, const char *); +struct tag_files *term_tag_init(const char *, const char *, const char *); void term_tag_write(struct roff_node *, size_t); int term_tag_close(void); void term_tag_unlink(void); Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.353 retrieving revision 1.354 diff -Lmain.c -Lmain.c -u -p -r1.353 -r1.354 --- main.c +++ main.c @@ -846,6 +846,7 @@ process_onefile(struct mparse *mp, struc if (outst->use_pager) { outst->use_pager = 0; outst->tag_files = term_tag_init(conf->output.outfilename, + outst->outtype == OUTT_HTML ? ".html" : "", conf->output.tagfilename); #if HAVE_PLEDGE if ((conf->output.outfilename != NULL || Index: term_tag.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/term_tag.c,v retrieving revision 1.5 retrieving revision 1.6 diff -Lterm_tag.c -Lterm_tag.c -u -p -r1.5 -r1.6 --- term_tag.c +++ term_tag.c @@ -47,7 +47,8 @@ static struct tag_files tag_files; * but for simplicity, create it anyway. */ struct tag_files * -term_tag_init(const char *outfilename, const char *tagfilename) +term_tag_init(const char *outfilename, const char *suffix, + const char *tagfilename) { struct sigaction sa; int ofd; /* In /tmp/, dup(2)ed to stdout. */ @@ -85,9 +86,9 @@ term_tag_init(const char *outfilename, c /* Create both temporary output files. */ if (outfilename == NULL) { - (void)strlcpy(tag_files.ofn, "/tmp/man.XXXXXXXXXX", - sizeof(tag_files.ofn)); - if ((ofd = mkstemp(tag_files.ofn)) == -1) { + (void)snprintf(tag_files.ofn, sizeof(tag_files.ofn), + "/tmp/man.XXXXXXXXXX%s", suffix); + if ((ofd = mkstemps(tag_files.ofn, strlen(suffix))) == -1) { mandoc_msg(MANDOCERR_MKSTEMP, 0, 0, "%s: %s", tag_files.ofn, strerror(errno)); goto fail; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv