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

2020-11-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  9 10:19:41 UTC 2020

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

Log Message:
Fix copy in previous


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makemandb/Makefile

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

2020-11-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov  9 10:19:41 UTC 2020

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

Log Message:
Fix copy in previous


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makemandb/Makefile

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/Makefile
diff -u src/usr.sbin/makemandb/Makefile:1.10 src/usr.sbin/makemandb/Makefile:1.11
--- src/usr.sbin/makemandb/Makefile:1.10	Sun Nov  8 21:56:48 2020
+++ src/usr.sbin/makemandb/Makefile	Mon Nov  9 10:19:41 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2020/11/08 21:56:48 nia Exp $
+# $NetBSD: Makefile,v 1.11 2020/11/09 10:19:41 martin Exp $
 
 .include 
 
@@ -29,10 +29,8 @@ LDADD.makemandb+= 	-L${MDOCMLOBJDIR} -lm
 LDADD.makemandb+=	-lcrypto
 DPADD.makemandb+=	${LIBCRYPTO}
 
-DPADD+=		${LIBSQLITE3} ${LIBM} ${LIBZ} ${LIBPTHREAD}
-LDADD+=		-lsqlite3 -lm -lz -lpthread
-DPADD+=		${LIBTERMLIB} ${LIBUTIL}
-DPADD+=		-ltermlib -lutil
+DPADD+=		${LIBSQLITE3} ${LIBM} ${LIBPTHREAD} ${LIBZ} ${LIBTERMLIB} ${LIBUTIL}
+LDADD+=		-lsqlite3 -lm -lz -ltermlib -lutil -lpthread
 
 stopwords.c: stopwords.txt
 	( set -e; ${TOOL_NBPERF} -n stopwords_hash -s -p ${.ALLSRC};	\



CVS commit: src/usr.sbin/makemandb

2020-06-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun  2 15:43:26 UTC 2020

Modified Files:
src/usr.sbin/makemandb: nostem.txt

Log Message:
Register ppoll


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

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/nostem.txt
diff -u src/usr.sbin/makemandb/nostem.txt:1.5 src/usr.sbin/makemandb/nostem.txt:1.6
--- src/usr.sbin/makemandb/nostem.txt:1.5	Fri Jan 17 15:00:21 2020
+++ src/usr.sbin/makemandb/nostem.txt	Tue Jun  2 15:43:26 2020
@@ -3036,6 +3036,7 @@ ppath
 ppb
 ppbus
 ppi
+ppoll
 ppp
 pppd
 pppdump



CVS commit: src/usr.sbin/makemandb

2020-06-02 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun  2 15:43:26 UTC 2020

Modified Files:
src/usr.sbin/makemandb: nostem.txt

Log Message:
Register ppoll


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

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.



CVS commit: src/usr.sbin/makemandb

2019-04-19 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Fri Apr 19 20:35:14 UTC 2019

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

Log Message:
Memory allocated by sqlite3_mprintf should be free'd by sqlite3_free

This was causing memory corruption thus making apropos(1) fail in some cases.
Specifically following options were broken and should be fixed with this commit:

-n option was causing a core dump
apropos was giving warning when using -l and any of the section numbers as 
options
as reported by paulg on current-users.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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-04-19 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Fri Apr 19 20:35:14 UTC 2019

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

Log Message:
Memory allocated by sqlite3_mprintf should be free'd by sqlite3_free

This was causing memory corruption thus making apropos(1) fail in some cases.
Specifically following options were broken and should be fixed with this commit:

-n option was causing a core dump
apropos was giving warning when using -l and any of the section numbers as 
options
as reported by paulg on current-users.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/usr.sbin/makemandb/apropos-utils.c:1.43
--- src/usr.sbin/makemandb/apropos-utils.c:1.42	Sun Apr 14 07:59:56 2019
+++ src/usr.sbin/makemandb/apropos-utils.c	Fri Apr 19 20:35:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.42 2019/04/14 07:59:56 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.43 2019/04/19 20:35:13 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.42 2019/04/14 07:59:56 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.43 2019/04/19 20:35:13 abhinav Exp $");
 
 #include 
 #include 
@@ -580,7 +580,7 @@ generate_search_query(query_args *args, 
 			if ((temp = sqlite3_mprintf("%Q%c", args->sections[i], c)) == NULL)
 goto RETURN;
 			concat(_clause, temp);
-			free(temp);
+			sqlite3_free(temp);
 		}
 	}
 
@@ -648,9 +648,9 @@ generate_search_query(query_args *args, 
 	}
 
 RETURN:
-	free(machine_clause);
-	free(section_clause);
-	free(limit_clause);
+	sqlite3_free(machine_clause);
+	sqlite3_free(section_clause);
+	sqlite3_free(limit_clause);
 	return query;
 }
 



CVS commit: src/usr.sbin/makemandb

2019-04-14 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 14 07:59:56 UTC 2019

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

Log Message:
Set the snippet_length field of the callback_args

Because of this field not being set, apropos was failing to show snippet when 
piped to a pager
or when used with -p argument.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/usr.sbin/makemandb/apropos-utils.c:1.42
--- src/usr.sbin/makemandb/apropos-utils.c:1.41	Thu Mar  7 22:08:59 2019
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Apr 14 07:59:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.41 2019/03/07 22:08:59 christos Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.42 2019/04/14 07:59:56 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.41 2019/03/07 22:08:59 christos Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.42 2019/04/14 07:59:56 abhinav Exp $");
 
 #include 
 #include 
@@ -699,10 +699,13 @@ execute_search_query(sqlite3 *db, char *
 		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);
