aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/manpage.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-12-27 18:51:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-12-27 18:51:25 +0000
commita7ed20ecbd09e040f50a359f60f9ac351bafd50f (patch)
tree206053d141537f164a475ed3e3189b2821fca7e0 /manpage.c
parentf025d38ef1ad098b22a683e883f7b6ddce37cd66 (diff)
downloadmandoc-a7ed20ecbd09e040f50a359f60f9ac351bafd50f.tar.gz
mandoc-a7ed20ecbd09e040f50a359f60f9ac351bafd50f.tar.zst
mandoc-a7ed20ecbd09e040f50a359f60f9ac351bafd50f.zip
Change the mansearch() interface to use the mlinks table in the database
and return a list of names with sections, used by apropos(1) for display. While here, improve uniformity of the interface by allocating the file name dynamically, just like the names list and the description.
Diffstat (limited to 'manpage.c')
-rw-r--r--manpage.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/manpage.c b/manpage.c
index dadf98f1..9c98b21d 100644
--- a/manpage.c
+++ b/manpage.c
@@ -1,4 +1,4 @@
-/* $Id: manpage.c,v 1.4 2013/06/05 02:00:26 schwarze Exp $ */
+/* $Id: manpage.c,v 1.5 2013/12/27 18:51:25 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -106,11 +106,14 @@ main(int argc, char *argv[])
for (i = 0; i < sz; i++) {
printf("%6zu %s: %s\n",
- i + 1, res[i].file, res[i].desc);
+ i + 1, res[i].names, res[i].desc);
+ free(res[i].names);
free(res[i].desc);
}
if (0 == term) {
+ for (i = 0; i < sz; i++)
+ free(res[i].file);
free(res);
return(EXIT_SUCCESS);
}
@@ -127,12 +130,16 @@ main(int argc, char *argv[])
}
if (0 == i) {
+ for (i = 0; i < sz; i++)
+ free(res[i].file);
free(res);
return(EXIT_SUCCESS);
}
show:
cmd = res[i - 1].form ? "mandoc" : "cat";
strlcpy(buf, res[i - 1].file, PATH_MAX);
+ for (i = 0; i < sz; i++)
+ free(res[i].file);
free(res);
show(cmd, buf);