diff options
-rw-r--r-- | demandoc.c | 1 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | mandoc.3 | 5 | ||||
-rw-r--r-- | mandocdb.c | 1 | ||||
-rw-r--r-- | read.c | 5 |
5 files changed, 11 insertions, 5 deletions
@@ -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; @@ -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; @@ -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 @@ -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); } @@ -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; } |