=================================================================== RCS file: /cvs/mandoc/Attic/apropos.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -p -r1.26 -r1.27 --- mandoc/Attic/apropos.c 2012/03/23 02:52:33 1.26 +++ mandoc/Attic/apropos.c 2012/03/24 00:31:55 1.27 @@ -1,4 +1,4 @@ -/* $Id: apropos.c,v 1.26 2012/03/23 02:52:33 kristaps Exp $ */ +/* $Id: apropos.c,v 1.27 2012/03/24 00:31:55 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -18,6 +18,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include #include #include @@ -39,8 +40,9 @@ int main(int argc, char *argv[]) { int ch, rc, whatis; + struct res *res; struct manpaths paths; - size_t terms; + size_t terms, ressz; struct opts opts; struct expr *e; char *defpaths, *auxpaths; @@ -59,6 +61,8 @@ main(int argc, char *argv[]) memset(&paths, 0, sizeof(struct manpaths)); memset(&opts, 0, sizeof(struct opts)); + ressz = 0; + res = NULL; auxpaths = defpaths = NULL; conf_file = NULL; e = NULL; @@ -104,17 +108,17 @@ main(int argc, char *argv[]) } rc = apropos_search - (paths.sz, paths.paths, - &opts, e, terms, NULL, list); + (paths.sz, paths.paths, &opts, + e, terms, NULL, &ressz, &res, list); - if (0 == rc) - fprintf(stderr, "%s: Error reading " - "manual database\n", progname); - + if (0 == rc) { + fprintf(stderr, "%s: Bad database\n", progname); + goto out; + } out: manpath_free(&paths); + resfree(res, ressz); exprfree(e); - return(rc ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -126,13 +130,16 @@ list(struct res *res, size_t sz, void *arg) qsort(res, sz, sizeof(struct res), cmp); - for (i = 0; i < sz; i++) + for (i = 0; i < sz; i++) { + if ( ! res[i].matched) + continue; printf("%s(%s%s%s) - %.70s\n", res[i].title, res[i].cat, *res[i].arch ? "/" : "", *res[i].arch ? res[i].arch : "", res[i].desc); + } } static int