diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-15 23:51:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-15 23:51:39 +0000 |
commit | c0dd4261c11271fe298a4b2fd33f3f9ab4f704af (patch) | |
tree | b0c6164da85d9adb47bf53ffa510a98b3cce0c85 /mansearch.c | |
parent | d72b7fb40b410b373f19c95710d8ed0de0dec1f5 (diff) | |
download | mandoc-c0dd4261c11271fe298a4b2fd33f3f9ab4f704af.tar.gz mandoc-c0dd4261c11271fe298a4b2fd33f3f9ab4f704af.tar.zst mandoc-c0dd4261c11271fe298a4b2fd33f3f9ab4f704af.zip |
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.c | 12 |
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); |