summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demandoc.c1
-rw-r--r--main.c4
-rw-r--r--mandoc.35
-rw-r--r--mandocdb.c1
-rw-r--r--read.c5
5 files changed, 11 insertions, 5 deletions
diff --git a/demandoc.c b/demandoc.c
index 8e9044b2..3eb358bc 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -113,6 +113,7 @@ pmandoc(struct mparse *mp, int fd, const char *fn, int list)
int line, col;
mparse_readfd(mp, fd, fn);
+ close(fd);
mparse_result(mp, &man, NULL);
line = 1;
col = 0;
diff --git a/main.c b/main.c
index 65659a44..aed5ed9c 100644
--- a/main.c
+++ b/main.c
@@ -724,9 +724,11 @@ parse(struct curparse *curp, int fd, const char *file)
/* Begin by parsing the file itself. */
assert(file);
- assert(fd >= -1);
+ assert(fd > 0);
rctmp = mparse_readfd(curp->mp, fd, file);
+ if (fd != STDIN_FILENO)
+ close(fd);
if (rc < rctmp)
rc = rctmp;
diff --git a/mandoc.3 b/mandoc.3
index 01a72bc6..b52f65f6 100644
--- a/mandoc.3
+++ b/mandoc.3
@@ -177,6 +177,9 @@ or
parse it with
.Fn mparse_readfd ;
.It
+close it with
+.Xr close 2 ;
+.It
retrieve the syntax tree with
.Fn mparse_result ;
.It
@@ -403,6 +406,8 @@ or
Pass the associated filename in
.Va fname .
This function may be called multiple times with different parameters; however,
+.Xr close 2
+and
.Fn mparse_reset
should be invoked between parses.
Declared in
diff --git a/mandocdb.c b/mandocdb.c
index e3768d9f..3b089194 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1146,6 +1146,7 @@ mpages_merge(struct mparse *mp)
*/
if (mlink->dform != FORM_CAT || mlink->fform != FORM_CAT) {
mparse_readfd(mp, fd, mlink->file);
+ close(fd);
mparse_result(mp, &man, &sodest);
}
diff --git a/read.c b/read.c
index 90642134..699b2c65 100644
--- a/read.c
+++ b/read.c
@@ -542,6 +542,7 @@ rerun:
if (mparse_open(curp, &fd, ln.buf + of) ==
MANDOCLEVEL_OK) {
mparse_readfd(curp, fd, ln.buf + of);
+ close(fd);
curp->file = save_file;
} else {
curp->file = save_file;
@@ -773,10 +774,6 @@ mparse_readfd(struct mparse *curp, int fd, const char *file)
#endif
free(blk.buf);
}
-
- if (fd != STDIN_FILENO && close(fd) == -1)
- perror(file);
-
return curp->file_status;
}