remove trailing whitespace
This commit is contained in:
parent
01401401c3
commit
9d8fe63b1b
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: apropos-utils.c,v 1.9 2013/01/14 21:26:25 christos Exp $ */
|
/* $NetBSD: apropos-utils.c,v 1.10 2013/02/10 23:24:18 christos Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: apropos-utils.c,v 1.9 2013/01/14 21:26:25 christos Exp $");
|
__RCSID("$NetBSD: apropos-utils.c,v 1.10 2013/02/10 23:24:18 christos Exp $");
|
||||||
|
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -99,8 +99,8 @@ lower(char *str)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* concat--
|
* concat--
|
||||||
* Utility function. Concatenates together: dst, a space character and src.
|
* Utility function. Concatenates together: dst, a space character and src.
|
||||||
* dst + " " + src
|
* dst + " " + src
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
concat(char **dst, const char *src)
|
concat(char **dst, const char *src)
|
||||||
|
@ -131,7 +131,7 @@ concat2(char **dst, const char *src, size_t srclen)
|
||||||
/* Append a space at the end of dst */
|
/* Append a space at the end of dst */
|
||||||
(*dst)[dst_len++] = ' ';
|
(*dst)[dst_len++] = ' ';
|
||||||
|
|
||||||
/* Now, copy src at the end of dst */
|
/* Now, copy src at the end of dst */
|
||||||
memcpy(*dst + dst_len, src, srclen + 1);
|
memcpy(*dst + dst_len, src, srclen + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ create_db(sqlite3 *db)
|
||||||
const char *sqlstr = NULL;
|
const char *sqlstr = NULL;
|
||||||
char *schemasql;
|
char *schemasql;
|
||||||
char *errmsg = NULL;
|
char *errmsg = NULL;
|
||||||
|
|
||||||
/*------------------------ Create the tables------------------------------*/
|
/*------------------------ Create the tables------------------------------*/
|
||||||
|
|
||||||
#if NOTYET
|
#if NOTYET
|
||||||
|
@ -207,7 +207,7 @@ out:
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
zip(sqlite3_context *pctx, int nval, sqlite3_value **apval)
|
zip(sqlite3_context *pctx, int nval, sqlite3_value **apval)
|
||||||
{
|
{
|
||||||
int nin;
|
int nin;
|
||||||
long int nout;
|
long int nout;
|
||||||
const unsigned char * inbuf;
|
const unsigned char * inbuf;
|
||||||
|
@ -278,7 +278,7 @@ get_dbpath(const char *manconf)
|
||||||
tp = gettag("_mandb", 1);
|
tp = gettag("_mandb", 1);
|
||||||
if (!tp)
|
if (!tp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&tp->entrylist))
|
if (TAILQ_EMPTY(&tp->entrylist))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -289,15 +289,15 @@ get_dbpath(const char *manconf)
|
||||||
/* init_db --
|
/* init_db --
|
||||||
* Prepare the database. Register the compress/uncompress functions and the
|
* Prepare the database. Register the compress/uncompress functions and the
|
||||||
* stopword tokenizer.
|
* stopword tokenizer.
|
||||||
* db_flag specifies the mode in which to open the database. 3 options are
|
* db_flag specifies the mode in which to open the database. 3 options are
|
||||||
* available:
|
* available:
|
||||||
* 1. DB_READONLY: Open in READONLY mode. An error if db does not exist.
|
* 1. DB_READONLY: Open in READONLY mode. An error if db does not exist.
|
||||||
* 2. DB_READWRITE: Open in read-write mode. An error if db does not exist.
|
* 2. DB_READWRITE: Open in read-write mode. An error if db does not exist.
|
||||||
* 3. DB_CREATE: Open in read-write mode. It will try to create the db if
|
* 3. DB_CREATE: Open in read-write mode. It will try to create the db if
|
||||||
* it does not exist already.
|
* it does not exist already.
|
||||||
* RETURN VALUES:
|
* RETURN VALUES:
|
||||||
* The function will return NULL in case the db does not exist and DB_CREATE
|
* The function will return NULL in case the db does not exist and DB_CREATE
|
||||||
* was not specified. And in case DB_CREATE was specified and yet NULL is
|
* was not specified. And in case DB_CREATE was specified and yet NULL is
|
||||||
* returned, then there was some other error.
|
* returned, then there was some other error.
|
||||||
* In normal cases the function should return a handle to the db.
|
* In normal cases the function should return a handle to the db.
|
||||||
*/
|
*/
|
||||||
|
@ -329,7 +329,7 @@ init_db(int db_flag, const char *manconf)
|
||||||
/* Now initialize the database connection */
|
/* Now initialize the database connection */
|
||||||
sqlite3_initialize();
|
sqlite3_initialize();
|
||||||
rc = sqlite3_open_v2(dbpath, &db, db_flag, NULL);
|
rc = sqlite3_open_v2(dbpath, &db, db_flag, NULL);
|
||||||
|
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
warnx("%s", sqlite3_errmsg(db));
|
warnx("%s", sqlite3_errmsg(db));
|
||||||
sqlite3_shutdown();
|
sqlite3_shutdown();
|
||||||
|
@ -362,7 +362,7 @@ init_db(int db_flag, const char *manconf)
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
sqlite3_extended_result_codes(db, 1);
|
sqlite3_extended_result_codes(db, 1);
|
||||||
|
|
||||||
/* Register the zip and unzip functions for FTS compression */
|
/* Register the zip and unzip functions for FTS compression */
|
||||||
rc = sqlite3_create_function(db, "zip", 1, SQLITE_ANY, NULL, zip, NULL, NULL);
|
rc = sqlite3_create_function(db, "zip", 1, SQLITE_ANY, NULL, zip, NULL, NULL);
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
|
@ -371,7 +371,7 @@ init_db(int db_flag, const char *manconf)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = sqlite3_create_function(db, "unzip", 1, SQLITE_ANY, NULL,
|
rc = sqlite3_create_function(db, "unzip", 1, SQLITE_ANY, NULL,
|
||||||
unzip, NULL, NULL);
|
unzip, NULL, NULL);
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
warnx("Unable to register function: uncompress: %s",
|
warnx("Unable to register function: uncompress: %s",
|
||||||
|
@ -391,14 +391,14 @@ error:
|
||||||
* 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.
|
* 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.
|
* It computes the final rank, by multiplying tf and idf together.
|
||||||
* Weight of term t for document d = (term frequency of t in d *
|
* Weight of term t for document d = (term frequency of t in d *
|
||||||
* inverse document frequency of t)
|
* inverse document frequency of t)
|
||||||
*
|
*
|
||||||
* Term Frequency of term t in document d = Number of times t occurs in d /
|
* Term Frequency of term t in document d = Number of times t occurs in d /
|
||||||
* Number of times t appears in all
|
* Number of times t appears in all
|
||||||
* documents
|
* documents
|
||||||
*
|
*
|
||||||
* Inverse document frequency of t = log(Total number of documents /
|
* Inverse document frequency of t = log(Total number of documents /
|
||||||
* Number of documents in which t occurs)
|
* Number of documents in which t occurs)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
|
@ -424,12 +424,12 @@ rank_func(sqlite3_context *pctx, int nval, sqlite3_value **apval)
|
||||||
int icol;
|
int icol;
|
||||||
const unsigned int *phraseinfo = &matchinfo[2 + ncol+ iphrase * ncol * 3];
|
const unsigned int *phraseinfo = &matchinfo[2 + ncol+ iphrase * ncol * 3];
|
||||||
for(icol = 1; icol < ncol; icol++) {
|
for(icol = 1; icol < ncol; icol++) {
|
||||||
|
|
||||||
/* nhitcount: number of times the current phrase occurs in the current
|
/* nhitcount: number of times the current phrase occurs in the current
|
||||||
* column in the current document.
|
* column in the current document.
|
||||||
* nglobalhitcount: number of times current phrase occurs in the current
|
* nglobalhitcount: number of times current phrase occurs in the current
|
||||||
* column in all documents.
|
* column in all documents.
|
||||||
* ndocshitcount: number of documents in which the current phrase
|
* ndocshitcount: number of documents in which the current phrase
|
||||||
* occurs in the current column at least once.
|
* occurs in the current column at least once.
|
||||||
*/
|
*/
|
||||||
int nhitcount = phraseinfo[3 * icol];
|
int nhitcount = phraseinfo[3 * icol];
|
||||||
|
@ -440,7 +440,7 @@ rank_func(sqlite3_context *pctx, int nval, sqlite3_value **apval)
|
||||||
if (idf->status == 0 && ndocshitcount)
|
if (idf->status == 0 && ndocshitcount)
|
||||||
idf->value += log(((double)ndoc / ndocshitcount))* weight;
|
idf->value += log(((double)ndoc / ndocshitcount))* weight;
|
||||||
|
|
||||||
/* Dividing the tf by document length to normalize the effect of
|
/* Dividing the tf by document length to normalize the effect of
|
||||||
* longer documents.
|
* longer documents.
|
||||||
*/
|
*/
|
||||||
if (nglobalhitcount > 0 && nhitcount)
|
if (nglobalhitcount > 0 && nhitcount)
|
||||||
|
@ -448,9 +448,9 @@ rank_func(sqlite3_context *pctx, int nval, sqlite3_value **apval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idf->status = 1;
|
idf->status = 1;
|
||||||
|
|
||||||
/* Final score = (tf * idf)/ ( k + tf)
|
/* Final score = (tf * idf)/ ( k + tf)
|
||||||
* Dividing by k+ tf further normalizes the weight leading to better
|
* Dividing by k+ tf further normalizes the weight leading to better
|
||||||
* results.
|
* results.
|
||||||
* The value of k is experimental
|
* The value of k is experimental
|
||||||
*/
|
*/
|
||||||
|
@ -464,9 +464,9 @@ rank_func(sqlite3_context *pctx, int nval, sqlite3_value **apval)
|
||||||
* Performs the searches for the keywords entered by the user.
|
* Performs the searches for the keywords entered by the user.
|
||||||
* The 2nd param: snippet_args is an array of strings providing values for the
|
* The 2nd param: snippet_args is an array of strings providing values for the
|
||||||
* last three parameters to the snippet function of sqlite. (Look at the docs).
|
* last three parameters to the snippet function of sqlite. (Look at the docs).
|
||||||
* The 3rd param: args contains rest of the search parameters. Look at
|
* The 3rd param: args contains rest of the search parameters. Look at
|
||||||
* arpopos-utils.h for the description of individual fields.
|
* arpopos-utils.h for the description of individual fields.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
run_query(sqlite3 *db, const char *snippet_args[3], query_args *args)
|
run_query(sqlite3 *db, const char *snippet_args[3], query_args *args)
|
||||||
|
@ -492,7 +492,7 @@ run_query(sqlite3 *db, const char *snippet_args[3], query_args *args)
|
||||||
easprintf(&machine_clause, "AND machine = \'%s\' ", args->machine);
|
easprintf(&machine_clause, "AND machine = \'%s\' ", args->machine);
|
||||||
|
|
||||||
/* Register the rank function */
|
/* Register the rank function */
|
||||||
rc = sqlite3_create_function(db, "rank_func", 1, SQLITE_ANY, (void *)&idf,
|
rc = sqlite3_create_function(db, "rank_func", 1, SQLITE_ANY, (void *)&idf,
|
||||||
rank_func, NULL, NULL);
|
rank_func, NULL, NULL);
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
warnx("Unable to register the ranking function: %s",
|
warnx("Unable to register the ranking function: %s",
|
||||||
|
@ -501,12 +501,12 @@ run_query(sqlite3 *db, const char *snippet_args[3], query_args *args)
|
||||||
sqlite3_shutdown();
|
sqlite3_shutdown();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We want to build a query of the form: "select x,y,z from mandb where
|
/* 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...)]
|
* mandb match :query [AND (section LIKE '1' OR section LIKE '2' OR...)]
|
||||||
* ORDER BY rank DESC..."
|
* ORDER BY rank DESC..."
|
||||||
* NOTES: 1. The portion in square brackets is optional, it will be there
|
* 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 to search in
|
* only if the user has specified an option on the command line to search in
|
||||||
* one or more specific sections.
|
* one or more specific sections.
|
||||||
* 2. I am using LIKE operator because '=' or IN operators do not seem to be
|
* 2. I am using LIKE operator because '=' or IN operators do not seem to be
|
||||||
* working with the compression option enabled.
|
* working with the compression option enabled.
|
||||||
|
@ -623,7 +623,7 @@ callback_html(void *data, const char *section, const char *name,
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
struct orig_callback_data *orig_data = (struct orig_callback_data *) data;
|
struct orig_callback_data *orig_data = (struct orig_callback_data *) data;
|
||||||
int (*callback) (void *, const char *, const char *, const char *,
|
int (*callback) (void *, const char *, const char *, const char *,
|
||||||
const char *, size_t) = orig_data->callback;
|
const char *, size_t) = orig_data->callback;
|
||||||
|
|
||||||
/* First scan the snippet to find out the number of occurrences of {'>', '<'
|
/* First scan the snippet to find out the number of occurrences of {'>', '<'
|
||||||
|
@ -696,7 +696,7 @@ callback_html(void *data, const char *section, const char *name,
|
||||||
/*
|
/*
|
||||||
* run_query_html --
|
* run_query_html --
|
||||||
* Utility function to output query result in HTML format.
|
* Utility function to output query result in HTML format.
|
||||||
* It internally calls run_query only, but it first passes the output to it's
|
* It internally calls run_query only, but it first passes the output to it's
|
||||||
* own custom callback function, which preprocess the snippet for quoting
|
* own custom callback function, which preprocess the snippet for quoting
|
||||||
* inline HTML fragments.
|
* inline HTML fragments.
|
||||||
* After that it delegates the call the actual user supplied callback function.
|
* After that it delegates the call the actual user supplied callback function.
|
||||||
|
@ -742,7 +742,7 @@ ul_pager(const char *s)
|
||||||
* more or less.
|
* more or less.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
callback_pager(void *data, const char *section, const char *name,
|
callback_pager(void *data, const char *section, const char *name,
|
||||||
const char *name_desc, const char *snippet, size_t snippet_length)
|
const char *name_desc, const char *snippet, size_t snippet_length)
|
||||||
{
|
{
|
||||||
struct orig_callback_data *orig_data = (struct orig_callback_data *) data;
|
struct orig_callback_data *orig_data = (struct orig_callback_data *) data;
|
||||||
|
@ -832,7 +832,7 @@ ul_term(const char *s, const struct term_args *ta)
|
||||||
* more or less.
|
* more or less.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
callback_term(void *data, const char *section, const char *name,
|
callback_term(void *data, const char *section, const char *name,
|
||||||
const char *name_desc, const char *snippet, size_t snippet_length)
|
const char *name_desc, const char *snippet, size_t snippet_length)
|
||||||
{
|
{
|
||||||
struct term_args *ta = data;
|
struct term_args *ta = data;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: apropos-utils.h,v 1.5 2013/01/14 21:26:25 christos Exp $ */
|
/* $NetBSD: apropos-utils.h,v 1.6 2013/02/10 23:24:18 christos Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -91,4 +91,4 @@ int run_query(sqlite3 *, const char *[3], query_args *);
|
||||||
int run_query_html(sqlite3 *, query_args *);
|
int run_query_html(sqlite3 *, query_args *);
|
||||||
int run_query_pager(sqlite3 *, query_args *);
|
int run_query_pager(sqlite3 *, query_args *);
|
||||||
int run_query_term(sqlite3 *, query_args *);
|
int run_query_term(sqlite3 *, query_args *);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: apropos.c,v 1.10 2013/01/14 21:26:25 christos Exp $ */
|
/* $NetBSD: apropos.c,v 1.11 2013/02/10 23:24:18 christos Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: apropos.c,v 1.10 2013/01/14 21:26:25 christos Exp $");
|
__RCSID("$NetBSD: apropos.c,v 1.11 2013/02/10 23:24:18 christos Exp $");
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <search.h>
|
#include <search.h>
|
||||||
|
@ -85,9 +85,9 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
memset(&aflags, 0, sizeof(aflags));
|
memset(&aflags, 0, sizeof(aflags));
|
||||||
|
|
||||||
/*If the user specifies a section number as an option, the corresponding
|
/*If the user specifies a section number as an option, the corresponding
|
||||||
* index element in sec_nums is set to the string representing that
|
* index element in sec_nums is set to the string representing that
|
||||||
* section number.
|
* section number.
|
||||||
*/
|
*/
|
||||||
while ((ch = getopt(argc, argv, "123456789Ccn:pS:s:")) != -1) {
|
while ((ch = getopt(argc, argv, "123456789Ccn:pS:s:")) != -1) {
|
||||||
|
@ -130,10 +130,10 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (!argc)
|
if (!argc)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ main(int argc, char *argv[])
|
||||||
rc = run_query_term(db, &args);
|
rc = run_query_term(db, &args);
|
||||||
else
|
else
|
||||||
rc = run_query_pager(db, &args);
|
rc = run_query_pager(db, &args);
|
||||||
|
|
||||||
free(query);
|
free(query);
|
||||||
close_db(db);
|
close_db(db);
|
||||||
if (errmsg) {
|
if (errmsg) {
|
||||||
|
@ -190,7 +190,7 @@ main(int argc, char *argv[])
|
||||||
/* Something wrong with the database. Exit */
|
/* Something wrong with the database. Exit */
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cbdata.count == 0) {
|
if (cbdata.count == 0) {
|
||||||
warnx("No relevant results obtained.\n"
|
warnx("No relevant results obtained.\n"
|
||||||
"Please make sure that you spelled all the terms correctly "
|
"Please make sure that you spelled all the terms correctly "
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: makemandb.c,v 1.17 2013/01/14 18:01:59 christos Exp $ */
|
/* $NetBSD: makemandb.c,v 1.18 2013/02/10 23:24:18 christos Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
||||||
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
|
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: makemandb.c,v 1.17 2013/01/14 18:01:59 christos Exp $");
|
__RCSID("$NetBSD: makemandb.c,v 1.18 2013/02/10 23:24:18 christos Exp $");
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -108,7 +108,7 @@ static void pmdoc_Nd(const struct mdoc_node *, mandb_rec *);
|
||||||
static void pmdoc_Sh(const struct mdoc_node *, mandb_rec *);
|
static void pmdoc_Sh(const struct mdoc_node *, mandb_rec *);
|
||||||
static void pmdoc_Xr(const struct mdoc_node *, mandb_rec *);
|
static void pmdoc_Xr(const struct mdoc_node *, mandb_rec *);
|
||||||
static void pmdoc_Pp(const struct mdoc_node *, mandb_rec *);
|
static void pmdoc_Pp(const struct mdoc_node *, mandb_rec *);
|
||||||
static void pmdoc_macro_handler(const struct mdoc_node *, mandb_rec *,
|
static void pmdoc_macro_handler(const struct mdoc_node *, mandb_rec *,
|
||||||
enum mdoct);
|
enum mdoct);
|
||||||
static void pman_node(const struct man_node *n, mandb_rec *);
|
static void pman_node(const struct man_node *n, mandb_rec *);
|
||||||
static void pman_parse_node(const struct man_node *, secbuff *);
|
static void pman_parse_node(const struct man_node *, secbuff *);
|
||||||
|
@ -387,7 +387,7 @@ main(int argc, char *argv[])
|
||||||
free(errmsg);
|
free(errmsg);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlstr = "CREATE TABLE metadb.file_cache(device, inode, mtime, parent,"
|
sqlstr = "CREATE TABLE metadb.file_cache(device, inode, mtime, parent,"
|
||||||
" file PRIMARY KEY);"
|
" file PRIMARY KEY);"
|
||||||
"CREATE UNIQUE INDEX metadb.index_file_cache_dev"
|
"CREATE UNIQUE INDEX metadb.index_file_cache_dev"
|
||||||
|
@ -464,13 +464,13 @@ traversedir(const char *parent, const char *file, sqlite3 *db,
|
||||||
warn("stat failed: %s", file);
|
warn("stat failed: %s", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it is a regular file or a symlink, pass it to build_cache() */
|
/* If it is a regular file or a symlink, pass it to build_cache() */
|
||||||
if (S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
|
if (S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
|
||||||
build_file_cache(db, parent, file, &sb);
|
build_file_cache(db, parent, file, &sb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If it is a directory, traverse it recursively */
|
/* If it is a directory, traverse it recursively */
|
||||||
if (S_ISDIR(sb.st_mode)) {
|
if (S_ISDIR(sb.st_mode)) {
|
||||||
if ((dp = opendir(file)) == NULL) {
|
if ((dp = opendir(file)) == NULL) {
|
||||||
|
@ -478,7 +478,7 @@ traversedir(const char *parent, const char *file, sqlite3 *db,
|
||||||
warn("opendir error: %s", file);
|
warn("opendir error: %s", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((dirp = readdir(dp)) != NULL) {
|
while ((dirp = readdir(dp)) != NULL) {
|
||||||
/* Avoid . and .. entries in a directory */
|
/* Avoid . and .. entries in a directory */
|
||||||
if (strncmp(dirp->d_name, ".", 1)) {
|
if (strncmp(dirp->d_name, ".", 1)) {
|
||||||
|
@ -784,7 +784,7 @@ update_db(sqlite3 *db, struct mparse *mp, mandb_rec *rec)
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
if (mflags.verbosity == 2) {
|
if (mflags.verbosity == 2) {
|
||||||
printf("Total Number of new or updated pages encountered = %d\n"
|
printf("Total Number of new or updated pages encountered = %d\n"
|
||||||
"Total number of (hard or symbolic) links found = %d\n"
|
"Total number of (hard or symbolic) links found = %d\n"
|
||||||
|
@ -1179,7 +1179,7 @@ pman_node(const struct man_node *n, mandb_rec *rec)
|
||||||
pman_node(n->next, rec);
|
pman_node(n->next, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pman_parse_name --
|
* pman_parse_name --
|
||||||
* Parses the NAME section and puts the complete content in the name_desc
|
* Parses the NAME section and puts the complete content in the name_desc
|
||||||
* variable.
|
* variable.
|
||||||
|
@ -1212,7 +1212,7 @@ pman_block(const struct man_node *n, mandb_rec *rec)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pman_sh --
|
* pman_sh --
|
||||||
* This function does one of the two things:
|
* This function does one of the two things:
|
||||||
* 1. If the present section is NAME, then it will:
|
* 1. If the present section is NAME, then it will:
|
||||||
|
@ -1283,7 +1283,7 @@ pman_sh(const struct man_node *n, mandb_rec *rec)
|
||||||
/* Remove any leading spaces. */
|
/* Remove any leading spaces. */
|
||||||
while (name_desc[0] == ' ')
|
while (name_desc[0] == ' ')
|
||||||
name_desc++;
|
name_desc++;
|
||||||
|
|
||||||
/* If the line begins with a "\&", avoid those */
|
/* If the line begins with a "\&", avoid those */
|
||||||
if (name_desc[0] == '\\' && name_desc[1] == '&')
|
if (name_desc[0] == '\\' && name_desc[1] == '&')
|
||||||
name_desc += 2;
|
name_desc += 2;
|
||||||
|
@ -1375,7 +1375,7 @@ pman_sh(const struct man_node *n, mandb_rec *rec)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pman_parse_node --
|
* pman_parse_node --
|
||||||
* Generic function to iterate through a node. Usually called from
|
* Generic function to iterate through a node. Usually called from
|
||||||
* man_parse_section to parse a particular section of the man page.
|
* man_parse_section to parse a particular section of the man page.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
|
@ -1386,14 +1386,14 @@ pman_parse_node(const struct man_node *n, secbuff *s)
|
||||||
|
|
||||||
if (n->type == MAN_TEXT)
|
if (n->type == MAN_TEXT)
|
||||||
append(s, n->string);
|
append(s, n->string);
|
||||||
|
|
||||||
pman_parse_node(n->child, s);
|
pman_parse_node(n->child, s);
|
||||||
pman_parse_node(n->next, s);
|
pman_parse_node(n->next, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* man_parse_section --
|
* man_parse_section --
|
||||||
* Takes two parameters:
|
* Takes two parameters:
|
||||||
* sec: Tells which section we are present in
|
* sec: Tells which section we are present in
|
||||||
* n: Is the present node of the AST.
|
* n: Is the present node of the AST.
|
||||||
* Depending on the section, we call pman_parse_node to parse that section and
|
* Depending on the section, we call pman_parse_node to parse that section and
|
||||||
|
@ -1464,12 +1464,12 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
|
||||||
char *ln = NULL;
|
char *ln = NULL;
|
||||||
char *errmsg = NULL;
|
char *errmsg = NULL;
|
||||||
long int mandb_rowid;
|
long int mandb_rowid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At the very minimum we want to make sure that we store
|
* At the very minimum we want to make sure that we store
|
||||||
* the following data:
|
* the following data:
|
||||||
* Name, one line description, and the MD5 hash
|
* Name, one line description, and the MD5 hash
|
||||||
*/
|
*/
|
||||||
if (rec->name == NULL || rec->name_desc == NULL ||
|
if (rec->name == NULL || rec->name_desc == NULL ||
|
||||||
rec->md5_hash == NULL) {
|
rec->md5_hash == NULL) {
|
||||||
cleanup(rec);
|
cleanup(rec);
|
||||||
|
@ -1601,14 +1601,14 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
goto Out;
|
goto Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = sqlite3_bind_parameter_index(stmt, ":md5_hash");
|
idx = sqlite3_bind_parameter_index(stmt, ":md5_hash");
|
||||||
rc = sqlite3_bind_text(stmt, idx, rec->md5_hash, -1, NULL);
|
rc = sqlite3_bind_text(stmt, idx, rec->md5_hash, -1, NULL);
|
||||||
if (rc != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
goto Out;
|
goto Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = sqlite3_bind_parameter_index(stmt, ":machine");
|
idx = sqlite3_bind_parameter_index(stmt, ":machine");
|
||||||
if (rec->machine)
|
if (rec->machine)
|
||||||
rc = sqlite3_bind_text(stmt, idx, rec->machine, -1, NULL);
|
rc = sqlite3_bind_text(stmt, idx, rec->machine, -1, NULL);
|
||||||
|
@ -1626,10 +1626,10 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
/* Get the row id of the last inserted row */
|
/* Get the row id of the last inserted row */
|
||||||
mandb_rowid = sqlite3_last_insert_rowid(db);
|
mandb_rowid = sqlite3_last_insert_rowid(db);
|
||||||
|
|
||||||
/*------------------------Populate the mandb_meta table-----------------------*/
|
/*------------------------Populate the mandb_meta table-----------------------*/
|
||||||
sqlstr = "INSERT INTO mandb_meta VALUES (:device, :inode, :mtime,"
|
sqlstr = "INSERT INTO mandb_meta VALUES (:device, :inode, :mtime,"
|
||||||
" :file, :md5_hash, :id)";
|
" :file, :md5_hash, :id)";
|
||||||
|
@ -1752,7 +1752,7 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
|
||||||
|
|
||||||
/*------------------------ Populate the mandb_links table---------------------*/
|
/*------------------------ Populate the mandb_links table---------------------*/
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
char *links;
|
char *links;
|
||||||
if (rec->links && strlen(rec->links)) {
|
if (rec->links && strlen(rec->links)) {
|
||||||
links = rec->links;
|
links = rec->links;
|
||||||
for(ln = strtok(links, " "); ln; ln = strtok(NULL, " ")) {
|
for(ln = strtok(links, " "); ln; ln = strtok(NULL, " ")) {
|
||||||
|
@ -1760,7 +1760,7 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
|
||||||
ln++;
|
ln++;
|
||||||
if(ln[strlen(ln) - 1] == ',')
|
if(ln[strlen(ln) - 1] == ',')
|
||||||
ln[strlen(ln) - 1] = 0;
|
ln[strlen(ln) - 1] = 0;
|
||||||
|
|
||||||
str = sqlite3_mprintf("INSERT INTO mandb_links"
|
str = sqlite3_mprintf("INSERT INTO mandb_links"
|
||||||
" VALUES (%Q, %Q, %Q, %Q, %Q)",
|
" VALUES (%Q, %Q, %Q, %Q, %Q)",
|
||||||
ln, rec->name, rec->section,
|
ln, rec->name, rec->section,
|
||||||
|
@ -1839,7 +1839,7 @@ check_md5(const char *file, sqlite3 *db, const char *table, char **md5sum,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqlite3_step(stmt) == SQLITE_ROW) {
|
if (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
free(sqlstr);
|
free(sqlstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1869,7 +1869,7 @@ optimize(sqlite3 *db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cleanup --
|
* cleanup --
|
||||||
* cleans up the global buffers
|
* cleans up the global buffers
|
||||||
*/
|
*/
|
||||||
|
@ -2018,7 +2018,7 @@ parse_escape(const char *str)
|
||||||
} while (backslash != NULL);
|
} while (backslash != NULL);
|
||||||
if (last_backslash != NULL)
|
if (last_backslash != NULL)
|
||||||
strcpy(iter, last_backslash);
|
strcpy(iter, last_backslash);
|
||||||
|
|
||||||
replace_hyph(result);
|
replace_hyph(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue