CVS commit: src/usr.sbin/makemandb

2023-08-07 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  7 20:35:21 UTC 2023

Modified Files:
src/usr.sbin/makemandb: custom_apropos_tokenizer.c

Log Message:
makemakedb: don't return uninitialized token length if stemming fails


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makemandb/custom_apropos_tokenizer.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/custom_apropos_tokenizer.c
diff -u src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.5 src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.6
--- src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.5	Thu Aug  3 07:49:23 2023
+++ src/usr.sbin/makemandb/custom_apropos_tokenizer.c	Mon Aug  7 20:35:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: custom_apropos_tokenizer.c,v 1.5 2023/08/03 07:49:23 rin Exp $	*/
+/*	$NetBSD: custom_apropos_tokenizer.c,v 1.6 2023/08/07 20:35:21 tnn Exp $	*/
 /*
 ** 2006 September 30
 **
@@ -719,9 +719,9 @@ aproposPorterNext(
 
 			size_t temp;
 			int stemStatus = do_stem([iStartOffset], n, c->zToken, );
-			*pnBytes = temp;
 			if (stemStatus != SQLITE_OK)
 return stemStatus;
+			*pnBytes = temp;
 
 			*pzToken = c->zToken;
 			*piStartOffset = iStartOffset;



CVS commit: src/usr.sbin/makemandb

2023-08-07 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  7 20:35:21 UTC 2023

Modified Files:
src/usr.sbin/makemandb: custom_apropos_tokenizer.c

Log Message:
makemakedb: don't return uninitialized token length if stemming fails


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makemandb/custom_apropos_tokenizer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2023-08-03 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Aug  3 07:49:23 UTC 2023

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos.c
custom_apropos_tokenizer.c fts3_tokenizer.h whatis.c

Log Message:
makemandb: trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/makemandb/apropos.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/custom_apropos_tokenizer.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makemandb/fts3_tokenizer.h
cvs rdiff -u -r1.9 -r1.10 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.



CVS commit: src/usr.sbin/makemandb

2023-08-03 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Aug  3 07:49:23 UTC 2023

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos.c
custom_apropos_tokenizer.c fts3_tokenizer.h whatis.c

Log Message:
makemandb: trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/makemandb/apropos.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/custom_apropos_tokenizer.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makemandb/fts3_tokenizer.h
cvs rdiff -u -r1.9 -r1.10 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/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.50 src/usr.sbin/makemandb/apropos-utils.c:1.51
--- src/usr.sbin/makemandb/apropos-utils.c:1.50	Sun Sep 11 20:32:37 2022
+++ src/usr.sbin/makemandb/apropos-utils.c	Thu Aug  3 07:49:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.50 2022/09/11 20:32:37 gutteridge Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.51 2023/08/03 07:49:23 rin Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.50 2022/09/11 20:32:37 gutteridge Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.51 2023/08/03 07:49:23 rin Exp $");
 
 #include 
 #include 
@@ -202,11 +202,11 @@ create_db(sqlite3 *db)
 	"CREATE VIRTUAL TABLE mandb USING fts4(section, name, "
 		"name_desc, desc, lib, return_vals, env, files, "
 		"exit_status, diagnostics, errors, md5_hash UNIQUE, machine, "
-#ifndef APROPOS_DEBUG		
+#ifndef APROPOS_DEBUG
 		"compress=zip, uncompress=unzip, tokenize=custom_apropos_tokenizer, "
 #else
 		"tokenize=porter, "
-#endif		
+#endif
 		"notindexed=section, notindexed=md5_hash); "
 	//mandb_meta
 	"CREATE TABLE IF NOT EXISTS mandb_meta(device, inode, mtime, "

Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.26 src/usr.sbin/makemandb/apropos.c:1.27
--- src/usr.sbin/makemandb/apropos.c:1.26	Thu May 19 04:08:03 2022
+++ src/usr.sbin/makemandb/apropos.c	Thu Aug  3 07:49:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.26 2022/05/19 04:08:03 gutteridge Exp $	*/
+/*	$NetBSD: apropos.c,v 1.27 2023/08/03 07:49:23 rin Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos.c,v 1.26 2022/05/19 04:08:03 gutteridge Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.27 2023/08/03 07:49:23 rin Exp $");
 
 #include 
 #include 
@@ -275,7 +275,7 @@ main(int argc, char *argv[])
 	if (pc == -1)
 		err(EXIT_FAILURE, "pclose error");
 
-	/* 
+	/*
 	 * Something wrong with the database, writing output, or a non-existent
 	 * pager.
 	 */

Index: src/usr.sbin/makemandb/custom_apropos_tokenizer.c
diff -u src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.4 src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.5
--- src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.4	Sun Dec  5 08:03:32 2021
+++ src/usr.sbin/makemandb/custom_apropos_tokenizer.c	Thu Aug  3 07:49:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: custom_apropos_tokenizer.c,v 1.4 2021/12/05 08:03:32 wiz Exp $	*/
+/*	$NetBSD: custom_apropos_tokenizer.c,v 1.5 2023/08/03 07:49:23 rin Exp $	*/
 /*
 ** 2006 September 30
 **
@@ -72,7 +72,7 @@ aproposPorterCreate(int argc, const char
 /*
  * Destroy a tokenizer
  */
