Commit Graph

67 Commits

Author SHA1 Message Date
gutteridge 550467b4c4 makemandb.c: spell "metadata" consistently 2023-01-01 21:27:14 +00:00
gutteridge 954d646f97 makemandb.c: fix grammar in a comment 2022-10-30 01:49:30 +00:00
andvar 49811c99f0 fix various typos in comments and makefs README file. 2022-10-26 21:56:19 +00:00
gutteridge 6f0eae4436 makemandb/*: fix spelling of database and consistency of SQLite 2022-09-11 20:32:37 +00:00
skrll 09be482eb3 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
2022-06-06 07:41:23 +00:00
gutteridge f2240c734a 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.
2022-04-06 03:23:38 +00:00
msaitoh 813cf550c4 s/trival/trivial/ in comment. 2021-12-05 08:18:18 +00:00
abhinav 933b5da267 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
2019-05-18 07:56:43 +00:00
christos 7f6ee53058 remove unneeded header. 2019-03-11 00:31:36 +00:00
christos 059d37ece9 adjust to the new mandoc api 2019-03-11 00:14:44 +00:00
abhinav 50d4d47f30 Adjust makemandb for the latest mandoc
ok christos@
2018-08-24 16:01:57 +00:00
kre 6a7c82e6b2 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).
2018-08-16 05:07:22 +00:00
abhinav a46498cbc0 Get rid of unnecessary variable. 2017-05-10 12:09:52 +00:00
abhinav 0b6c27b077 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.
2017-05-02 13:54:08 +00:00
abhinav 520f86ec72 Avoid dereferencing pointer at multiple places, instead use a local variable. 2017-05-01 06:56:00 +00:00
abhinav 05f4872247 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.
2017-05-01 06:43:56 +00:00
abhinav 1d50c960ff Avoid copying strings where it is not needed. 2017-05-01 05:52:33 +00:00
abhinav e62bbc5df1 Avoid a call to strncmp when comparing only the first character of the string. 2017-04-30 08:41:18 +00:00
abhinav 116a5447e2 Bring the comment in sync with code (after changes brought by the last commit). 2017-04-29 16:49:51 +00:00
abhinav c376a38e5b Don't parse Nm macro when it occurs anywhere outside the NAME section.
mandoc(3) already generates the text node representing the value for the .Nm macro.
Doing our own parsing for .Nm on top of that leads to large duplication of text
in the database. This gets specially worse for man pages with large NAME sections,
such as queue(3).
2017-04-29 14:43:09 +00:00
joerg c57cca78b1 Use libarchive 3.x interface and not obsolete 2.x versions. 2017-04-20 13:11:35 +00:00
abhinav 01c3d3dc7f Escape hyphen when parsing .Nd 2016-12-19 14:10:57 +00:00
abhinav e4137a4e3a Don't ignore symlinks.
There can be symlinks which are pointing to man pages not installed in
one of the _default locations mentioned in man.conf or MANPATH. For example
there are man pages in /usr/pkg/man which are symlinked to pages in
/usr/pkg/lib/perl5/man. If we ignore symlinks, we would not be able to
index such pages installed outside the default set of directories.

(Also, the symlink test was incorecct, so we never noticed this issue)

Ok christos@, wiz@
2016-12-17 17:04:38 +00:00
abhinav e108642273 We don't need to parse the sections we don't index, so stop early. Saves few
instructions.
2016-10-03 16:11:11 +00:00
abhinav 150a47b73e With the latest release of mandoc, makemandb(8) started to parse some
sections multiple times. This started to happen because, pmdoc_Sh(), the handler function
responsible for parsing the Sh macros, used to recursively go through all the child
nodes and then the next nodes starting from top level Sh block node.
Now, once it has processed all the child nodes of the top level block node,
it moves to the next node, which is the top level block node of the next section and
in this way one call to pmdoc_Sh() was causing a complete pass through the
man page. Since, mandoc(3) calls pmdoc_Sh() for each .Sh macro in the man
page, it would result in parsing some of the sections multiple times.
This never happened with the previous versions of mandoc, so we never noticed.

I've fixed this by starting the parse sequence of the Sh macro from its body, which gurantees
that we will stop once that section ends.

ok christos@
2016-10-03 13:53:39 +00:00
abhinav ee829d24f5 Use deroff() from mandoc(3) to directly parse the Nd macro rather
than parsing it by hand.

With the latest mandoc(3), the .Nd macro was getting parsed twice. This fixes
that problem and cleans up the code as well.

ok christos@
2016-07-17 15:56:14 +00:00
abhinav 19584ea1f8 Fix extraction of section number and machine architecture from man pages.
With the latest API, mdoc_validate()/man_validate() needs to be called before
reading the roff_man.meta field, otherwise it is NULL.

Also, if a man page doesn't specify machine architecture, don't default to '?'
, let it be stored as null in the db. Otherwise, the output of apropos(1) shows
the names of the results as \?/<title>
2016-07-17 12:18:12 +00:00
christos 00e4117929 Sync with API changes. 2016-07-15 19:41:33 +00:00
abhinav d5630c9cd6 Avoid possible buffer overflow while parsing NAME section of man(7) pages.
Also, simplify copyging of strings, use estrdupn instead of emalloc + memcpy.

Patch from christos@, XXX comment by me
2016-07-06 08:52:01 +00:00
abhinav 168510ab07 Reuse variable from previous line. 2016-07-05 16:24:18 +00:00
christos 5e64704ab9 PR/51062: Abhinav Upadhyay: Allow non numeric sections to be indexed and
searched by apropos(1).
Fold long lines.
2016-04-13 11:48:29 +00:00
christos 0fc86a7786 PR/51040: Abhinav Upadhyay: Fix memory leak 2016-04-13 01:41:18 +00:00
christos b3b58d82a5 PR/51039: Abhinav Upadhyay: Check for return value of chdir(2) 2016-04-13 01:40:09 +00:00
christos 88453a2aaf PR/51034: Abhinav Upadhyay: Close database connection when failed to commit 2016-04-13 01:32:00 +00:00
christos 8896183565 PR/51034: Abhinav Upadhyay: makemandb(8): Close database connection when
failed to commit
2016-03-31 20:17:58 +00:00
christos 8fb426c83c PR/51006: Abhinav Upadhyay: makemandb(8) should parse escape sequences
in the NAME section
2016-03-24 17:28:03 +00:00
christos 91708124b8 Don't crash if we have a missing section. 2016-01-28 03:32:29 +00:00
christos 0f635f7225 Adjust to the new mdocml 2015-12-18 14:30:16 +00:00
plunky 877e528c4e largely apply patch from PR bin/47392 by Abhinav Upadhyay
change some comments to reflect reality, a variable name to enhance
readability, and adds an assert for safety.
2015-04-07 17:47:10 +00:00
joerg a23fab26e8 MDOC_MAX is a valid token if the type is text. Adjust. 2015-03-12 14:57:18 +00:00
christos 704de17457 - handle section numbers that are not single digits
- don't allocate and free needlessly
2015-03-04 02:02:15 +00:00
joerg 5a02bfcb09 Explicitly deal with end of lists. PR 49708. 2015-03-02 13:51:24 +00:00
snj f0a7346d21 src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
2014-10-18 08:33:23 +00:00
wiz 82d04f72be Fix a bug that caused an error about a UNIQUE constraint violation.
Patch from Abhinav Upadhyay.
2014-06-03 14:42:41 +00:00
wiz 6dc3f341a8 Replace non-breaking space with hyphen, and call hyphen replacement
from one more place.
Improves 'man -k midi' output.

From Abhinav Upadhyay.
2014-05-24 21:01:58 +00:00
chs 49d6a7c368 in update_db(), extract the full list of files to update from the db
before actually updating anything, since changing the db while the query
that extracts the list of files is still in progress results in
the extraction query failing before it finds everything.
2014-02-10 00:23:36 +00:00
joerg 12f8f2b852 Sync with interface change in mdocml 1.12.3. 2014-01-05 19:26:44 +00:00
wiz 0f54719895 Skip files of size 0 from indexing.
From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
2013-11-13 18:46:33 +00:00
christos 9eea140044 avoid stdio assertion, failing later 2013-05-15 00:35:02 +00:00
christos 9d8fe63b1b remove trailing whitespace 2013-02-10 23:24:18 +00:00