summaryrefslogtreecommitdiffstats
path: root/mansearch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-15 23:51:39 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-15 23:51:39 +0000
commit2b2eab1f9ec714c29cb6de32730c0434a7c9f273 (patch)
tree597c85c25bedcbf448bde4d9c62ff3526e57b0f4 /mansearch.c
parent1e37663de965811e1708b093943894578c95d5ae (diff)
downloadmandoc-2b2eab1f9ec714c29cb6de32730c0434a7c9f273.tar.gz
Oops, sorry, revert previous and commit the correct patch:
At the end of mansearch(), fchdir() back to where we started from.
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/mansearch.c b/mansearch.c
index b84295ae..8918f1d1 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -210,7 +210,7 @@ mansearch(const struct mansearch *search,
*/
if (NULL == getcwd(buf, PATH_MAX)) {
- perror(NULL);
+ perror("getcwd");
goto out;
} else if (-1 == (fd = open(buf, O_RDONLY, 0))) {
perror(buf);
@@ -218,7 +218,6 @@ mansearch(const struct mansearch *search,
}
sql = sql_statement(e);
- printf("%s\n", sql);
/*
* Loop over the directories (containing databases) for us to
@@ -348,9 +347,12 @@ mansearch(const struct mansearch *search,
}
rc = 1;
out:
- exprfree(e);
- if (-1 != fd)
+ if (-1 != fd) {
+ if (-1 == fchdir(fd))
+ perror(buf);
close(fd);
+ }
+ exprfree(e);
free(sql);
*sz = cur;
return(rc);