-static int 
+static int
 aproposPorterDestroy(sqlite3_tokenizer * pTokenizer)
 {
 	free(pTokenizer);
@@ -82,10 +82,10 @@ aproposPorterDestroy(sqlite3_tokenizer *
 /*
  * Prepare to begin tokenizing a particular string.  The input
  * string to be tokenized is zInput[0..nInput-1].  A cursor
- * used to incrementally tokenize this string is returned in 
+ * used to incrementally tokenize this string is returned in
  * *ppCursor.
  */
-static int 
+static int
 aproposPorterOpen(
 sqlite3_tokenizer * pTokenizer,	/* The tokenizer */
 const char *zInput, int nInput,	/* String to be tokenized */
@@ -114,7 +114,7 @@ aproposPorterOpen(
  * Close a tokenization cursor previously opened by a call to
  * aproposPorterOpen() above.
  */
-static int 
+static int
 aproposPorterClose(sqlite3_tokenizer_cursor *pCursor)
 {
 	custom_apropos_tokenizer_cursor *c = (custom_apropos_tokenizer_cursor *) pCursor;
@@ -134,7 +134,7 @@ static const char cType[] = {
 /*
  * isConsonant() and isVowel() determine if their first character in
  * the string they point to is a consonant or a vowel, according
- * to Porter ruls.  
+ * to Porter ruls.
  *
  * A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.
  * 'Y' is a consonant unless it follows another consonant,
@@ -146,7 +146,7 @@ static const char cType[] = {
  */
 static int isVowel(const char*);
 
-static int 
+static int
 isConsonant(const char *z)
 {
 	int j;
@@ -160,7 +160,7 @@ 

CVS commit: src/usr.sbin/makemandb

2023-01-01 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Jan  1 21:27:14 UTC 2023

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
makemandb.c: spell "metadata" consistently


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2023-01-01 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Jan  1 21:27:14 UTC 2023

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
makemandb.c: spell "metadata" consistently


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/makemandb/makemandb.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/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.66 src/usr.sbin/makemandb/makemandb.c:1.67
--- src/usr.sbin/makemandb/makemandb.c:1.66	Sun Oct 30 01:49:30 2022
+++ src/usr.sbin/makemandb/makemandb.c	Sun Jan  1 21:27:14 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.66 2022/10/30 01:49:30 gutteridge Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.67 2023/01/01 21:27:14 gutteridge Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.66 2022/10/30 01:49:30 gutteridge Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.67 2023/01/01 21:27:14 gutteridge Exp $");
 
 #include 
 #include 
@@ -686,7 +686,7 @@ update_existing_entry(sqlite3 *db, const
 		}
 	} else {
 		if (mflags.verbosity == 2)
-			warnx("Could not update the meta data for %s", file);
+			warnx("Could not update the metadata for %s", file);
 		(*err_count)++;
 	}
 	sqlite3_finalize(inner_stmt);



CVS commit: src/usr.sbin/makemandb

2022-10-29 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 30 01:49:31 UTC 2022

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
makemandb.c: fix grammar in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/makemandb/makemandb.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/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.65 src/usr.sbin/makemandb/makemandb.c:1.66
--- src/usr.sbin/makemandb/makemandb.c:1.65	Wed Oct 26 21:56:19 2022
+++ src/usr.sbin/makemandb/makemandb.c	Sun Oct 30 01:49:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.65 2022/10/26 21:56:19 andvar Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.66 2022/10/30 01:49:30 gutteridge Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.65 2022/10/26 21:56:19 andvar Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.66 2022/10/30 01:49:30 gutteridge Exp $");
 
 #include 
 #include 
@@ -503,7 +503,7 @@ traversedir(const char *parent, const ch
 }
 
 /* build_file_cache --
- *   This function generates a md5 hash of the file passed as its 2nd parameter
+ *   This function generates an md5 hash of the file passed as its 2nd parameter
  *   and stores it in a temporary table file_cache along with the full file path.
  *   This is done to support incremental update of the database.
  *   The temporary table file_cache is dropped thereafter in the function



CVS commit: src/usr.sbin/makemandb

2022-10-29 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 30 01:49:31 UTC 2022

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
makemandb.c: fix grammar in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-09-11 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Sep 11 20:32:38 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos-utils.3 apropos-utils.c close_db.3
init_db.3 makemandb.8 makemandb.c run_query.3 whatis.1

Log Message:
makemandb/*: fix spelling of database and consistency of SQLite


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/apropos-utils.3 \
src/usr.sbin/makemandb/run_query.3 src/usr.sbin/makemandb/whatis.1
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/close_db.3
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makemandb/init_db.3
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makemandb/makemandb.8
cvs rdiff -u -r1.63 -r1.64 src/usr.sbin/makemandb/makemandb.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/apropos-utils.3
diff -u src/usr.sbin/makemandb/apropos-utils.3:1.4 src/usr.sbin/makemandb/apropos-utils.3:1.5
--- src/usr.sbin/makemandb/apropos-utils.3:1.4	Tue May 24 18:06:42 2016
+++ src/usr.sbin/makemandb/apropos-utils.3	Sun Sep 11 20:32:37 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos-utils.3,v 1.4 2016/05/24 18:06:42 abhinav Exp $
+.\" $NetBSD: apropos-utils.3,v 1.5 2022/09/11 20:32:37 gutteridge Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -49,7 +49,7 @@ These functions all live in the
 header file.
 They operate on
 .Pa /var/db/man.db
-which is an Sqlite database containing a full text search index of the manual
+which is an SQLite database containing a full text search index of the manual
 pages.
 The functions provide an easy to use interface to query the database and
 develop applications on top of it.
Index: src/usr.sbin/makemandb/run_query.3
diff -u src/usr.sbin/makemandb/run_query.3:1.4 src/usr.sbin/makemandb/run_query.3:1.5
--- src/usr.sbin/makemandb/run_query.3:1.4	Tue May 24 18:06:42 2016
+++ src/usr.sbin/makemandb/run_query.3	Sun Sep 11 20:32:37 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: run_query.3,v 1.4 2016/05/24 18:06:42 abhinav Exp $
+.\" $NetBSD: run_query.3,v 1.5 2022/09/11 20:32:37 gutteridge Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -161,7 +161,7 @@ function will return 0 and in case of an
 .Sh FILES
 .Bl -hang -width /var/db/man.db -compact
 .It Pa /var/db/man.db
-The Sqlite FTS database which contains an index of the manual pages.
+The SQLite FTS database which contains an index of the manual pages.
 .El
 .Sh EXAMPLES
 Following is a code excerpt of how
Index: src/usr.sbin/makemandb/whatis.1
diff -u src/usr.sbin/makemandb/whatis.1:1.4 src/usr.sbin/makemandb/whatis.1:1.5
--- src/usr.sbin/makemandb/whatis.1:1.4	Thu Jun 16 14:07:16 2016
+++ src/usr.sbin/makemandb/whatis.1	Sun Sep 11 20:32:37 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: whatis.1,v 1.4 2016/06/16 14:07:16 abhinav Exp $
+.\" $NetBSD: whatis.1,v 1.5 2022/09/11 20:32:37 gutteridge Exp $
 .\"
 .\" Copyright (c) 2012 Joerg Sonnenberger 
 .\" All rights reserved.
@@ -58,7 +58,7 @@ configuration file than the default,
 .Sh FILES
 .Bl -hang -width /etc/man.conf -compact
 .It Pa /etc/man.conf
-The location of the Sqlite FTS database can be configured using the
+The location of the SQLite FTS database can be configured using the
 .Cd _mandb
 tag.
 .El

Index: src/usr.sbin/makemandb/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.49 src/usr.sbin/makemandb/apropos-utils.c:1.50
--- src/usr.sbin/makemandb/apropos-utils.c:1.49	Thu May 19 04:08:03 2022
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Sep 11 20:32:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.49 2022/05/19 04:08:03 gutteridge Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.50 2022/09/11 20:32:37 gutteridge Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.49 2022/05/19 04:08:03 gutteridge Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.50 2022/09/11 20:32:37 gutteridge Exp $");
 
 #include 
 #include 
@@ -241,7 +241,7 @@ out:
 
 /*
  * zip --
- *  User defined Sqlite function to compress the FTS table
+ *  User defined SQLite function to compress the FTS table
  */
 static void
 zip(sqlite3_context *pctx, int nval, sqlite3_value **apval)
@@ -262,7 +262,7 @@ zip(sqlite3_context *pctx, int nval, sql
 
 /*
  * unzip --
- *  User defined Sqlite function to uncompress the FTS table.
+ *  User defined SQLite function to uncompress the FTS table.
  */
 static void
 unzip(sqlite3_context *pctx, int nval, sqlite3_value **apval)
@@ -459,7 +459,7 @@ error:
 
 /*
  * rank_func --
- *  Sqlite user defined function for ranking the documents.
+ *  SQLite user defined function for ranking the documents.
  *  For each phrase of the query, it computes the tf and idf and adds them over.
  *  It computes the final rank, by multiplying tf and idf together.
 

CVS commit: src/usr.sbin/makemandb

2022-09-11 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Sep 11 20:32:38 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos-utils.3 apropos-utils.c close_db.3
init_db.3 makemandb.8 makemandb.c run_query.3 whatis.1

Log Message:
makemandb/*: fix spelling of database and consistency of SQLite


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/apropos-utils.3 \
src/usr.sbin/makemandb/run_query.3 src/usr.sbin/makemandb/whatis.1
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/close_db.3
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makemandb/init_db.3
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makemandb/makemandb.8
cvs rdiff -u -r1.63 -r1.64 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-06-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun  6 07:41:23 UTC 2022

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
Don't index outside the mdocs array of function pointers.  Analysis and
suggested fixes from Tom Lane.  I played it safe and went with (my
variation of) the minimal fix.

port-hppa/56118: sporadic app crashes in HPPA -current


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-06-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jun  6 07:41:23 UTC 2022

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
Don't index outside the mdocs array of function pointers.  Analysis and
suggested fixes from Tom Lane.  I played it safe and went with (my
variation of) the minimal fix.

port-hppa/56118: sporadic app crashes in HPPA -current


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/makemandb/makemandb.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/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.62 src/usr.sbin/makemandb/makemandb.c:1.63
--- src/usr.sbin/makemandb/makemandb.c:1.62	Wed Apr  6 03:23:38 2022
+++ src/usr.sbin/makemandb/makemandb.c	Mon Jun  6 07:41:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.62 2022/04/06 03:23:38 gutteridge Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.63 2022/06/06 07:41:23 skrll Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.62 2022/04/06 03:23:38 gutteridge Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.63 2022/06/06 07:41:23 skrll Exp $");
 
 #include 
 #include 
@@ -1078,15 +1078,18 @@ mdoc_parse_Sh(const struct roff_node *n,
 
 	if (n->type == ROFFT_TEXT) {
 		mdoc_parse_section(n->sec, n->string, rec);
-	} else if (mdocs[n->tok] == pmdoc_Xr) {
-		/*
-		 * When encountering other inline macros,
-		 * call pmdoc_macro_handler.
-		 */
-		pmdoc_macro_handler(n, rec, MDOC_Xr);
-		xr_found = 1;
-	} else if (mdocs[n->tok] == pmdoc_Pp) {
-		pmdoc_macro_handler(n, rec, MDOC_Pp);
+	} else if (n->tok >= MDOC_Dd && n->tok < MDOC_MAX) {
+		const int tok_idx = n->tok - MDOC_Dd;
+		if (mdocs[tok_idx] == pmdoc_Xr) {
+			/*
+			* When encountering other inline macros,
+			* call pmdoc_macro_handler.
+			*/
+			pmdoc_macro_handler(n, rec, MDOC_Xr);
+			xr_found = 1;
+		} else if (mdocs[tok_idx] == pmdoc_Pp) {
+			pmdoc_macro_handler(n, rec, MDOC_Pp);
+		}
 	}
 
 	/*



CVS commit: src/usr.sbin/makemandb

2022-05-18 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu May 19 04:08:03 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos.c

Log Message:
apropos(1): improve error handling in edge cases

Patch from RVP on NetBSD-Users, with an additional comment tweak by me.
Summary from RVP:

1. Ignore SIGPIPE so that we're not killed in the middle of some
   DB operation by a botched $PAGER:

$ env PAGER=/non-existent apropos -p ...

2. Return proper exit status in case of write errors:

$ apropos ... >/dev/full || echo fail


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/makemandb/apropos.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/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.48 src/usr.sbin/makemandb/apropos-utils.c:1.49
--- src/usr.sbin/makemandb/apropos-utils.c:1.48	Sat Nov 27 22:30:25 2021
+++ src/usr.sbin/makemandb/apropos-utils.c	Thu May 19 04:08:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.48 2021/11/27 22:30:25 rillig Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.49 2022/05/19 04:08:03 gutteridge Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.48 2021/11/27 22:30:25 rillig Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.49 2022/05/19 04:08:03 gutteridge Exp $");
 
 #include 
 #include 
@@ -665,7 +665,7 @@ get_stmt_col_text(sqlite3_stmt *stmt, in
  * Execute the full text search query and return the number of results
  * obtained.
  */
-static unsigned int
+static int
 execute_search_query(sqlite3 *db, char *query, query_args *args)
 {
 	sqlite3_stmt *stmt;
@@ -699,8 +699,8 @@ execute_search_query(sqlite3 *db, char *
 		return -1;
 	}
 
-	unsigned int nresults = 0;
-	while (sqlite3_step(stmt) == SQLITE_ROW) {
+	int nresults = rc = 0;
+	while (rc == 0 && sqlite3_step(stmt) == SQLITE_ROW) {
 		nresults++;
 		callback_args.section = get_stmt_col_text(stmt, 0);
 		name_temp = get_stmt_col_text(stmt, 1);
@@ -725,11 +725,11 @@ execute_search_query(sqlite3 *db, char *
 		}
 		callback_args.name = name;
 		callback_args.other_data = args->callback_data;
-		(args->callback)(_args);
+		rc = (args->callback)(_args);
 		free(name);
 	}
 	sqlite3_finalize(stmt);
-	return nresults;
+	return (rc < 0) ? rc : nresults;
 }
 
 
@@ -752,9 +752,9 @@ run_query_internal(sqlite3 *db, const ch
 		return -1;
 	}
 
-	execute_search_query(db, query, args);
+	int rc = execute_search_query(db, query, args);
 	sqlite3_free(query);
-	return *(args->errmsg) == NULL ? 0 : -1;
+	return (rc < 0 || *(args->errmsg) != NULL) ? -1 : 0;
 }
 
 static char *
@@ -845,10 +845,10 @@ callback_html(query_callback_args *callb
 	callback_args->snippet = qsnippet;
 	callback_args->snippet_length = length;
 	callback_args->other_data = orig_data->data;
-	(*callback)(callback_args);
+	int rc = (*callback)(callback_args);
 	free(qsnippet);
 	free(qname_description);
-	return 0;
+	return rc;
 }
 
 /*
@@ -968,12 +968,12 @@ callback_pager(query_callback_args *call
 	callback_args->snippet = psnippet;
 	callback_args->snippet_length = psnippet_length;
 	callback_args->other_data = orig_data->data;
-	(orig_data->callback)(callback_args);
+	int rc = (orig_data->callback)(callback_args);
 	free(ul_section);
 	free(ul_name);
 	free(ul_name_desc);
 	free(psnippet);
-	return 0;
+	return rc;
 }
 
 struct term_args {
@@ -1013,11 +1013,11 @@ callback_term(query_callback_args *callb
 	callback_args->name = ul_name;
 	callback_args->name_desc = ul_name_desc;
 	callback_args->other_data = orig_data->data;
-	(orig_data->callback)(callback_args);
+	int rc = (orig_data->callback)(callback_args);
 	free(ul_section);
 	free(ul_name);
 	free(ul_name_desc);
-	return 0;
+	return rc;
 }
 
 /*

Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.25 src/usr.sbin/makemandb/apropos.c:1.26
--- src/usr.sbin/makemandb/apropos.c:1.25	Tue May 17 00:21:22 2022
+++ src/usr.sbin/makemandb/apropos.c	Thu May 19 04:08:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $	*/
+/*	$NetBSD: apropos.c,v 1.26 2022/05/19 04:08:03 gutteridge Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,9 +31,10 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.26 2022/05/19 04:08:03 gutteridge Exp $");
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -223,6 +224,10 @@ main(int argc, char *argv[])
 		const char *pager = getenv("PAGER");
 		if (pager == NULL)
 			pager = _PATH_PAGER;
+
+		/* Don't get killed by a broken pipe */
+		signal(SIGPIPE, SIG_IGN);
+
 		/* Open a pipe to the pager */
 		if ((cbdata.out = popen(pager, "w")) == NULL) {
 			

CVS commit: src/usr.sbin/makemandb

2022-05-18 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu May 19 04:08:03 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos.c

Log Message:
apropos(1): improve error handling in edge cases

Patch from RVP on NetBSD-Users, with an additional comment tweak by me.
Summary from RVP:

1. Ignore SIGPIPE so that we're not killed in the middle of some
   DB operation by a botched $PAGER:

$ env PAGER=/non-existent apropos -p ...

2. Return proper exit status in case of write errors:

$ apropos ... >/dev/full || echo fail


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/makemandb/apropos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 11:37:54 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): Use the official spelling for "SQLite".

While here, use .Bx to refer to 3BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makemandb/apropos.1

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/apropos.1
diff -u src/usr.sbin/makemandb/apropos.1:1.22 src/usr.sbin/makemandb/apropos.1:1.23
--- src/usr.sbin/makemandb/apropos.1:1.22	Tue May 17 11:31:14 2022
+++ src/usr.sbin/makemandb/apropos.1	Tue May 17 11:37:54 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.22 2022/05/17 11:31:14 uwe Exp $
+.\" $NetBSD: apropos.1,v 1.23 2022/05/17 11:37:54 uwe Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -47,7 +47,7 @@
 The
 .Nm
 utility performs a full text search over the complete content of all man pages.
-It uses the FTS engine of Sqlite to perform the search.
+It uses the FTS engine of SQLite to perform the search.
 The database is created with the help of the
 .Xr makemandb 8
 utility.
@@ -107,7 +107,7 @@ For single digit sections you can use ab
 .Sh FILES
 .Bl -hang -width /etc/man.conf -compact
 .It Pa /etc/man.conf
-The location of the Sqlite FTS database can be configured using the
+The location of the SQLite FTS database can be configured using the
 .Cd _mandb
 tag.
 .El
@@ -133,9 +133,10 @@ will be used.
 .Sh HISTORY
 The
 .Nm
-command appeared in 3.0BSD.
+command appeared in
+.Bx 3 .
 It was rewritten in
 .Nx 6.0
-to support full text search using Sqlite.
+to support full text search using SQLite.
 .Sh AUTHORS
 .An Abhinav Upadhyay



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 11:37:54 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): Use the official spelling for "SQLite".

While here, use .Bx to refer to 3BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makemandb/apropos.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 11:31:14 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): Tweak the description of -1, ... -9, and -s

-s is not for compatibility only, because section names can be
anything.  E.g. we have 3lua and 9lua in base.  We have rudiments of
3f (for FORTRAN libs).  Some packages in pkgsrc also use suffixed 1
and 3 sections.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makemandb/apropos.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 11:31:14 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): Tweak the description of -1, ... -9, and -s

-s is not for compatibility only, because section names can be
anything.  E.g. we have 3lua and 9lua in base.  We have rudiments of
3f (for FORTRAN libs).  Some packages in pkgsrc also use suffixed 1
and 3 sections.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makemandb/apropos.1

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/apropos.1
diff -u src/usr.sbin/makemandb/apropos.1:1.21 src/usr.sbin/makemandb/apropos.1:1.22
--- src/usr.sbin/makemandb/apropos.1:1.21	Tue May 17 08:39:58 2022
+++ src/usr.sbin/makemandb/apropos.1	Tue May 17 11:31:14 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.21 2022/05/17 08:39:58 uwe Exp $
+.\" $NetBSD: apropos.1,v 1.22 2022/05/17 11:31:14 uwe Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -63,8 +63,12 @@ Quotes are optional for specifying multi
 .Pp
 It supports the following options:
 .Bl -tag -width Fl
-.It Fl [1-9]
-Search only within the specified section of manual pages.
+.It Fl 1 , No \&... , Fl 9
+Limit the search to the specified section of the manual.
+By default, pages from all sections are shown.
+These options are abbreviations for the
+.Fl s
+option for single digit sections.
 .It Fl C Ar path
 Use different
 .Xr man 1
@@ -95,12 +99,10 @@ Turn off formatting.
 Limit the search to the pages for the specified machine architecture.
 By default pages for all architectures are shown in the search results.
 .It Fl s Ar section
-Restrict the search to the specified section of the manual.
+Limit the search to the specified section of the manual.
 By default, pages from all sections are shown.
-This option is for backwards compatibility with the classic version of apropos,
-using it is equivalent to using the
-.Op 123456789
-options directly.
+For single digit sections you can use abbreviations:
+.Fl 1 , No \&... , Fl 9 .
 .El
 .Sh FILES
 .Bl -hang -width /etc/man.conf -compact



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 08:39:58 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): use proper -width for the list of options too


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makemandb/apropos.1

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/apropos.1
diff -u src/usr.sbin/makemandb/apropos.1:1.20 src/usr.sbin/makemandb/apropos.1:1.21
--- src/usr.sbin/makemandb/apropos.1:1.20	Tue May 17 08:35:46 2022
+++ src/usr.sbin/makemandb/apropos.1	Tue May 17 08:39:58 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.20 2022/05/17 08:35:46 uwe Exp $
+.\" $NetBSD: apropos.1,v 1.21 2022/05/17 08:39:58 uwe Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -62,7 +62,7 @@ relevance.
 Quotes are optional for specifying multiword queries.
 .Pp
 It supports the following options:
-.Bl -tag -width indent
+.Bl -tag -width Fl
 .It Fl [1-9]
 Search only within the specified section of manual pages.
 .It Fl C Ar path



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 08:39:58 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): use proper -width for the list of options too


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makemandb/apropos.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 08:35:46 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): use proper -width


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makemandb/apropos.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-05-17 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Tue May 17 08:35:46 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos(1): use proper -width


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makemandb/apropos.1

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/apropos.1
diff -u src/usr.sbin/makemandb/apropos.1:1.19 src/usr.sbin/makemandb/apropos.1:1.20
--- src/usr.sbin/makemandb/apropos.1:1.19	Tue May 17 01:22:14 2022
+++ src/usr.sbin/makemandb/apropos.1	Tue May 17 08:35:46 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.19 2022/05/17 01:22:14 gutteridge Exp $
+.\" $NetBSD: apropos.1,v 1.20 2022/05/17 08:35:46 uwe Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -110,7 +110,7 @@ The location of the Sqlite FTS database 
 tag.
 .El
 .Sh ENVIRONMENT VARIABLES
