mirror of
https://github.com/openbsd/src.git
synced 2026-05-01 09:37:02 +00:00
Fix a bug where formatting two compressed manual pages in row failed to
decompress the second one. The problem was calling mparse*() functions in the wrong order mparse_open -> mparse_reset -> mparse_readfd instead of in the correct order mparse_reset -> mparse_open -> mparse_readfd: mparse_reset() clears the gzip flag, mparse_open() sets it if the new file is gzipped, and read_whole_file() called from mparse_readfd() enables decompression if the flag is set. To make the code easier to follow, call all of mparse_alloc(), mparse_reset(), and mparse_free() from main() rather than hiding mparse_reset() two levels down in the parse() subroutine. Bug found by Alejandro Colomar <alx@kernel.org> on Debian Sid and reported on the GNU roff mailing list.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* $OpenBSD: main.c,v 1.266 2025/08/28 16:37:25 schwarze Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.267 2025/09/24 21:27:21 schwarze Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2010-2012, 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
|
||||
* Copyright (c) 2010-2012,2014-2021,2025 Ingo Schwarze <schwarze@openbsd.org>
|
||||
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
|
||||
*
|
||||
@@ -579,6 +579,8 @@ main(int argc, char *argv[])
|
||||
mp = mparse_alloc(options, os_e, os_s);
|
||||
|
||||
for (i = 0; i < ressz; i++) {
|
||||
if (i > 0)
|
||||
mparse_reset(mp);
|
||||
process_onefile(mp, res + i, &outst, &conf);
|
||||
if (outst.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK)
|
||||
break;
|
||||
@@ -894,18 +896,12 @@ parse(struct mparse *mp, int fd, const char *file,
|
||||
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)
|
||||
close(fd);
|
||||
|
||||
Reference in New Issue
Block a user