aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/demandoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-01-08 02:13:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-01-08 02:13:39 +0000
commit04d39401bf641371ebd7d33949c6022bf67ee762 (patch)
treeb80ccae4c0c658aca51fc9efa7b61c1c8ffc0ee1 /demandoc.c
parent24cca2c9750d89a1dd92e9e8aee7567012175880 (diff)
downloadmandoc-04d39401bf641371ebd7d33949c6022bf67ee762.tar.gz
mandoc-04d39401bf641371ebd7d33949c6022bf67ee762.tar.zst
mandoc-04d39401bf641371ebd7d33949c6022bf67ee762.zip
It was very surprising that a function called mparse_readfd()
closed the file descriptor passed to it after completing its work, in particular considering the fact that it required its callers to call open(2) or mparse_open() beforehand. Change mparse_readfd() to not call close(2) and change the callers to call close(2) afterwards, more or less bringing open and close to the same level of the code and making review easier. Note that man.cgi(8) already did that, even though it was wrong in the past. Small restructuring suggested by Christos Zoulas (NetBSD).
Diffstat (limited to 'demandoc.c')
-rw-r--r--demandoc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/demandoc.c b/demandoc.c
index 2e4e932e..f55109cd 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -1,4 +1,4 @@
-/* $Id: demandoc.c,v 1.24 2015/10/22 22:06:43 schwarze Exp $ */
+/* $Id: demandoc.c,v 1.25 2016/01/08 02:13:39 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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;