-.Bl -tag -width APROPOSX
+.Bl -tag -width Ev
 .It Ev APROPOS
 This environment variable is white-space tokenized as an argument vector
 and the options in it are parsed and set.



CVS commit: src/usr.sbin/makemandb

2022-05-16 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue May 17 01:22:14 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos.1: document the PAGER environment variable


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makemandb/apropos.1

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/apropos.1
diff -u src/usr.sbin/makemandb/apropos.1:1.18 src/usr.sbin/makemandb/apropos.1:1.19
--- src/usr.sbin/makemandb/apropos.1:1.18	Fri Jun 17 18:48:07 2016
+++ src/usr.sbin/makemandb/apropos.1	Tue May 17 01:22:14 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.18 2016/06/17 18:48:07 abhinav Exp $
+.\" $NetBSD: apropos.1,v 1.19 2022/05/17 01:22:14 gutteridge Exp $
 .\"
 .\" Copyright (c) 2011 Abhinav Upadhyay 
 .\" All rights reserved.
@@ -29,7 +29,7 @@
 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 16, 2016
+.Dd May 17, 2022
 .Dt APROPOS 1
 .Os
 .Sh NAME
@@ -110,11 +110,19 @@ The location of the Sqlite FTS database 
 tag.
 .El
 .Sh ENVIRONMENT VARIABLES
