Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/usr.sbin/makemandb Pull up following revision(s) (request...
details: https://anonhg.NetBSD.org/src/rev/70b572bade1b
branches: netbsd-6
changeset: 774017:70b572bade1b
user: riz <riz%NetBSD.org@localhost>
date: Thu Apr 19 20:03:00 2012 +0000
description:
Pull up following revision(s) (requested by wiz in ticket #186):
usr.sbin/makemandb/apropos.c: revision 1.6
usr.sbin/makemandb/apropos-utils.c: revision 1.3
usr.sbin/makemandb/apropos-utils.c: revision 1.4
Add the result from sqlite3_errmsg() to some error messages.
Now we can get "apropos: Unable to query schema version: database is locked"
instead of just "apropos: Unable to query schema version".
Handle pages with slashes in their names better.
>From Abhinav Upadhyay in private mail.
diffstat:
usr.sbin/makemandb/apropos-utils.c | 27 +++++++++++++++++++--------
usr.sbin/makemandb/apropos.c | 6 +++---
2 files changed, 22 insertions(+), 11 deletions(-)
diffs (121 lines):
diff -r 76b33defca29 -r 70b572bade1b usr.sbin/makemandb/apropos-utils.c
--- a/usr.sbin/makemandb/apropos-utils.c Thu Apr 19 19:59:10 2012 +0000
+++ b/usr.sbin/makemandb/apropos-utils.c Thu Apr 19 20:03:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apropos-utils.c,v 1.2 2012/02/07 19:17:16 joerg Exp $ */
+/* $NetBSD: apropos-utils.c,v 1.2.2.1 2012/04/19 20:03:00 riz Exp $ */
/*-
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
* All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos-utils.c,v 1.2 2012/02/07 19:17:16 joerg Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.2.2.1 2012/04/19 20:03:00 riz Exp $");
#include <sys/stat.h>
@@ -312,12 +312,14 @@
rc = sqlite3_prepare_v2(db, "PRAGMA user_version", -1, &stmt, NULL);
if (rc != SQLITE_OK) {
- warnx("Unable to query schema version");
+ warnx("Unable to query schema version: %s",
+ sqlite3_errmsg(db));
goto error;
}
if (sqlite3_step(stmt) != SQLITE_ROW) {
sqlite3_finalize(stmt);
- warnx("Unable to query schema version");
+ warnx("Unable to query schema version: %s",
+ sqlite3_errmsg(db));
goto error;
}
if (sqlite3_column_int(stmt, 0) != APROPOS_SCHEMA_VERSION) {
@@ -333,14 +335,16 @@
/* Register the zip and unzip functions for FTS compression */
rc = sqlite3_create_function(db, "zip", 1, SQLITE_ANY, NULL, zip, NULL, NULL);
if (rc != SQLITE_OK) {
- warnx("Unable to register function: compress");
+ warnx("Unable to register function: compress: %s",
+ sqlite3_errmsg(db));
goto error;
}
rc = sqlite3_create_function(db, "unzip", 1, SQLITE_ANY, NULL,
unzip, NULL, NULL);
if (rc != SQLITE_OK) {
- warnx("Unable to register function: uncompress");
+ warnx("Unable to register function: uncompress: %s",
+ sqlite3_errmsg(db));
goto error;
}
return db;
@@ -445,6 +449,8 @@
const char *name_desc;
const char *machine;
const char *snippet;
+ const char *name_temp;
+ char *slash_ptr;
char *m = NULL;
int rc;
inverse_document_frequency idf = {0, 0};
@@ -457,9 +463,11 @@
rc = sqlite3_create_function(db, "rank_func", 1, SQLITE_ANY, (void *)&idf,
rank_func, NULL, NULL);
if (rc != SQLITE_OK) {
+ warnx("Unable to register the ranking function: %s",
+ sqlite3_errmsg(db));
sqlite3_close(db);
sqlite3_shutdown();
- errx(EXIT_FAILURE, "Unable to register the ranking function");
+ exit(EXIT_FAILURE);
}
/* We want to build a query of the form: "select x,y,z from mandb where
@@ -543,13 +551,16 @@
while (sqlite3_step(stmt) == SQLITE_ROW) {
section = (const char *) sqlite3_column_text(stmt, 0);
+ name_temp = (const char *) sqlite3_column_text(stmt, 1);
name_desc = (const char *) sqlite3_column_text(stmt, 2);
machine = (const char *) sqlite3_column_text(stmt, 3);
snippet = (const char *) sqlite3_column_text(stmt, 4);
+ if ((slash_ptr = strrchr(name_temp, '/')) != NULL)
+ name_temp = slash_ptr + 1;
if (machine && machine[0]) {
m = estrdup(machine);
easprintf(&name, "%s/%s", lower(m),
- sqlite3_column_text(stmt, 1));
+ name_temp);
free(m);
} else {
name = estrdup((const char *) sqlite3_column_text(stmt, 1));
diff -r 76b33defca29 -r 70b572bade1b usr.sbin/makemandb/apropos.c
--- a/usr.sbin/makemandb/apropos.c Thu Apr 19 19:59:10 2012 +0000
+++ b/usr.sbin/makemandb/apropos.c Thu Apr 19 20:03:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: apropos.c,v 1.4.2.1 2012/02/18 18:03:26 riz Exp $ */
+/* $NetBSD: apropos.c,v 1.4.2.2 2012/04/19 20:03:00 riz Exp $ */
/*-
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
* All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos.c,v 1.4.2.1 2012/02/18 18:03:26 riz Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.4.2.2 2012/04/19 20:03:00 riz Exp $");
#include <err.h>
#include <search.h>
@@ -216,7 +216,7 @@
callback_data *cbdata = (callback_data *) data;
FILE *out = cbdata->out;
cbdata->count++;
- fprintf(out, "%s(%s)\t%s\n", name, section, name_desc);
+ fprintf(out, "%s (%s)\t%s\n", name, section, name_desc);
if (cbdata->aflags->no_context == 0)
fprintf(out, "%s\n\n", snippet);
Home |
Main Index |
Thread Index |
Old Index