-		if (!args->legacy)
+		if (!args->legacy) {
 			callback_args.snippet = (const char *) sqlite3_column_text(stmt, 4);
-		else
+			callback_args.snippet_length = strlen(callback_args.snippet);
+		} else {
 			callback_args.snippet = "";
+			callback_args.snippet_length = 1;
+		}
 		if ((slash_ptr = strrchr(name_temp, '/')) != NULL)
 			name_temp = slash_ptr + 1;
 		if (callback_args.machine && callback_args.machine[0]) {



CVS commit: src/usr.sbin/makemandb

2019-04-14 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 14 07:59:56 UTC 2019

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

Log Message:
Set the snippet_length field of the callback_args

Because of this field not being set, apropos was failing to show snippet when 
piped to a pager
or when used with -p argument.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 11 00:31:36 UTC 2019

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

Log Message:
remove unneeded header.


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

2019-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 11 00:31:36 UTC 2019

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

Log Message:
remove unneeded header.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 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.58 src/usr.sbin/makemandb/makemandb.c:1.59
--- src/usr.sbin/makemandb/makemandb.c:1.58	Sun Mar 10 20:14:44 2019
+++ src/usr.sbin/makemandb/makemandb.c	Sun Mar 10 20:31:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.58 2019/03/11 00:14:44 christos Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.59 2019/03/11 00:31:36 christos Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.58 2019/03/11 00:14:44 christos Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.59 2019/03/11 00:31:36 christos Exp $");
 
 #include 
 #include 
@@ -39,7 +39,6 @@ __RCSID("$NetBSD: makemandb.c,v 1.58 201
 #include "dist/mandoc.h"
 #include "dist/mdoc.h"
 #include "dist/roff.h"
-#include "dist/roff_int.h"
 #include "dist/mandoc_parse.h"
 
 #define BUFLEN 1024



CVS commit: src/usr.sbin/makemandb

2019-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 11 00:14:44 UTC 2019

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

Log Message:
adjust to the new mandoc api


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

2019-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar 11 00:14:44 UTC 2019

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

Log Message:
adjust to the new mandoc api


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.57 src/usr.sbin/makemandb/makemandb.c:1.58
--- src/usr.sbin/makemandb/makemandb.c:1.57	Fri Aug 24 12:01:57 2018
+++ src/usr.sbin/makemandb/makemandb.c	Sun Mar 10 20:14:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.57 2018/08/24 16:01:57 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.58 2019/03/11 00:14:44 christos Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.57 2018/08/24 16:01:57 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.58 2019/03/11 00:14:44 christos Exp $");
 
 #include 
 #include 
@@ -39,6 +39,8 @@ __RCSID("$NetBSD: makemandb.c,v 1.57 201
 #include "dist/mandoc.h"
 #include "dist/mdoc.h"
 #include "dist/roff.h"
+#include "dist/roff_int.h"
+#include "dist/mandoc_parse.h"
 
 #define BUFLEN 1024
 #define MDOC 0	//If the page is of mdoc(7) type
@@ -98,13 +100,12 @@ static void init_secbuffs(mandb_rec *);
 static void free_secbuffs(mandb_rec *);
 static int check_md5(const char *, sqlite3 *, char **, void *, size_t);
 static void cleanup(mandb_rec *);
-static void set_section(const struct roff_man *, mandb_rec *);
-static void set_machine(const struct roff_man *, mandb_rec *);
+static void set_section(const struct roff_meta *, mandb_rec *);
+static void set_machine(const struct roff_meta *, mandb_rec *);
 static int insert_into_db(sqlite3 *, mandb_rec *);
-static	void begin_parse(const char *, struct mparse *, mandb_rec *,
-			 const void *, size_t len);
-static void proff_node(const struct roff_node *, mandb_rec *, struct roff_man *,
-		 const proff_nf *);
+static	void begin_parse(const char *, struct mparse *, mandb_rec *, int);
+static void proff_node(const struct roff_node *, mandb_rec *,
+		   struct roff_meta *, const proff_nf *);
 static void pmdoc_Nm(const struct roff_node *, mandb_rec *);
 static void pmdoc_Nd(const struct roff_node *, mandb_rec *);
 static void pmdoc_Sh(const struct roff_node *, mandb_rec *);
@@ -336,7 +337,8 @@ main(int argc, char *argv[])
 
 	init_secbuffs();
 	mchars_alloc();
-	mp = mparse_alloc(0, MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, NULL);
+	mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 |
+	MPARSE_VALIDATE, MANDOC_OS_OTHER, NULL);
 
 	if (manconf) {
 		char *arg;
@@ -579,62 +581,6 @@ build_file_cache(sqlite3 *db, const char
 	sqlite3_finalize(stmt);
 }
 
-static void
-update_existing_entry(sqlite3 *db, const char *file, const char *hash,
-mandb_rec *rec, int *new_count, int *link_count, int *err_count)
-{
-	int update_count, rc, idx;
-	const char *inner_sqlstr;
-	sqlite3_stmt *inner_stmt;
-
-	update_count = sqlite3_total_changes(db);
-	inner_sqlstr = "UPDATE mandb_meta SET device = :device,"
-		   " inode = :inode, mtime = :mtime WHERE"
-		   " md5_hash = :md5 AND file = :file AND"
-		   " (device <> :device2 OR inode <> "
-		   "  :inode2 OR mtime <> :mtime2)";
-	rc = sqlite3_prepare_v2(db, inner_sqlstr, -1, _stmt, NULL);
-	if (rc != SQLITE_OK) {
-		if (mflags.verbosity)
-			warnx("%s", sqlite3_errmsg(db));
-		return;
-	}
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":device");
-	sqlite3_bind_int64(inner_stmt, idx, rec->device);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":inode");
-	sqlite3_bind_int64(inner_stmt, idx, rec->inode);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":mtime");
-	sqlite3_bind_int64(inner_stmt, idx, rec->mtime);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":md5");
-	sqlite3_bind_text(inner_stmt, idx, hash, -1, NULL);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":file");
-	sqlite3_bind_text(inner_stmt, idx, file, -1, NULL);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":device2");
-	sqlite3_bind_int64(inner_stmt, idx, rec->device);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":inode2");
-	sqlite3_bind_int64(inner_stmt, idx, rec->inode);
-	idx = sqlite3_bind_parameter_index(inner_stmt, ":mtime2");
-	sqlite3_bind_int64(inner_stmt, idx, rec->mtime);
-
-	rc = sqlite3_step(inner_stmt);
-	if (rc == SQLITE_DONE) {
-		/* Check if an update has been performed. */
-		if (update_count != sqlite3_total_changes(db)) {
-			if (mflags.verbosity == 2)
-printf("Updated %s\n", file);
-			(*new_count)++;
-		} else {
-			/* Otherwise it was a hardlink. */
-			(*link_count)++;
-		}
-	} else {
-		if (mflags.verbosity == 2)
-			warnx("Could not update the meta data for %s", file);
-		(*err_count)++;
-	}
-	sqlite3_finalize(inner_stmt);
-}
-
 /* 

CVS commit: src/usr.sbin/makemandb

2019-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar  7 22:08:59 UTC 2019

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

Log Message:
fix memory allocation problems detected by jemalloc...


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/usr.sbin/makemandb/apropos-utils.c:1.41
--- src/usr.sbin/makemandb/apropos-utils.c:1.40	Sat Nov 25 09:29:38 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Thu Mar  7 17:08:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.40 2017/11/25 14:29:38 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.41 2019/03/07 22:08:59 christos Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.40 2017/11/25 14:29:38 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.41 2019/03/07 22:08:59 christos Exp $");
 
 #include 
 #include 
@@ -270,34 +270,40 @@ unzip(sqlite3_context *pctx, int nval, s
 	unsigned int rc;
 	unsigned char *outbuf;
 	z_stream stream;
+	long total_out;
 
 	assert(nval == 1);
+	memset(, 0, sizeof(stream));
 	stream.next_in = __UNCONST(sqlite3_value_blob(apval[0]));
 	stream.avail_in = sqlite3_value_bytes(apval[0]);
-	stream.avail_out = stream.avail_in * 2 + 100;
-	stream.next_out = outbuf = emalloc(stream.avail_out);
 	stream.zalloc = NULL;
 	stream.zfree = NULL;
 
 	if (inflateInit() != Z_OK) {
-		free(outbuf);
 		return;
 	}
 
+	total_out = stream.avail_out = stream.avail_in * 2 + 100;
+	stream.next_out = outbuf = emalloc(stream.avail_out);
 	while ((rc = inflate(, Z_SYNC_FLUSH)) != Z_STREAM_END) {
 		if (rc != Z_OK ||
 		(stream.avail_out != 0 && stream.avail_in == 0)) {
 			free(outbuf);
 			return;
 		}
-		outbuf = erealloc(outbuf, stream.total_out * 2);
+		total_out <<= 1;
+		outbuf = erealloc(outbuf, total_out);
 		stream.next_out = outbuf + stream.total_out;
-		stream.avail_out = stream.total_out;
+		stream.avail_out = total_out - stream.total_out;
 	}
 	if (inflateEnd() != Z_OK) {
 		free(outbuf);
 		return;
 	}
+	if (stream.total_out == 0) {
+		free(outbuf);
+		return;
+	}
 	outbuf = erealloc(outbuf, stream.total_out);
 	sqlite3_result_text(pctx, (const char *)outbuf, stream.total_out, free);
 }



CVS commit: src/usr.sbin/makemandb

2019-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Mar  7 22:08:59 UTC 2019

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

Log Message:
fix memory allocation problems detected by jemalloc...


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

2018-08-24 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Fri Aug 24 16:01:57 UTC 2018

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

Log Message:
Adjust makemandb for the latest mandoc

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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.56 src/usr.sbin/makemandb/makemandb.c:1.57
--- src/usr.sbin/makemandb/makemandb.c:1.56	Thu Aug 16 05:07:22 2018
+++ src/usr.sbin/makemandb/makemandb.c	Fri Aug 24 16:01:57 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.56 2018/08/16 05:07:22 kre Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.57 2018/08/24 16:01:57 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.56 2018/08/16 05:07:22 kre Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.57 2018/08/24 16:01:57 abhinav Exp $");
 
 #include 
 #include 
@@ -103,7 +103,8 @@ static void set_machine(const struct rof
 static int insert_into_db(sqlite3 *, mandb_rec *);
 static	void begin_parse(const char *, struct mparse *, mandb_rec *,
 			 const void *, size_t len);
-static void proff_node(const struct roff_node *, mandb_rec *, const proff_nf *);
+static void proff_node(const struct roff_node *, mandb_rec *, struct roff_man *,
+		 const proff_nf *);
 static void pmdoc_Nm(const struct roff_node *, mandb_rec *);
 static void pmdoc_Nd(const struct roff_node *, mandb_rec *);
 static void pmdoc_Sh(const struct roff_node *, mandb_rec *);
@@ -127,165 +128,130 @@ static char *parse_escape(const char *);
 static void replace_hyph(char *);
 static makemandb_flags mflags = { .verbosity = 1 };
 
-static	const proff_nf mdocs[MDOC_MAX + 1] = {
-	NULL, /* Ap */
+static	const proff_nf mdocs[MDOC_MAX - MDOC_Dd] = {
 	NULL, /* Dd */
 	NULL, /* Dt */
 	NULL, /* Os */
-
 	pmdoc_Sh, /* Sh */
 	NULL, /* Ss */
 	pmdoc_Pp, /* Pp */
 	NULL, /* D1 */
-
 	NULL, /* Dl */
 	NULL, /* Bd */
 	NULL, /* Ed */
 	NULL, /* Bl */
-
 	NULL, /* El */
 	NULL, /* It */
 	NULL, /* Ad */
 	NULL, /* An */
-
+	NULL, /* Ap */
 	NULL, /* Ar */
 	NULL, /* Cd */
 	NULL, /* Cm */
 	NULL, /* Dv */
-
 	NULL, /* Er */
 	NULL, /* Ev */
 	NULL, /* Ex */
 	NULL, /* Fa */
-
 	NULL, /* Fd */
 	NULL, /* Fl */
 	NULL, /* Fn */
 	NULL, /* Ft */
-
 	NULL, /* Ic */
 	NULL, /* In */
 	NULL, /* Li */
 	pmdoc_Nd, /* Nd */
-
 	pmdoc_Nm, /* Nm */
 	NULL, /* Op */
 	NULL, /* Ot */
 	NULL, /* Pa */
-
 	NULL, /* Rv */
 	NULL, /* St */
 	NULL, /* Va */
 	NULL, /* Vt */
-
 	pmdoc_Xr, /* Xr */
 	NULL, /* %A */
 	NULL, /* %B */
 	NULL, /* %D */
-
 	NULL, /* %I */
 	NULL, /* %J */
 	NULL, /* %N */
 	NULL, /* %O */
-
 	NULL, /* %P */
 	NULL, /* %R */
 	NULL, /* %T */
 	NULL, /* %V */
-
 	NULL, /* Ac */
 	NULL, /* Ao */
 	NULL, /* Aq */
 	NULL, /* At */
-
 	NULL, /* Bc */
 	NULL, /* Bf */
 	NULL, /* Bo */
 	NULL, /* Bq */
-
 	NULL, /* Bsx */
 	NULL, /* Bx */
 	NULL, /* Db */
 	NULL, /* Dc */
-
 	NULL, /* Do */
 	NULL, /* Dq */
 	NULL, /* Ec */
 	NULL, /* Ef */
-
 	NULL, /* Em */
 	NULL, /* Eo */
 	NULL, /* Fx */
 	NULL, /* Ms */
-
 	NULL, /* No */
 	NULL, /* Ns */
 	NULL, /* Nx */
 	NULL, /* Ox */
-
 	NULL, /* Pc */
 	NULL, /* Pf */
 	NULL, /* Po */
 	NULL, /* Pq */
-
 	NULL, /* Qc */
 	NULL, /* Ql */
 	NULL, /* Qo */
 	NULL, /* Qq */
-
 	NULL, /* Re */
 	NULL, /* Rs */
 	NULL, /* Sc */
 	NULL, /* So */
-
 	NULL, /* Sq */
 	NULL, /* Sm */
 	NULL, /* Sx */
 	NULL, /* Sy */
-
 	NULL, /* Tn */
 	NULL, /* Ux */
 	NULL, /* Xc */
 	NULL, /* Xo */
-
 	NULL, /* Fo */
 	NULL, /* Fc */
 	NULL, /* Oo */
 	NULL, /* Oc */
-
 	NULL, /* Bk */
 	NULL, /* Ek */
 	NULL, /* Bt */
 	NULL, /* Hf */
-
 	NULL, /* Fr */
 	NULL, /* Ud */
 	NULL, /* Lb */
 	NULL, /* Lp */
-
 	NULL, /* Lk */
 	NULL, /* Mt */
 	NULL, /* Brq */
 	NULL, /* Bro */
-
 	NULL, /* Brc */
 	NULL, /* %C */
 	NULL, /* Es */
 	NULL, /* En */
-
 	NULL, /* Dx */
 	NULL, /* %Q */
-	NULL, /* br */
-	NULL, /* sp */
-
 	NULL, /* %U */
-	NULL, /* Ta */
-	NULL, /* ll */
-	NULL, /* text */
+	NULL /* Ta */
 };
 