-The
-.Ev APROPOS
-environment variable is white-space tokenized as an argument vector
+.Bl -tag -width APROPOSX
+.It Ev APROPOS
+This environment variable is white-space tokenized as an argument vector
 and the options in it are parsed and set.
 Command line options override the environment options.
+.It Ev PAGER
+The pagination command used for writing the output, should this be requested.
+If the
+.Ev PAGER
+environment variable is null or not set, the standard pagination program
+.Xr more 1
+will be used.
+.El
 .Sh SEE ALSO
 .Xr man 1 ,
 .Xr whatis 1 ,



CVS commit: src/usr.sbin/makemandb

2022-05-16 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue May 17 01:22:14 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.1

Log Message:
apropos.1: document the PAGER environment variable


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makemandb/apropos.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-05-16 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue May 17 00:21:22 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.c

Log Message:
apropos.c: fix pager functionality

Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/makemandb/apropos.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/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.24 src/usr.sbin/makemandb/apropos.c:1.25
--- src/usr.sbin/makemandb/apropos.c:1.24	Sat Nov 25 14:29:38 2017
+++ src/usr.sbin/makemandb/apropos.c	Tue May 17 00:21:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $	*/
+/*	$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.25 2022/05/17 00:21:22 gutteridge Exp $");
 
 #include 
 #include 
@@ -157,6 +157,7 @@ main(int argc, char *argv[])
 	char *query = NULL;	// the user query
 	char *errmsg = NULL;
 	char *str;
+	int pc = 0;
 	int rc = 0;
 	size_t i;
 	int s;
@@ -249,6 +250,8 @@ main(int argc, char *argv[])
 	if (aflags.format == APROPOS_HTML)
 		fprintf(cbdata.out, "\n\n\n");
 
+	if (aflags.pager)
+		pc = pclose(cbdata.out);
 	free(query);
 
 	if (aflags.sections) {
@@ -264,6 +267,9 @@ main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
+	if (pc == -1)
+		err(EXIT_FAILURE, "pclose error");
+
 	if (rc < 0) {
 		/* Something wrong with the database. Exit */
 		exit(EXIT_FAILURE);



