From c0dd4261c11271fe298a4b2fd33f3f9ab4f704af Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 15 Apr 2014 23:51:39 +0000 Subject: Oops, sorry, revert previous and commit the correct patch: At the end of mansearch(), fchdir() back to where we started from. --- mansearch.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mansearch.c') 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 * Copyright (c) 2013, 2014 Ingo Schwarze @@ -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); -- cgit v1.2.3-56-ge451