-static	const proff_nf mans[MAN_MAX] = {
-	NULL,	//br
+static	const proff_nf mans[MAN_MAX - MAN_TH] = {
 	NULL,	//TH
 	pman_sh, //SH
 	NULL,	//SS
@@ -306,7 +272,6 @@ static	const proff_nf mans[MAN_MAX] = {
 	NULL,	//I
 	NULL,	//IR
 	NULL,	//RI
-	NULL,	//sp
 	NULL,	//nf
 	NULL,	//fi
 	NULL,	//RE
@@ -316,16 +281,15 @@ static	const proff_nf mans[MAN_MAX] = {
 	NULL,	//PD
 	NULL,	//AT
 	NULL,	//in
-	NULL,	//ft
 	NULL,	//OP
 	NULL,	//EX
 	NULL,	//EE
 	NULL,	//UR
 	NULL,	//UE
-	NULL,	//ll
+	NULL,	//MT
+	NULL   //ME
 };
 
-
 int
 main(int argc, char *argv[])
 {
@@ -923,11 +887,11 @@ begin_parse(const char *file, struct mpa
 	if (roff->macroset == MACROSET_MDOC) {
 		mdoc_validate(roff);
 		rec->page_type = MDOC;
-		proff_node(roff->first->child, rec, mdocs);
+		

CVS commit: src/usr.sbin/makemandb

2018-08-24 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Fri Aug 24 16:01:57 UTC 2018

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

Log Message:
Adjust makemandb for the latest mandoc

ok christos@


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



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-16 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


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


CVS commit: src/usr.sbin/makemandb

2018-08-15 Thread Robert Elz
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).


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

2018-08-15 Thread Robert Elz
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).


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.55 src/usr.sbin/makemandb/makemandb.c:1.56
--- src/usr.sbin/makemandb/makemandb.c:1.55	Wed May 10 12:09:52 2017
+++ src/usr.sbin/makemandb/makemandb.c	Thu Aug 16 05:07:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.55 2017/05/10 12:09:52 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.56 2018/08/16 05:07:22 kre Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.55 2017/05/10 12:09:52 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.56 2018/08/16 05:07:22 kre Exp $");
 
 #include 
 #include 
@@ -372,7 +372,7 @@ main(int argc, char *argv[])
 
 	init_secbuffs();
 	mchars_alloc();
-	mp = mparse_alloc(0, MANDOCLEVEL_BADARG, NULL, NULL);
+	mp = mparse_alloc(0, MANDOCERR_MAX, NULL, MANDOC_OS_OTHER, NULL);
 
 	if (manconf) {
 		char *arg;



CVS commit: src/usr.sbin/makemandb

2017-11-25 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat Nov 25 14:29:38 UTC 2017

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

Log Message:
Encapsulate all the arguments required by the query callback function in a 
struct.

If we want to add or remove arguments from the callback functions, it requires
changing the callback interface all over the place. By letting the callback 
simply
expect a single struct argument, it would clean things up a bit.

ok christos


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.23 -r1.24 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.39 src/usr.sbin/makemandb/apropos-utils.c:1.40
--- src/usr.sbin/makemandb/apropos-utils.c:1.39	Tue Aug  1 16:16:32 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Sat Nov 25 14:29:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.39 2017/08/01 16:16:32 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.40 2017/11/25 14:29:38 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.39 2017/08/01 16:16:32 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.40 2017/11/25 14:29:38 abhinav Exp $");
 
 #include 
 #include 
@@ -56,8 +56,7 @@ __RCSID("$NetBSD: apropos-utils.c,v 1.39
 
 typedef struct orig_callback_data {
 	void *data;
-	int (*callback) (void *, const char *, const char *, const char *,
-		const char *, size_t);
+	int (*callback) (query_callback_args*);
 } orig_callback_data;
 
 typedef struct inverse_document_frequency {
@@ -657,15 +656,12 @@ static unsigned int
 execute_search_query(sqlite3 *db, char *query, query_args *args)
 {
 	sqlite3_stmt *stmt;
-	const char *section;
 	char *name;
 	char *slash_ptr;
-	const char *name_desc;
-	const char *machine;
-	const char *snippet = "";
 	const char *name_temp;
 	char *m = NULL;
 	int rc;
+	query_callback_args callback_args;
 	inverse_document_frequency idf = {0, 0};
 
 	if (!args->legacy) {
@@ -693,25 +689,27 @@ execute_search_query(sqlite3 *db, char *
 	unsigned int nresults = 0;
 	while (sqlite3_step(stmt) == SQLITE_ROW) {
 		nresults++;
-		section = (const char *) sqlite3_column_text(stmt, 0);
+		callback_args.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);
+		callback_args.name_desc = (const char *) sqlite3_column_text(stmt, 2);
+		callback_args.machine = (const char *) sqlite3_column_text(stmt, 3);
 		if (!args->legacy)
-			snippet = (const char *) sqlite3_column_text(stmt, 4);
+			callback_args.snippet = (const char *) sqlite3_column_text(stmt, 4);
+		else
+			callback_args.snippet = "";
 		if ((slash_ptr = strrchr(name_temp, '/')) != NULL)
 			name_temp = slash_ptr + 1;
-		if (machine && machine[0]) {
-			m = estrdup(machine);
+		if (callback_args.machine && callback_args.machine[0]) {
+			m = estrdup(callback_args.machine);
 			easprintf(, "%s/%s", lower(m), name_temp);
 			free(m);
 		} else {
 			name = estrdup((const char *)
 			sqlite3_column_text(stmt, 1));
 		}
-
-		(args->callback)(args->callback_data, section, name,
-		name_desc, snippet, args->legacy? 0: strlen(snippet));
+		callback_args.name = name;
+		callback_args.other_data = args->callback_data;
+		(args->callback)(_args);
 		free(name);
 	}
 	sqlite3_finalize(stmt);
@@ -818,20 +816,20 @@ get_escaped_html_string(const char *src,
  *  calls the actual user supplied callback function.
  */
 static int
-callback_html(void *data, const char *section, const char *name,
-const char *name_desc, const char *snippet, size_t snippet_length)
+callback_html(query_callback_args *callback_args)
 {
-	struct orig_callback_data *orig_data = data;
-	int (*callback)(void *, const char *, const char *, const char *,
-	const char *, size_t) = orig_data->callback;
-	size_t length = snippet_length;
-	size_t name_description_length = strlen(name_desc);
-	char *qsnippet = get_escaped_html_string(snippet, );
-	char *qname_description = get_escaped_html_string(name_desc,
+	struct orig_callback_data *orig_data = callback_args->other_data;
+	int (*callback)(query_callback_args*) = orig_data->callback;
+	size_t length = callback_args->snippet_length;
+	size_t name_description_length = strlen(callback_args->name_desc);
+	char *qsnippet = get_escaped_html_string(callback_args->snippet, );
+	char *qname_description = get_escaped_html_string(callback_args->name_desc,
 	_description_length);
-
-	

CVS commit: src/usr.sbin/makemandb

2017-11-25 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat Nov 25 14:29:38 UTC 2017

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

Log Message:
Encapsulate all the arguments required by the query callback function in a 
struct.

If we want to add or remove arguments from the callback functions, it requires
changing the callback interface all over the place. By letting the callback 
simply
expect a single struct argument, it would clean things up a bit.

ok christos


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.23 -r1.24 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

2017-10-31 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Oct 31 10:14:27 UTC 2017

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

Log Message:
Casting variable of type int *  to size_t *, may cause
alignment issues on some platforms (e.g. Sparc64)
So, Use a temporary variable to avoid the cast.

Thanks to Martin@ for noticing the issue and also suggesting the issue.
Fixes PR bin/52678


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

2017-10-31 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Oct 31 10:14:27 UTC 2017

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

Log Message:
Casting variable of type int *  to size_t *, may cause
alignment issues on some platforms (e.g. Sparc64)
So, Use a temporary variable to avoid the cast.

Thanks to Martin@ for noticing the issue and also suggesting the issue.
Fixes PR bin/52678


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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.1 src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.2
--- src/usr.sbin/makemandb/custom_apropos_tokenizer.c:1.1	Sun Jun 18 16:24:10 2017
+++ src/usr.sbin/makemandb/custom_apropos_tokenizer.c	Tue Oct 31 10:14:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: custom_apropos_tokenizer.c,v 1.1 2017/06/18 16:24:10 abhinav Exp $	*/
+/*	$NetBSD: custom_apropos_tokenizer.c,v 1.2 2017/10/31 10:14:27 abhinav Exp $	*/
 /*
 ** 2006 September 30
 **
@@ -716,7 +716,10 @@ aproposPorterNext(
 	return SQLITE_NOMEM;
 c->zToken = pNew;
 			}
-			int stemStatus = do_stem([iStartOffset], n, c->zToken, (size_t *) pnBytes);
+			
+			size_t temp; 
+			int stemStatus = do_stem([iStartOffset], n, c->zToken, );
+			*pnBytes = temp;
 			if (stemStatus != SQLITE_OK)
 return stemStatus;
 



CVS commit: src/usr.sbin/makemandb

2017-08-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug  2 12:52:19 UTC 2017

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

Log Message:
Make the 'no results found' message sound less harsh.

Changes "try using better keywords" to "try using different keywords".


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

2017-08-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug  2 12:52:19 UTC 2017

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

Log Message:
Make the 'no results found' message sound less harsh.

Changes "try using better keywords" to "try using different keywords".


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 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.22 src/usr.sbin/makemandb/apropos.c:1.23
--- src/usr.sbin/makemandb/apropos.c:1.22	Mon May  1 05:28:00 2017
+++ src/usr.sbin/makemandb/apropos.c	Wed Aug  2 12:52:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.22 2017/05/01 05:28:00 abhinav Exp $	*/
+/*	$NetBSD: apropos.c,v 1.23 2017/08/02 12:52:18 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos.c,v 1.22 2017/05/01 05:28:00 abhinav Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.23 2017/08/02 12:52:18 jmcneill Exp $");
 
 #include 
 #include 
@@ -273,7 +273,7 @@ main(int argc, char *argv[])
 	if (cbdata.count == 0) {
 		warnx("No relevant results obtained.\n"
 		"Please make sure that you spelled all the terms correctly "
-		"or try using better keywords.");
+		"or try using different keywords.");
 	}
 	return 0;
 }



CVS commit: src/usr.sbin/makemandb

2017-08-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Aug  1 16:16:32 UTC 2017

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

Log Message:
Don't use the custom tokenizer when compiled with debugging on

Using the custom tokenizer means one cannot interactively query the database
through the SQLite shell, thus thwarting the purpose of the debug build option.

Thanks to leot@ for reporting it.

(While there change the debug macro from DEBUG to APROPOS_DEBUG)


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/usr.sbin/makemandb/apropos-utils.c:1.39
--- src/usr.sbin/makemandb/apropos-utils.c:1.38	Sun Jun 18 16:24:10 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Tue Aug  1 16:16:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.38 2017/06/18 16:24:10 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.39 2017/08/01 16:16:32 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.38 2017/06/18 16:24:10 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.39 2017/08/01 16:16:32 abhinav Exp $");
 
 #include 
 #include 
@@ -81,6 +81,7 @@ static const double col_weights[] = {
 	1.00	//machine
 };
 
+#ifndef APROPOS_DEBUG
 static int
 register_tokenizer(sqlite3 *db)
 {
@@ -102,6 +103,7 @@ register_tokenizer(sqlite3 *db)
 
 	return sqlite3_finalize(stmt);
 }
+#endif
 
 /*
  * lower --
@@ -201,10 +203,12 @@ 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 DEBUG		
-		"compress=zip, uncompress=unzip, "
+#ifndef APROPOS_DEBUG		
+		"compress=zip, uncompress=unzip, tokenize=custom_apropos_tokenizer, "
+#else
+		"tokenize=porter, "
 #endif		
-		"tokenize=custom_apropos_tokenizer, notindexed=section, notindexed=md5_hash); "
+		"notindexed=section, notindexed=md5_hash); "
 	//mandb_meta
 	"CREATE TABLE IF NOT EXISTS mandb_meta(device, inode, mtime, "
 		"file UNIQUE, md5_hash UNIQUE, id  INTEGER PRIMARY KEY); "
@@ -391,11 +395,13 @@ init_db(mandb_access_mode db_flag, const
 
 	sqlite3_extended_result_codes(db, 1);
 
+#ifndef APROPOS_DEBUG
 	rc = register_tokenizer(db);
 	if (rc != SQLITE_OK) {
 		warnx("Unable to register custom tokenizer: %s", sqlite3_errmsg(db));
 		goto error;
 	}
+#endif
 
 	if (create_db_flag && create_db(db) < 0) {
 		warnx("%s", "Unable to create database schema");



CVS commit: src/usr.sbin/makemandb

2017-08-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue Aug  1 16:16:32 UTC 2017

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

Log Message:
Don't use the custom tokenizer when compiled with debugging on

Using the custom tokenizer means one cannot interactively query the database
through the SQLite shell, thus thwarting the purpose of the debug build option.

Thanks to leot@ for reporting it.

(While there change the debug macro from DEBUG to APROPOS_DEBUG)


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

2017-06-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Jun 18 16:24:10 UTC 2017

Modified Files:
src/usr.sbin/makemandb: Makefile apropos-utils.c apropos-utils.h
Added Files:
src/usr.sbin/makemandb: custom_apropos_tokenizer.c
custom_apropos_tokenizer.h fts3_tokenizer.h nostem.txt

Log Message:
Add a custom tokenizer which does not stem certain keywords.

Which keywords should not be stemmed is specified in the nostem.txt file.
(Right now I have taken all the man page names, split them if they had
underscores, removed common English words and converted everything to
lowercase.)

The tokenizer itself is based on the Porter stemming tokenizer shipped with
Sqlite. The code in custom_apropos_tokenizer.c is copy of that code with
some modifications to prevent stemming keywords specified in nostem.txt.

Additionally, it now uses underscore `_' also as a token delimiter. Therefore,
now it's possible to do query for `lwp' and all `_lwp_*' man page names
will be matched. Or the query can be `unconst' and `__UNCONST' will be matched.
This was not possible earlier, because underscore was not a delimiter and 
therefore
the index would have __UNCONST as a key rather than UNCONST.

The tokenizer needs fts3_tokenizer.h file, which is not shipped with the
amalgamation build of Sqlite, therefore it needs to be added here (unless
we decide there is a better place for it).

To enforce using the new tokenizer, a schema version bump is needed

Since the tokenization is done both at the indexing time (via makemandb) and
also while query time (via apropos or whatis), it will be needed to bump
the schema version everytime nostem.txt is modified. Otherwise the
index will consist of old tokens and desired changes will not be seen with
apropos.

This should also fix the issue reported in PR bin/46255. Similar suggestion was
also made on tech-userlevel@ recently:


Thanks to christos@ for multiple rounds of reviews of the tokenizer code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makemandb/Makefile
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makemandb/custom_apropos_tokenizer.c \
src/usr.sbin/makemandb/custom_apropos_tokenizer.h \
src/usr.sbin/makemandb/fts3_tokenizer.h src/usr.sbin/makemandb/nostem.txt

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/Makefile
diff -u src/usr.sbin/makemandb/Makefile:1.8 src/usr.sbin/makemandb/Makefile:1.9
--- src/usr.sbin/makemandb/Makefile:1.8	Sun May 21 15:28:43 2017
+++ src/usr.sbin/makemandb/Makefile	Sun Jun 18 16:24:10 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2017/05/21 15:28:43 riastradh Exp $
+# $NetBSD: Makefile,v 1.9 2017/06/18 16:24:10 abhinav Exp $
 
 .include 
 
@@ -6,9 +6,9 @@ MDOCDIR=${NETBSDSRCDIR}/external/bsd/mdo
 MANCONFDIR=${NETBSDSRCDIR}/usr.bin/man
 
 PROGS=			makemandb apropos whatis
-SRCS.makemandb=		makemandb.c apropos-utils.c manconf.c
-SRCS.apropos=	apropos.c apropos-utils.c manconf.c
-SRCS.whatis=	whatis.c apropos-utils.c manconf.c
+SRCS.makemandb=		makemandb.c apropos-utils.c manconf.c custom_apropos_tokenizer.c
+SRCS.apropos=	apropos.c apropos-utils.c manconf.c custom_apropos_tokenizer.c
+SRCS.whatis=	whatis.c apropos-utils.c manconf.c custom_apropos_tokenizer.c
 MAN.makemandb=	makemandb.8
 MAN.apropos=	apropos.1
 MAN.whatis=	whatis.1
@@ -39,7 +39,14 @@ stopwords.c: stopwords.txt
 	echo '};'			\
 	) > ${.TARGET}
 
-DPSRCS+=	stopwords.c
-CLEANFILES+=	stopwords.c
+nostem.c: nostem.txt
+	( set -e; ${TOOL_NBPERF} -n nostem_hash -s -p ${.ALLSRC};	\
+	echo 'static const char *nostem[] = {';			\
+	${TOOL_SED} -e 's|^\(.*\)$$|	"\1",|' ${.ALLSRC};		\
+	echo '};'			\
+	) > ${.TARGET}
+
+DPSRCS+=	stopwords.c nostem.c
+CLEANFILES+=	stopwords.c nostem.c
 
 .include 

Index: src/usr.sbin/makemandb/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.37 src/usr.sbin/makemandb/apropos-utils.c:1.38
--- src/usr.sbin/makemandb/apropos-utils.c:1.37	Mon May  1 05:28:00 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Jun 18 16:24:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.37 2017/05/01 05:28:00 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.38 2017/06/18 16:24:10 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.37 2017/05/01 05:28:00 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.38 2017/06/18 16:24:10 abhinav Exp $");
 
 #include 
 #include 
@@ -50,7 +50,9 @@ __RCSID("$NetBSD: apropos-utils.c,v 1.37
 #undef tab	// XXX: manconf.h
 
 #include "apropos-utils.h"
+#include "custom_apropos_tokenizer.h"
 #include "manconf.h"

CVS commit: src/usr.sbin/makemandb

2017-06-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Jun 18 16:24:10 UTC 2017

Modified Files:
src/usr.sbin/makemandb: Makefile apropos-utils.c apropos-utils.h
Added Files:
src/usr.sbin/makemandb: custom_apropos_tokenizer.c
custom_apropos_tokenizer.h fts3_tokenizer.h nostem.txt

Log Message:
Add a custom tokenizer which does not stem certain keywords.

Which keywords should not be stemmed is specified in the nostem.txt file.
(Right now I have taken all the man page names, split them if they had
underscores, removed common English words and converted everything to
lowercase.)

The tokenizer itself is based on the Porter stemming tokenizer shipped with
Sqlite. The code in custom_apropos_tokenizer.c is copy of that code with
some modifications to prevent stemming keywords specified in nostem.txt.

Additionally, it now uses underscore `_' also as a token delimiter. Therefore,
now it's possible to do query for `lwp' and all `_lwp_*' man page names
will be matched. Or the query can be `unconst' and `__UNCONST' will be matched.
This was not possible earlier, because underscore was not a delimiter and 
therefore
the index would have __UNCONST as a key rather than UNCONST.

The tokenizer needs fts3_tokenizer.h file, which is not shipped with the
amalgamation build of Sqlite, therefore it needs to be added here (unless
we decide there is a better place for it).

To enforce using the new tokenizer, a schema version bump is needed

Since the tokenization is done both at the indexing time (via makemandb) and
also while query time (via apropos or whatis), it will be needed to bump
the schema version everytime nostem.txt is modified. Otherwise the
index will consist of old tokens and desired changes will not be seen with
apropos.

This should also fix the issue reported in PR bin/46255. Similar suggestion was
also made on tech-userlevel@ recently:


Thanks to christos@ for multiple rounds of reviews of the tokenizer code.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makemandb/Makefile
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makemandb/custom_apropos_tokenizer.c \
src/usr.sbin/makemandb/custom_apropos_tokenizer.h \
src/usr.sbin/makemandb/fts3_tokenizer.h src/usr.sbin/makemandb/nostem.txt

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

2017-05-23 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue May 23 15:27:54 UTC 2017

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

Log Message:
Make the name comparison case insensitive.

(The old whatis(1) also used to do case insensitive string comparisons).


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/usr.sbin/makemandb/whatis.c:1.7
--- src/usr.sbin/makemandb/whatis.c:1.6	Sun Apr 23 16:56:49 2017
+++ src/usr.sbin/makemandb/whatis.c	Tue May 23 15:27:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: whatis.c,v 1.6 2017/04/23 16:56:49 abhinav Exp $	*/
+/*	$NetBSD: whatis.c,v 1.7 2017/05/23 15:27:54 abhinav Exp $	*/
 /*-
  * Copyright (c) 2012 Joerg Sonnenberger 
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: whatis.c,v 1.6 2017/04/23 16:56:49 abhinav Exp $");
+__RCSID("$NetBSD: whatis.c,v 1.7 2017/05/23 15:27:54 abhinav Exp $");
 
 #include 
 #include 
@@ -49,7 +49,7 @@ static int
 whatis(sqlite3 *db, const char *cmd)
 {
 	static const char sqlstr[] = "SELECT name, section, name_desc"
-		" FROM mandb WHERE name MATCH ? AND name=?"
+		" FROM mandb WHERE name MATCH ? AND name=? COLLATE NOCASE"
 		" UNION"
 		" SELECT b.link AS name, b.section, a.name_desc FROM mandb a"
 		" JOIN"



CVS commit: src/usr.sbin/makemandb

2017-05-23 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue May 23 15:27:54 UTC 2017

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

Log Message:
Make the name comparison case insensitive.

(The old whatis(1) also used to do case insensitive string comparisons).


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

2017-05-10 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed May 10 12:09:52 UTC 2017

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

Log Message:
Get rid of unnecessary variable.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 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.54 src/usr.sbin/makemandb/makemandb.c:1.55
--- src/usr.sbin/makemandb/makemandb.c:1.54	Tue May  2 13:54:08 2017
+++ src/usr.sbin/makemandb/makemandb.c	Wed May 10 12:09:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.54 2017/05/02 13:54:08 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.55 2017/05/10 12:09:52 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.54 2017/05/02 13:54:08 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.55 2017/05/10 12:09:52 abhinav Exp $");
 
 #include 
 #include 
@@ -944,8 +944,7 @@ set_section(const struct roff_man *rm, m
 {
 	if (!rm)
 		return;
-	const struct roff_meta *rm_meta = >meta;
-	const char *s = rm_meta->msec == NULL ? "?" : rm_meta->msec;
+	const char *s = rm->meta.msec == NULL ? "?" : rm->meta.msec;
 	easprintf(>section, "%s", s);
 	if (rec->section[0] == '?' && mflags.verbosity == 2)
 		warnx("%s: Missing section number", rec->file_path);
@@ -960,9 +959,8 @@ set_machine(const struct roff_man *rm, m
 {
 	if (rm == NULL)
 		return;
-	const struct roff_meta *rm_meta = >meta;
-	if (rm_meta->arch)
-		rec->machine = estrdup(rm_meta->arch);
+	if (rm->meta.arch)
+		rec->machine = estrdup(rm->meta.arch);
 }
 
 /*



CVS commit: src/usr.sbin/makemandb

2017-05-10 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed May 10 12:09:52 UTC 2017

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

Log Message:
Get rid of unnecessary variable.


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

2017-05-02 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue May  2 13:54:08 UTC 2017

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

Log Message:
We do need to copy the return value from dirname(3) since there it is a static
buffer and can be overwritten in between. I overzealously removed this in one
of my previous commits.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.53 src/usr.sbin/makemandb/makemandb.c:1.54
--- src/usr.sbin/makemandb/makemandb.c:1.53	Mon May  1 06:56:00 2017
+++ src/usr.sbin/makemandb/makemandb.c	Tue May  2 13:54:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.54 2017/05/02 13:54:08 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.54 2017/05/02 13:54:08 abhinav Exp $");
 
 #include 
 #include 
@@ -450,9 +450,10 @@ main(int argc, char *argv[])
 	while ((len = getline(, , file)) != -1) {
 		/* Replace the new line character at the end of string with '\0' */
 		line[len - 1] = '\0';
-		char *pdir = dirname(line);
+		char *pdir = estrdup(dirname(line));
 		/* Traverse the man page directories and parse the pages */
 		traversedir(pdir, line, db, mp);
+		free(pdir);
 	}
 	free(line);
 



CVS commit: src/usr.sbin/makemandb

2017-05-02 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Tue May  2 13:54:08 UTC 2017

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

Log Message:
We do need to copy the return value from dirname(3) since there it is a static
buffer and can be overwritten in between. I overzealously removed this in one
of my previous commits.


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

2017-05-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 06:56:00 UTC 2017

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

Log Message:
Avoid dereferencing pointer at multiple places, instead use a local variable.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/usr.sbin/makemandb/makemandb.c:1.53
--- src/usr.sbin/makemandb/makemandb.c:1.52	Mon May  1 06:43:56 2017
+++ src/usr.sbin/makemandb/makemandb.c	Mon May  1 06:56:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $");
 
 #include 
 #include 
@@ -1832,16 +1832,17 @@ insert_into_db(sqlite3 *db, mandb_rec *r
  *  1: If the hash exists in the database.
  */
 static int
-check_md5(const char *file, sqlite3 *db, char **md5sum, void *buf, size_t buflen)
+check_md5(const char *file, sqlite3 *db, char **md5, void *buf, size_t buflen)
 {
 	int rc = 0;
 	int idx = -1;
 	char *sqlstr = NULL;
+	char *mymd5;
 	sqlite3_stmt *stmt = NULL;
+	*md5 = NULL;
 
 	assert(file != NULL);
-	*md5sum = MD5Data(buf, buflen, NULL);
-	if (*md5sum == NULL) {
+	if ((mymd5 = MD5Data(buf, buflen, NULL)) == NULL) {
 		if (mflags.verbosity)
 			warn("md5 failed: %s", file);
 		return -1;
@@ -1851,23 +1852,22 @@ check_md5(const char *file, sqlite3 *db,
 	rc = sqlite3_prepare_v2(db, sqlstr, -1, , NULL);
 	if (rc != SQLITE_OK) {
 		free(sqlstr);
-		free(*md5sum);
-		*md5sum = NULL;
+		free(mymd5);
 		return -1;
 	}
 
 	idx = sqlite3_bind_parameter_index(stmt, ":md5_hash");
-	rc = sqlite3_bind_text(stmt, idx, *md5sum, -1, NULL);
+	rc = sqlite3_bind_text(stmt, idx, mymd5, -1, NULL);
 	if (rc != SQLITE_OK) {
 		if (mflags.verbosity)
 			warnx("%s", sqlite3_errmsg(db));
 		sqlite3_finalize(stmt);
 		free(sqlstr);
-		free(*md5sum);
-		*md5sum = NULL;
+		free(mymd5);
 		return -1;
 	}
 
+	*md5 = mymd5;
 	if (sqlite3_step(stmt) == SQLITE_ROW) {
 		sqlite3_finalize(stmt);
 		free(sqlstr);



CVS commit: src/usr.sbin/makemandb

2017-05-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 06:56:00 UTC 2017

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

Log Message:
Avoid dereferencing pointer at multiple places, instead use a local variable.


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

2017-05-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 06:43:56 UTC 2017

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

Log Message:
Remove the table name parameter from the check_md5 function.

There is only one table storing the md5 checksums, so we can hardcode the table
name instead of passing it as a function argument.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/usr.sbin/makemandb/makemandb.c:1.52
--- src/usr.sbin/makemandb/makemandb.c:1.51	Mon May  1 05:52:33 2017
+++ src/usr.sbin/makemandb/makemandb.c	Mon May  1 06:43:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $");
 
 #include 
 #include 
@@ -96,7 +96,7 @@ typedef	void (*proff_nf)(const struct ro
 static void append(secbuff *sbuff, const char *src);
 static void init_secbuffs(mandb_rec *);
 static void free_secbuffs(mandb_rec *);
-static int check_md5(const char *, sqlite3 *, const char *, char **, void *, size_t);
+static int check_md5(const char *, sqlite3 *, char **, void *, size_t);
 static void cleanup(mandb_rec *);
 static void set_section(const struct roff_man *, mandb_rec *);
 static void set_machine(const struct roff_man *, mandb_rec *);
@@ -804,8 +804,7 @@ update_db(sqlite3 *db, struct mparse *mp
 			err_count++;
 			continue;
 		}
-		md5_status = check_md5(file, db, "mandb_meta", , buf,
-		buflen);
+		md5_status = check_md5(file, db, , buf, buflen);
 		assert(md5sum != NULL);
 		if (md5_status == -1) {
 			if (mflags.verbosity)
@@ -1822,7 +1821,7 @@ insert_into_db(sqlite3 *db, mandb_rec *r
 /*
  * check_md5--
  *  Generates the md5 hash of the file and checks if it already doesn't exist
- *  in the table (passed as the 3rd parameter).
+ *  in the table.
  *  This function is being used to avoid hardlinks.
  *  On successful completion it will also set the value of the fourth parameter
  *  to the md5 hash of the file (computed previously). It is the responsibility
@@ -1833,8 +1832,7 @@ insert_into_db(sqlite3 *db, mandb_rec *r
  *  1: If the hash exists in the database.
  */
 static int
-check_md5(const char *file, sqlite3 *db, const char *table, char **md5sum,
-void *buf, size_t buflen)
+check_md5(const char *file, sqlite3 *db, char **md5sum, void *buf, size_t buflen)
 {
 	int rc = 0;
 	int idx = -1;
@@ -1849,8 +1847,7 @@ check_md5(const char *file, sqlite3 *db,
 		return -1;
 	}
 
-	easprintf(, "SELECT * FROM %s WHERE md5_hash = :md5_hash",
-	table);
+	easprintf(, "SELECT * FROM mandb_meta WHERE md5_hash = :md5_hash");
 	rc = sqlite3_prepare_v2(db, sqlstr, -1, , NULL);
 	if (rc != SQLITE_OK) {
 		free(sqlstr);



CVS commit: src/usr.sbin/makemandb

2017-05-01 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 06:43:56 UTC 2017

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

Log Message:
Remove the table name parameter from the check_md5 function.

There is only one table storing the md5 checksums, so we can hardcode the table
name instead of passing it as a function argument.


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 05:52:33 UTC 2017

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

Log Message:
Avoid copying strings where it is not needed.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 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.50 src/usr.sbin/makemandb/makemandb.c:1.51
--- src/usr.sbin/makemandb/makemandb.c:1.50	Sun Apr 30 08:41:18 2017
+++ src/usr.sbin/makemandb/makemandb.c	Mon May  1 05:52:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.50 2017/04/30 08:41:18 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.50 2017/04/30 08:41:18 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $");
 
 #include 
 #include 
@@ -331,7 +331,7 @@ main(int argc, char *argv[])
 {
 	FILE *file;
 	const char *sqlstr, *manconf = NULL;
-	char *line, *command, *parent;
+	char *line, *command;
 	char *errmsg;
 	int ch;
 	struct mparse *mp;
@@ -450,12 +450,9 @@ main(int argc, char *argv[])
 	while ((len = getline(, , file)) != -1) {
 		/* Replace the new line character at the end of string with '\0' */
 		line[len - 1] = '\0';
-		parent = estrdup(line);
-		char *pdir = estrdup(dirname(parent));
-		free(parent);
+		char *pdir = dirname(line);
 		/* Traverse the man page directories and parse the pages */
 		traversedir(pdir, line, db, mp);
-		free(pdir);
 	}
 	free(line);
 



CVS commit: src/usr.sbin/makemandb

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 05:52:33 UTC 2017

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

Log Message:
Avoid copying strings where it is not needed.


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 05:28:00 UTC 2017

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

Log Message:
Simplify handling of the section arguments in apropos(1).

Earlier, a white space separated string was generated containing all the section
numbers passed through command line arguments. Later on that would have to be
tokenized and processed. Instead of that, use a NULL terminated array of 
strings.

Thanks to christos@ for reviewing and suggesting further improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.21 -r1.22 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.36 src/usr.sbin/makemandb/apropos-utils.c:1.37
--- src/usr.sbin/makemandb/apropos-utils.c:1.36	Sun Apr 30 16:56:30 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Mon May  1 05:28:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.36 2017/04/30 16:56:30 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.37 2017/05/01 05:28:00 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.36 2017/04/30 16:56:30 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.37 2017/05/01 05:28:00 abhinav Exp $");
 
 #include 
 #include 
@@ -530,38 +530,14 @@ generate_search_query(query_args *args, 
 	 *   2. The LIMIT portion will be there if the user has specified
 	 *  a limit using the -n option.
 	 */
-	char *sections_str = args->sec_nums;
-	char *temp;
-	if (sections_str) {
-		while (*sections_str) {
-			size_t len = strcspn(sections_str, " ");
-			char *sec = sections_str;
-			if (sections_str[len] == 0) {
-sections_str += len;
-			} else {
-sections_str[len] = 0;
-sections_str += len + 1;
-			}
-			easprintf(, "\'%s\',", sec);
-
-			if (section_clause) {
-concat(_clause, temp);
-free(temp);
-			} else {
-section_clause = temp;
-			}
-		}
-		if (section_clause) {
-			/*
-			 * At least one section requested, add glue for query.
-			 * Before doing that, remove the comma at the end of
-			 * section_clause
-			 */
-			size_t section_clause_len = strlen(section_clause);
-			if (section_clause[section_clause_len - 1] == ',')
-section_clause[section_clause_len - 1] = 0;
-			temp = section_clause;
-			easprintf(_clause, " AND mandb.section IN (%s)", temp);
+	if (args->sections && args->sections[0]) {
+		concat(_clause, " AND mandb.section IN (");
+		for (size_t i = 0; args->sections[i]; i++) {
+			char *temp;
+			char c = args->sections[i + 1]? ',': ')';
+			if ((temp = sqlite3_mprintf("%Q%c", args->sections[i], c)) == NULL)
+goto RETURN;
+			concat(_clause, temp);
 			free(temp);
 		}
 	}

Index: src/usr.sbin/makemandb/apropos-utils.h
diff -u src/usr.sbin/makemandb/apropos-utils.h:1.11 src/usr.sbin/makemandb/apropos-utils.h:1.12
--- src/usr.sbin/makemandb/apropos-utils.h:1.11	Wed Apr 13 11:48:29 2016
+++ src/usr.sbin/makemandb/apropos-utils.h	Mon May  1 05:28:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.h,v 1.11 2016/04/13 11:48:29 christos Exp $	*/
+/*	$NetBSD: apropos-utils.h,v 1.12 2017/05/01 05:28:00 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -73,7 +73,7 @@ enum man_sec {
 
 typedef struct query_args {
 	const char *search_str;		// user query
-	char *sec_nums;		// Section in which to do the search
+	char **sections;		// Sections in which to do the search
 	int nrec;			// number of records to fetch
 	int offset;		//From which position to start processing the records
 	int legacy;

Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.21 src/usr.sbin/makemandb/apropos.c:1.22
--- src/usr.sbin/makemandb/apropos.c:1.21	Sun May 22 19:26:04 2016
+++ src/usr.sbin/makemandb/apropos.c	Mon May  1 05:28:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos.c,v 1.21 2016/05/22 19:26:04 abhinav Exp $	*/
+/*	$NetBSD: apropos.c,v 1.22 2017/05/01 05:28:00 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos.c,v 1.21 2016/05/22 19:26:04 abhinav Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.22 2017/05/01 05:28:00 abhinav Exp $");
 
 #include 
 #include 
@@ -43,7 +43,7 @@ __RCSID("$NetBSD: apropos.c,v 1.21 2016/
 #include "apropos-utils.h"
 
 typedef struct apropos_flags {
-	char *sec_nums;
+	char **sections;
 	int nresults;
 	int pager;
 	int no_context;
@@ -59,22 +59,30 @@ typedef struct callback_data {
 	apropos_flags *aflags;
 } 

CVS commit: src/usr.sbin/makemandb

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Mon May  1 05:28:00 UTC 2017

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

Log Message:
Simplify handling of the section arguments in apropos(1).

Earlier, a white space separated string was generated containing all the section
numbers passed through command line arguments. Later on that would have to be
tokenized and processed. Instead of that, use a NULL terminated array of 
strings.

Thanks to christos@ for reviewing and suggesting further improvements.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.21 -r1.22 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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 16:56:30 UTC 2017

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

Log Message:
Simplify


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/usr.sbin/makemandb/apropos-utils.c:1.36
--- src/usr.sbin/makemandb/apropos-utils.c:1.35	Sun Apr 30 15:27:24 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Apr 30 16:56:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.35 2017/04/30 15:27:24 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.36 2017/04/30 16:56:30 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.35 2017/04/30 15:27:24 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.36 2017/04/30 16:56:30 abhinav Exp $");
 
 #include 
 #include 
@@ -89,10 +89,8 @@ lower(char *str)
 	assert(str);
 	int i = 0;
 	char c;
-	while (str[i] != '\0') {
-		c = tolower((unsigned char) str[i]);
-		str[i++] = c;
-	}
+	while ((c = str[i]) != '\0')
+		str[i++] = tolower((unsigned char) c);
 	return str;
 }
 



CVS commit: src/usr.sbin/makemandb

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 16:56:30 UTC 2017

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

Log Message:
Simplify


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 15:27:24 UTC 2017

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

Log Message:
Instead of dereferencing the pointer passed in as function argument, use a
temporary local buffer. Saves the cost of pointer dereferencing at so many 
places.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/usr.sbin/makemandb/apropos-utils.c:1.35
--- src/usr.sbin/makemandb/apropos-utils.c:1.34	Sun Apr 30 14:53:58 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Apr 30 15:27:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.34 2017/04/30 14:53:58 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.35 2017/04/30 15:27:24 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.34 2017/04/30 14:53:58 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.35 2017/04/30 15:27:24 abhinav Exp $");
 
 #include 
 #include 
@@ -111,31 +111,34 @@ void
 concat2(char **dst, const char *src, size_t srclen)
 {
 	size_t totallen, dstlen;
+	char *mydst = *dst;
 	assert(src != NULL);
 
 	/*
 	 * If destination buffer dst is NULL, then simply
 	 * strdup the source buffer
 	 */
-	if (*dst == NULL) {
-		*dst = estrndup(src, srclen);
+	if (mydst == NULL) {
+		mydst = estrndup(src, srclen);
+		*dst = mydst;
 		return;
 	}
 
-	dstlen = strlen(*dst);
+	dstlen = strlen(mydst);
 	/*
 	 * NUL Byte and separator space
 	 */
 	totallen = dstlen + srclen + 2;
 
-	*dst = erealloc(*dst, totallen);
+	mydst = erealloc(mydst, totallen);
 
 	/* Append a space at the end of dst */
-	(*dst)[dstlen++] = ' ';
+	mydst[dstlen++] = ' ';
 
 	/* Now, copy src at the end of dst */
-	memcpy(*dst + dstlen, src, srclen);
-	(*dst)[dstlen + srclen] = '\0';
+	memcpy(mydst + dstlen, src, srclen);
+	mydst[dstlen + srclen] = '\0';
+	*dst = mydst;
 }
 
 void



CVS commit: src/usr.sbin/makemandb

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 15:27:24 UTC 2017

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

Log Message:
Instead of dereferencing the pointer passed in as function argument, use a
temporary local buffer. Saves the cost of pointer dereferencing at so many 
places.


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 14:53:58 UTC 2017

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

Log Message:
Update the comment to be in sync with the code.


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 14:53:58 UTC 2017

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

Log Message:
Update the comment to be in sync with the code.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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.33 src/usr.sbin/makemandb/apropos-utils.c:1.34
--- src/usr.sbin/makemandb/apropos-utils.c:1.33	Sun Apr 30 14:49:26 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Apr 30 14:53:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.33 2017/04/30 14:49:26 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.34 2017/04/30 14:53:58 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.33 2017/04/30 14:49:26 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.34 2017/04/30 14:53:58 abhinav Exp $");
 
 #include 
 #include 
@@ -520,12 +520,14 @@ generate_search_query(query_args *args, 
 	}
 
 	/* We want to build a query of the form: "select x,y,z from mandb where
-	 * mandb match :query [AND (section LIKE '1' OR section LIKE '2' OR...)]
-	 * ORDER BY rank DESC..."
+	 * mandb match :query [AND (section IN ('1', '2')]
+	 * ORDER BY rank DESC [LIMIT 10 OFFSET 0]"
 	 * NOTES:
-	 *   1. The portion in square brackets is optional, it will be there
-	 *  only if the user has specified an option on the command line
+	 *   1. The portion in first pair of square brackets is optional.
+	 *  It will be there only if the user has specified an option
 	 *  to search in one or more specific sections.
+	 *   2. The LIMIT portion will be there if the user has specified
+	 *  a limit using the -n option.
 	 */
 	char *sections_str = args->sec_nums;
 	char *temp;



CVS commit: src/usr.sbin/makemandb

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 14:49:26 UTC 2017

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

Log Message:
Use sqlite3_mprintf() to generate SQL query instead of asprintf.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.32 src/usr.sbin/makemandb/apropos-utils.c:1.33
--- src/usr.sbin/makemandb/apropos-utils.c:1.32	Thu Apr 27 08:02:24 2017
+++ src/usr.sbin/makemandb/apropos-utils.c	Sun Apr 30 14:49:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.32 2017/04/27 08:02:24 abhinav Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.33 2017/04/30 14:49:26 abhinav Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay 
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: apropos-utils.c,v 1.32 2017/04/27 08:02:24 abhinav Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.33 2017/04/30 14:49:26 abhinav Exp $");
 
 #include 
 #include 
@@ -503,12 +503,21 @@ generate_search_query(query_args *args, 
 	char *section_clause = NULL;
 	char *limit_clause = NULL;
 	char *machine_clause = NULL;
-	char *query;
+	char *query = NULL;
 
-	if (args->machine)
-		easprintf(_clause, "AND mandb.machine = \'%s\' ",
-		args->machine);
+	if (args->machine) {
+		machine_clause = sqlite3_mprintf("AND mandb.machine=%Q", args->machine);
+		if (machine_clause == NULL)
+			goto RETURN;
+	}
 
+	if (args->nrec >= 0) {
+		/* Use the provided number of records and offset */
+		limit_clause = sqlite3_mprintf(" LIMIT %d OFFSET %d",
+		args->nrec, args->offset);
+		if (limit_clause == NULL)
+			goto RETURN;
+	}
 
 	/* We want to build a query of the form: "select x,y,z from mandb where
 	 * mandb match :query [AND (section LIKE '1' OR section LIKE '2' OR...)]
@@ -554,12 +563,6 @@ generate_search_query(query_args *args, 
 		}
 	}
 
-	if (args->nrec >= 0) {
-		/* Use the provided number of records and offset */
-		easprintf(_clause, " LIMIT %d OFFSET %d",
-		args->nrec, args->offset);
-	}
-
 	if (snippet_args == NULL) {
 		default_snippet_args[0] = "";
 		default_snippet_args[1] = "";
@@ -623,6 +626,7 @@ generate_search_query(query_args *args, 
 		limit_clause ? limit_clause : "");
 	}
 
+RETURN:
 	free(machine_clause);
 	free(section_clause);
 	free(limit_clause);



CVS commit: src/usr.sbin/makemandb

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 14:49:26 UTC 2017

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

Log Message:
Use sqlite3_mprintf() to generate SQL query instead of asprintf.


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 08:41:18 UTC 2017

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

Log Message:
Avoid a call to strncmp when comparing only the first character of the string.


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

2017-04-30 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Apr 30 08:41:18 UTC 2017

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

Log Message:
Avoid a call to strncmp when comparing only the first character of the string.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 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.49 src/usr.sbin/makemandb/makemandb.c:1.50
--- src/usr.sbin/makemandb/makemandb.c:1.49	Sat Apr 29 16:49:51 2017
+++ src/usr.sbin/makemandb/makemandb.c	Sun Apr 30 08:41:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.49 2017/04/29 16:49:51 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.50 2017/04/30 08:41:18 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.49 2017/04/29 16:49:51 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.50 2017/04/30 08:41:18 abhinav Exp $");
 
 #include 
 #include 
@@ -519,7 +519,7 @@ traversedir(const char *parent, const ch
 
 		while ((dirp = readdir(dp)) != NULL) {
 			/* Avoid . and .. entries in a directory */
-			if (strncmp(dirp->d_name, ".", 1)) {
+			if (dirp->d_name[0] != '.') {
 easprintf(, "%s/%s", file, dirp->d_name);
 traversedir(parent, buf, db, mp);
 free(buf);



CVS commit: src/usr.sbin/makemandb

2017-04-29 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sat Apr 29 16:49:51 UTC 2017

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

Log Message:
Bring the comment in sync with code (after changes brought by the last commit).


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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.48 src/usr.sbin/makemandb/makemandb.c:1.49
--- src/usr.sbin/makemandb/makemandb.c:1.48	Sat Apr 29 14:43:09 2017
+++ src/usr.sbin/makemandb/makemandb.c	Sat Apr 29 16:49:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.48 2017/04/29 14:43:09 abhinav Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.49 2017/04/29 16:49:51 abhinav Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay 
  * Copyright (c) 2011 Kristaps Dzonsons 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: makemandb.c,v 1.48 2017/04/29 14:43:09 abhinav Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.49 2017/04/29 16:49:51 abhinav Exp $");
 
 #include 
 #include 
@@ -1108,8 +1108,7 @@ pmdoc_Sh(const struct roff_node *n, mand
 /*
  *  Called from pmdoc_Sh to parse body of a .Sh macro. It calls
  *  mdoc_parse_section to append the data to the section specific buffer.
- *  Two special macros which may occur inside the body of Sh are .Nm and .Xr and
- *  they need special handling, thus the separate if branches for them.
+ *  The .Xr macro needs special handling, thus the separate if branch for it.
  */
 static void
 mdoc_parse_Sh(const struct roff_node *n, mandb_rec *rec)



  1   2   3   >