CVS commit: src/usr.sbin/makemandb

2022-05-16 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Tue May 17 00:21:22 UTC 2022

Modified Files:
src/usr.sbin/makemandb: apropos.c

Log Message:
apropos.c: fix pager functionality

Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/makemandb/apropos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-04-05 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Apr  6 03:23:38 UTC 2022

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
makemandb.c: fail sooner if man page dirs can't be found

There's no point initializing database state if we're then going to
fail to locate any man page sources. Make all the initial state checks
contiguous for simplicity and readability. Also, free the variable
"command" on the error path, and correct the error message.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2022-04-05 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Apr  6 03:23:38 UTC 2022

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
makemandb.c: fail sooner if man page dirs can't be found

There's no point initializing database state if we're then going to
fail to locate any man page sources. Make all the initial state checks
contiguous for simplicity and readability. Also, free the variable
"command" on the error path, and correct the error message.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/makemandb/makemandb.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/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.61 src/usr.sbin/makemandb/makemandb.c:1.62
--- src/usr.sbin/makemandb/makemandb.c:1.61	Sun Dec  5 08:18:18 2021
+++ src/usr.sbin/makemandb/makemandb.c	Wed Apr  6 03:23:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.61 2021/12/05 08:18:18 msaitoh Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.62 2022/04/06 03:23:38 gutteridge Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.61 2021/12/05 08:18:18 msaitoh Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.62 2022/04/06 03:23:38 gutteridge Exp $");
 
 #include 
 #include 
@@ -351,6 +351,13 @@ main(int argc, char *argv[])
 		manconf = MANCONF;
 	}
 
