X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/68183e3516ca405d803db497157cd8246b9b8bad..0df69c1e73797280f13714a991c4829655e432a3:/read.c?ds=sidebyside diff --git a/read.c b/read.c index 8ab3c803..a3a1f982 100644 --- a/read.c +++ b/read.c @@ -1,7 +1,7 @@ -/* $Id: read.c,v 1.209 2018/12/30 00:49:55 schwarze Exp $ */ +/* $Id: read.c,v 1.211 2019/01/11 17:04:44 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010-2018 Ingo Schwarze + * Copyright (c) 2010-2019 Ingo Schwarze * Copyright (c) 2010, 2012 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -607,7 +607,7 @@ int mparse_open(struct mparse *curp, const char *file) { char *cp; - int fd; + int fd, save_errno; cp = strrchr(file, '.'); curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz")); @@ -623,9 +623,11 @@ mparse_open(struct mparse *curp, const char *file) */ if ( ! curp->gzip) { + save_errno = errno; mandoc_asprintf(&cp, "%s.gz", file); fd = open(cp, O_RDONLY); free(cp); + errno = save_errno; if (fd != -1) { curp->gzip = 1; return fd; @@ -688,6 +690,7 @@ mparse_free(struct mparse *curp) struct roff_meta * mparse_result(struct mparse *curp) { + roff_state_reset(curp->man); if (curp->options & MPARSE_VALIDATE) { if (curp->man->meta.macroset == MACROSET_MDOC) mdoc_validate(curp->man);