* Gzip'ed manpages other than the first argument
@ 2022-09-03 21:25 Simon Branch
0 siblings, 0 replies; only message in thread
From: Simon Branch @ 2022-09-03 21:25 UTC (permalink / raw)
To: discuss
Hello! A current build of mandoc(1) only automatically unzips on the
first call to process_onefile(). This is because detection happens in
mparse_open(), which is called by process_onefile() *before* parse():
if (resp->file != NULL)
if ((fd = mparse_open(mp, resp->file)) == -1)
...
...
if (resp->form == FORM_SRC)
parse(mp, fd, resp->file, outst, conf);
Unfortunately parse() is where we reset the struct mparse
if (previous)
mparse_reset(mp);
else
previous = 1;
... which is where the gzip flag is stored. In other words,
process_onefile() calls mparse_open(), which populates mp->gzip, and
then calls parse(), which overwrites mp->gzip (after the first run).
My fix here is to hoist the mparse_reset() call all the way out to
main(), where it is within view of the initial mparse_alloc().
Thoughts?
Index: main.c
===================================================================
RCS file: /cvs/mandoc/main.c,v
retrieving revision 1.361
diff -u -r1.361 main.c
--- main.c 14 Apr 2022 16:43:43 -0000 1.361
+++ main.c 3 Sep 2022 20:34:10 -0000
@@ -626,6 +626,8 @@
*/
startdir = open(".", O_RDONLY | O_DIRECTORY);
for (i = 0; i < ressz; i++) {
+ if (i)
+ mparse_reset(mp);
process_onefile(mp, res + i, startdir, &outst, &conf);
if (outst.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK)
break;
@@ -952,17 +954,11 @@
struct outstate *outst, struct manconf *conf)
{
static struct manpaths basepaths;
- static int previous;
struct roff_meta *meta;
assert(fd >= 0);
if (file == NULL)
file = "<stdin>";
-
- if (previous)
- mparse_reset(mp);
- else
- previous = 1;
mparse_readfd(mp, fd, file);
if (fd != STDIN_FILENO)
--
To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-03 21:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-03 21:25 Gzip'ed manpages other than the first argument Simon Branch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).