aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mansearch.c
diff options
context:
space:
mode:
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mansearch.c b/mansearch.c
index 6eab7e07..197fddd9 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.29 2014/04/15 23:48:51 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.30 2014/04/15 23:51:39 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);