+	/* Call man -p to get the list of man page dirs */
+	if ((file = popen(command, "r")) == NULL) {
+		free(command);
+		err(EXIT_FAILURE, "popen failed");
+	}
+	free(command);
+
 	if (mflags.recreate) {
 		char *dbp = get_dbpath(manconf);
 		/* No error here, it will fail in init_db in the same call */
@@ -378,14 +385,6 @@ main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-
-	/* Call man -p to get the list of man page dirs */
-	if ((file = popen(command, "r")) == NULL) {
-		close_db(db);
-		err(EXIT_FAILURE, "fopen failed");
-	}
-	free(command);
-
 	/* Begin the transaction for indexing the pages	*/
 	sqlite3_exec(db, "BEGIN", NULL, NULL, );
 	if (errmsg != NULL) {



CVS commit: src/usr.sbin/makemandb

2021-12-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Dec  5 08:18:18 UTC 2021

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
s/trival/trivial/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/makemandb/makemandb.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/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.60 src/usr.sbin/makemandb/makemandb.c:1.61
--- src/usr.sbin/makemandb/makemandb.c:1.60	Sat May 18 07:56:43 2019
+++ src/usr.sbin/makemandb/makemandb.c	Sun Dec  5 08:18:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.60 2019/05/18 07:56:43 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.61 2021/12/05 08:18:18 msaitoh Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.60 2019/05/18 07:56:43 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.61 2021/12/05 08:18:18 msaitoh Exp $");
 
 #include 
 #include 
@@ -1259,7 +1259,7 @@ pman_sh(const struct roff_node *n, mandb
 
 	/*
 	 * Check if this section should be extracted and
-	 * where it should be stored. Handled the trival cases first.
+	 * where it should be stored. Handled the trivial cases first.
 	 */
 	for (i = 0; i < sizeof(mapping) / sizeof(mapping[0]); ++i) {
 		if (strcmp(head->string, mapping[i].header) == 0) {



CVS commit: src/usr.sbin/makemandb

2021-12-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun Dec  5 08:18:18 UTC 2021

Modified Files:
src/usr.sbin/makemandb: makemandb.c

Log Message:
s/trival/trivial/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2021-12-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Dec  5 08:03:32 UTC 2021

Modified Files:
src/usr.sbin/makemandb: custom_apropos_tokenizer.c

Log Message:
preceds -> precedes


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makemandb/custom_apropos_tokenizer.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/custom_apropos_tokenizer.c
diff -u src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.3 src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.4
--- src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.3	Sun Dec  5 07:13:49 2021
+++ src/usr.sbin/makemandb/custom_apropos_tokenizer.c	Sun Dec  5 08:03:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: custom_apropos_tokenizer.c,v 1.3 2021/12/05 07:13:49 msaitoh Exp $	*/
+/*	$NetBSD: custom_apropos_tokenizer.c,v 1.4 2021/12/05 08:03:32 wiz Exp $	*/
 /*
 ** 2006 September 30
 **
@@ -304,7 +304,7 @@ star_oh(const char *z)
 
 /*
  * If the word ends with zFrom and xCond() is true for the stem
- * of the word that preceds the zFrom ending, then change the 
+ * of the word that precedes the zFrom ending, then change the 
  * ending to zTo.
  *
  * The input word *pz and zFrom are both in reverse order.  zTo



CVS commit: src/usr.sbin/makemandb

2021-12-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Dec  5 08:03:32 UTC 2021

Modified Files:
src/usr.sbin/makemandb: custom_apropos_tokenizer.c

Log Message:
preceds -> precedes


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makemandb/custom_apropos_tokenizer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2019-08-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Aug 18 09:14:30 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c

Log Message:
PR bin/54343:  We want the callback_args.machine to be NULL if it is not 
present in the DB.

The previous commit fixed the problem of allowing apropos to not crash and
produce output even if the database is missing values for certain mandatory
fields, such as name, section etc. Normally we don't expect those values
to be missing in the database but in case of parsing errors it can happen.

However, the machine architecture is an optional field since not all man pages
are hardware specific so that should be allowed to be set to NULL if not
present in the database.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makemandb/apropos-utils.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2019-08-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Aug 18 09:14:30 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c

Log Message:
PR bin/54343:  We want the callback_args.machine to be NULL if it is not 
present in the DB.

The previous commit fixed the problem of allowing apropos to not crash and
produce output even if the database is missing values for certain mandatory
fields, such as name, section etc. Normally we don't expect those values
to be missing in the database but in case of parsing errors it can happen.

However, the machine architecture is an optional field since not all man pages
are hardware specific so that should be allowed to be set to NULL if not
present in the database.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makemandb/apropos-utils.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/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.46 src/usr.sbin/makemandb/apropos-utils.c:1.47
--- src/usr.sbin/makemandb/apropos-utils.c:1.46	Thu Aug 15 10:29:07 2019
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Aug 18 09:14:30 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.46 2019/08/15 10:29:07 christos Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.47 2019/08/18 09:14:30 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.46 2019/08/15 10:29:07 christos Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.47 2019/08/18 09:14:30 abhinav Exp $");
 
 #include 
 #include 
@@ -705,7 +705,7 @@ execute_search_query(sqlite3 *db, char *
 		callback_args.section = get_stmt_col_text(stmt, 0);
 		name_temp = get_stmt_col_text(stmt, 1);
 		callback_args.name_desc = get_stmt_col_text(stmt, 2);
-		callback_args.machine = get_stmt_col_text(stmt, 3);
+		callback_args.machine = (const char *) sqlite3_column_text(stmt, 3);
 		if (!args->legacy) {
 			callback_args.snippet = get_stmt_col_text(stmt, 4);
 			callback_args.snippet_length =



CVS commit: src/usr.sbin/makemandb

2019-08-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 15 10:29:07 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c

Log Message:
PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
identify them.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/makemandb/apropos-utils.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2019-08-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 15 10:29:07 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c

Log Message:
PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
identify them.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/makemandb/apropos-utils.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/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.45 src/usr.sbin/makemandb/apropos-utils.c:1.46
--- src/usr.sbin/makemandb/apropos-utils.c:1.45	Fri Jun  7 12:43:58 2019
+++ src/usr.sbin/makemandb/apropos-utils.c	Thu Aug 15 06:29:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.45 2019/06/07 16:43:58 leot Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.46 2019/08/15 10:29:07 christos Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.45 2019/06/07 16:43:58 leot Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.46 2019/08/15 10:29:07 christos Exp $");
 
 #include 
 #include 
@@ -654,6 +654,13 @@ RETURN:
 	return query;
 }
 
+static const char *
+get_stmt_col_text(sqlite3_stmt *stmt, int col)
+{
+	const char *t = (const char *) sqlite3_column_text(stmt, col);
+	return t == NULL ? "*?*" : t;
+}
+
 /*
  * Execute the full text search query and return the number of results
  * obtained.
@@ -695,13 +702,14 @@ execute_search_query(sqlite3 *db, char *
 	unsigned int nresults = 0;
 	while (sqlite3_step(stmt) == SQLITE_ROW) {
 		nresults++;
-		callback_args.section = (const char *) sqlite3_column_text(stmt, 0);
-		name_temp = (const char *) sqlite3_column_text(stmt, 1);
-		callback_args.name_desc = (const char *) sqlite3_column_text(stmt, 2);
-		callback_args.machine = (const char *) sqlite3_column_text(stmt, 3);
+		callback_args.section = get_stmt_col_text(stmt, 0);
+		name_temp = get_stmt_col_text(stmt, 1);
+		callback_args.name_desc = get_stmt_col_text(stmt, 2);
+		callback_args.machine = get_stmt_col_text(stmt, 3);
 		if (!args->legacy) {
-			callback_args.snippet = (const char *) sqlite3_column_text(stmt, 4);
-			callback_args.snippet_length = strlen(callback_args.snippet);
+			callback_args.snippet = get_stmt_col_text(stmt, 4);
+			callback_args.snippet_length =
+			strlen(callback_args.snippet);
 		} else {
 			callback_args.snippet = "";
 			callback_args.snippet_length = 1;
@@ -713,8 +721,7 @@ execute_search_query(sqlite3 *db, char *
 			easprintf(, "%s/%s", lower(m), name_temp);
 			free(m);
 		} else {
-			name = estrdup((const char *)
-			sqlite3_column_text(stmt, 1));
+			name = estrdup(get_stmt_col_text(stmt, 1));
 		}
 		callback_args.name = name;
 		callback_args.other_data = args->callback_data;



CVS commit: src/usr.sbin/makemandb

2019-06-07 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Fri Jun  7 16:43:58 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c

Log Message:
Properly free section_clause.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/makemandb/apropos-utils.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/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.44 src/usr.sbin/makemandb/apropos-utils.c:1.45
--- src/usr.sbin/makemandb/apropos-utils.c:1.44	Sat May 18 07:56:43 2019
+++ src/usr.sbin/makemandb/apropos-utils.c	Fri Jun  7 16:43:58 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.44 2019/05/18 07:56:43 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.45 2019/06/07 16:43:58 leot Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.44 2019/05/18 07:56:43 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.45 2019/06/07 16:43:58 leot Exp $");
 
 #include 
 #include 
@@ -649,7 +649,7 @@ generate_search_query(query_args *args, 
 
 RETURN:
 	sqlite3_free(machine_clause);
-	sqlite3_free(section_clause);
+	free(section_clause);
 	sqlite3_free(limit_clause);
 	return query;
 }



CVS commit: src/usr.sbin/makemandb

2019-06-07 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Fri Jun  7 16:43:58 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c

Log Message:
Properly free section_clause.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/makemandb/apropos-utils.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2019-05-18 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Sat May 18 10:38:04 UTC 2019

Modified Files:
src/usr.sbin/makemandb: DBSCHEMA

Log Message:
Document name_desc attribute of mandb_links.

Discussed with  via PR misc/54213, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/DBSCHEMA

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/makemandb

2019-05-18 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Sat May 18 10:28:57 UTC 2019

Modified Files:
src/usr.sbin/makemandb: whatis.c

Log Message:
Reintroduce case insensitive comparison of name accidentally lost in last
revision.

Discussed with  via PR misc/54213, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.



CVS commit: src/usr.sbin/makemandb

2019-05-18 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Sat May 18 10:28:57 UTC 2019

Modified Files:
src/usr.sbin/makemandb: whatis.c

Log Message:
Reintroduce case insensitive comparison of name accidentally lost in last
revision.

Discussed with  via PR misc/54213, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.8 src/usr.sbin/makemandb/whatis.c:1.9
--- src/usr.sbin/makemandb/whatis.c:1.8	Sat May 18 07:56:43 2019
+++ src/usr.sbin/makemandb/whatis.c	Sat May 18 10:28:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: whatis.c,v 1.8 2019/05/18 07:56:43 abhinav Exp $	*/
+/*	$NetBSD: whatis.c,v 1.9 2019/05/18 10:28:57 leot Exp $	*/
 /*-
  * Copyright (c) 2012 Joerg Sonnenberger 
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: whatis.c,v 1.8 2019/05/18 07:56:43 abhinav Exp $");
+__RCSID("$NetBSD: whatis.c,v 1.9 2019/05/18 10:28:57 leot Exp $");
 
 #include 
 #include 
@@ -49,8 +49,11 @@ static int
 whatis(sqlite3 *db, const char *cmd)
 {
 	static const char sqlstr[] = "SELECT link AS name, section, name_desc"
-		" FROM mandb_links WHERE link=? UNION SELECT name, section, name_desc"
-		" FROM mandb WHERE name MATCH ? AND name=? ORDER BY section";
+		" FROM mandb_links WHERE link=?" 
+		" UNION"
+		" SELECT name, section, name_desc"
+		" FROM mandb WHERE name MATCH ? AND name=? COLLATE NOCASE"
+		" ORDER BY section";
 	sqlite3_stmt *stmt = NULL;
 	int retval;
 	int i;



CVS commit: src/usr.sbin/makemandb

2019-05-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat May 18 07:56:43 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos-utils.h makemandb.c
whatis.c

Log Message:
PR misc/54213: Fix performance of whatis(1) when no matches are found

In revision 1.6 of whatis.c the query was modified to return matches for names 
found
in MLINKS of the man pages as well. However it was slow. The reason probably 
being that it
required a join. But more importantly the where condition on an FTS virtual 
table column
is very slow. To avoid the join and the expensive where condition on the 
virtual table,
add the name_desc column to the mandb_links table as well. This improves the 
performance
of whatis(1) to the original level at the expense of slight data duplication.

Bump the schema to force database rebuild to take account for the new column 
addition


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/makemandb/makemandb.c
cvs rdiff -u -r1.7 -r1.8 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/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.43 src/usr.sbin/makemandb/apropos-utils.c:1.44
--- src/usr.sbin/makemandb/apropos-utils.c:1.43	Fri Apr 19 20:35:13 2019
+++ src/usr.sbin/makemandb/apropos-utils.c	Sat May 18 07:56:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.43 2019/04/19 20:35:13 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.44 2019/05/18 07:56:43 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.43 2019/04/19 20:35:13 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.44 2019/05/18 07:56:43 abhinav Exp $");
 
 #include 
 #include 
@@ -213,7 +213,7 @@ create_db(sqlite3 *db)
 		"file UNIQUE, md5_hash UNIQUE, id  INTEGER PRIMARY KEY); "
 	//mandb_links
 	"CREATE TABLE IF NOT EXISTS mandb_links(link COLLATE NOCASE, target, section, "
-		"machine, md5_hash); ";
+		"machine, md5_hash, name_desc); ";
 
 	sqlite3_exec(db, sqlstr, NULL, NULL, );
 	if (errmsg != NULL)

Index: src/usr.sbin/makemandb/apropos-utils.h
diff -u src/usr.sbin/makemandb/apropos-utils.h:1.14 src/usr.sbin/makemandb/apropos-utils.h:1.15
--- src/usr.sbin/makemandb/apropos-utils.h:1.14	Sat Nov 25 14:29:38 2017
+++ src/usr.sbin/makemandb/apropos-utils.h	Sat May 18 07:56:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.h,v 1.14 2017/11/25 14:29:38 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.h,v 1.15 2019/05/18 07:56:43 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -45,7 +45,7 @@ typedef enum mandb_access_mode {
 } mandb_access_mode;
 
 
-#define APROPOS_SCHEMA_VERSION 20170618
+#define APROPOS_SCHEMA_VERSION 20190518
 
 /*
  * Used to identify the section of a man(7) page.

Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.59 src/usr.sbin/makemandb/makemandb.c:1.60
--- src/usr.sbin/makemandb/makemandb.c:1.59	Mon Mar 11 00:31:36 2019
+++ src/usr.sbin/makemandb/makemandb.c	Sat May 18 07:56:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.59 2019/03/11 00:31:36 christos Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.60 2019/05/18 07:56:43 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.59 2019/03/11 00:31:36 christos Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.60 2019/05/18 07:56:43 abhinav Exp $");
 
 #include 
 #include 
@@ -1767,9 +1767,9 @@ insert_into_db(sqlite3 *db, mandb_rec *r
 ln[strlen(ln) - 1] = 0;
 
 			str = sqlite3_mprintf("INSERT INTO mandb_links"
-	  " VALUES (%Q, %Q, %Q, %Q, %Q)",
+	  " VALUES (%Q, %Q, %Q, %Q, %Q, %Q)",
 	  ln, rec->name, rec->section,
-	  rec->machine, rec->md5_hash);
+	  rec->machine, rec->md5_hash, rec->name_desc);
 			sqlite3_exec(db, str, NULL, NULL, );
 			sqlite3_free(str);
 			if (errmsg != NULL) {

Index: src/usr.sbin/makemandb/whatis.c
diff -u src/usr.sbin/makemandb/whatis.c:1.7 src/usr.sbin/makemandb/whatis.c:1.8
--- src/usr.sbin/makemandb/whatis.c:1.7	Tue May 23 15:27:54 2017
+++ src/usr.sbin/makemandb/whatis.c	Sat May 18 07:56:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: whatis.c,v 1.7 2017/05/23 15:27:54 abhinav Exp $	*/
+/*	$NetBSD: whatis.c,v 1.8 2019/05/18 07:56:43 abhinav Exp $	*/
 /*-
  * Copyright (c) 2012 Joerg Sonnenberger 
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: whatis.c,v 1.7 2017/05/23 15:27:54 abhinav Exp $");
+__RCSID("$NetBSD: whatis.c,v 1.8 2019/05/18 07:56:43 abhinav Exp $");
 
 #include 
 #include 
@@ -48,24 +48,20 

CVS commit: src/usr.sbin/makemandb

2019-05-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat May 18 07:56:43 UTC 2019

Modified Files:
src/usr.sbin/makemandb: apropos-utils.c apropos-utils.h makemandb.c
whatis.c

Log Message:
PR misc/54213: Fix performance of whatis(1) when no matches are found

In revision 1.6 of whatis.c the query was modified to return matches for names 
found
in MLINKS of the man pages as well. However it was slow. The reason probably 
being that it
required a join. But more importantly the where condition on an FTS virtual 
table column
is very slow. To avoid the join and the expensive where condition on the 
virtual table,
add the name_desc column to the mandb_links table as well. This improves the 
performance
of whatis(1) to the original level at the expense of slight data duplication.

Bump the schema to force database rebuild to take account for the new column 
addition


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/makemandb/makemandb.c
cvs rdiff -u -r1.7 -r1.8 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.



Re: CVS commit: src/usr.sbin/makemandb

2018-08-16 Thread Robert Elz
Date:Thu, 16 Aug 2018 11:24:51 +0530
From:Abhinav Upadhyay 
Message-ID:  


  | I will have a look at makemandb tonight
  | (Indian time). Usually every release mandoc's API has some small
  | changes and adjustments are needed in makemandb.

Great thanks,

It is not actually really proven yet that the build is fixed, though I have my
fingers crossed now... (I did a complete build, but just "build.sh build" not
"release").

makemandb from that appears to be working, though it says:

Performing index update
makemandb: Error in indexing `/usr/share/man/man7/mandoc_tbl.7'
makemandb: Error in indexing `/usr/share/man/man7/mandoc_roff.7'
makemandb: Error in indexing `/usr/share/man/man7/mandoc_mdoc.7'
makemandb: Error in indexing `/usr/share/man/man7/mandoc_man.7'
makemandb: Error in indexing `/usr/share/man/man7/mandoc_eqn.7'
makemandb: Error in indexing `/usr/share/man/man7/mandoc_char.7'
makemandb: Error in indexing `/usr/share/man/man4/tap.4'
makemandb: Error in indexing `/usr/share/man/man4/l2tp.4'
makemandb: Error in indexing `/usr/share/man/man4/gif.4'
makemandb: Error in indexing `/usr/share/man/man4/bridge.4'
makemandb: Error in indexing `/usr/share/man/man3/mandoc.3'
makemandb: Error in indexing `/usr/share/man/man3/libarchive_changes.3'
makemandb: Error in indexing `/usr/share/man/man3/getsubopt.3'
makemandb: Error in indexing `/usr/share/man/man1/mandoc.1'

Kind of interesting that (at least almost) all the mandoc man pages are
included...

kre



Re: CVS commit: src/usr.sbin/makemandb

2018-08-15 Thread Abhinav Upadhyay
On Thu, Aug 16, 2018 at 10:37 AM Robert Elz  wrote:
>
> Module Name:src
> Committed By:   kre
> Date:   Thu Aug 16 05:07:22 UTC 2018
>
> Modified Files:
> src/usr.sbin/makemandb: makemandb.c
>
> Log Message:
> In the latest mandoc (mdocml) the signature (prototype) of
> mparse_alloc() altered - update the call here to compensate.
>
> This fixes the build (of makemandb), but I am not sure that
> the changed version is what is desired - someone who knows
> something about all of this should validate ... I just copied
> the invocation from mandoc's demandoc.c (which seems likely
> to be at least a similar kind of usage).

Thanks for fixing the build. I will have a look at makemandb tonight
(Indian time). Usually every release mandoc's API has some small
changes and adjustments are needed in makemandb.

-
Abhinav