=================================================================== RCS file: /cvs/mandoc/mansearch.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -p -r1.29 -r1.30 --- mandoc/mansearch.c 2014/04/15 23:48:51 1.29 +++ mandoc/mansearch.c 2014/04/15 23:51:39 1.30 @@ -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);