Module Name: src Committed By: abhinav Date: Sun Apr 23 16:56:49 UTC 2017
Modified Files: src/usr.sbin/makemandb: whatis.c Log Message: Teach whatis(1) to handle MLINKS Similar to apropos(1), whatis did not utilise the mandb_links table till now. Therefore, if it was asked about one of the links to a man page, it would error out. This change teaches whatis(1) to look up both the FTS table as well as the links table, thus ensuring that it is able to answer queries about MLINKS as well. Comparision between outputs before this change and after this change: #Before change $ whatis realloc realloc: not found #after change $ ./whatis realloc realloc(3) - general memory allocation operations realloc(3) - general purpose memory allocation functions realloc(9) - general-purpose kernel memory allocator To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makemandb/whatis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/makemandb/whatis.c diff -u src/usr.sbin/makemandb/whatis.c:1.5 src/usr.sbin/makemandb/whatis.c:1.6 --- src/usr.sbin/makemandb/whatis.c:1.5 Sun May 22 19:26:04 2016 +++ src/usr.sbin/makemandb/whatis.c Sun Apr 23 16:56:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: whatis.c,v 1.5 2016/05/22 19:26:04 abhinav Exp $ */ +/* $NetBSD: whatis.c,v 1.6 2017/04/23 16:56:49 abhinav Exp $ */ /*- * Copyright (c) 2012 Joerg Sonnenberger <jo...@netbsd.org> * All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: whatis.c,v 1.5 2016/05/22 19:26:04 abhinav Exp $"); +__RCSID("$NetBSD: whatis.c,v 1.6 2017/04/23 16:56:49 abhinav Exp $"); #include <err.h> #include <stdio.h> @@ -49,8 +49,12 @@ static int whatis(sqlite3 *db, const char *cmd) { static const char sqlstr[] = "SELECT name, section, name_desc" - " FROM mandb WHERE name MATCH ? AND name=?" - " ORDER BY section, name"; + " FROM mandb WHERE name MATCH ? AND name=?" + " UNION" + " SELECT b.link AS name, b.section, a.name_desc FROM mandb a" + " JOIN" + " mandb_links b ON a.name=b.target AND a.section=b.section WHERE b.link=?" + " GROUP BY a.name, a.section, a.name_desc ORDER BY section, name"; sqlite3_stmt *stmt = NULL; int retval; @@ -60,6 +64,8 @@ whatis(sqlite3 *db, const char *cmd) errx(EXIT_FAILURE, "Unable to query database"); if (sqlite3_bind_text(stmt, 2, cmd, -1, NULL) != SQLITE_OK) errx(EXIT_FAILURE, "Unable to query database"); + if (sqlite3_bind_text(stmt, 3, cmd, -1, NULL) != SQLITE_OK) + errx(EXIT_FAILURE, "Unable to query database"); retval = 1; while (sqlite3_step(stmt) == SQLITE_ROW) { printf("%s(%s) - %s\n", sqlite3_column_text(stmt, 0),