Home | History | Annotate | Download | only in makemandb
History log of /src/usr.sbin/makemandb/makemandb.c
RevisionDateAuthorComments
 1.67  01-Jan-2023  gutteridge makemandb.c: spell "metadata" consistently
 1.66  30-Oct-2022  gutteridge makemandb.c: fix grammar in a comment
 1.65  26-Oct-2022  andvar fix various typos in comments and makefs README file.
 1.64  11-Sep-2022  gutteridge makemandb/*: fix spelling of database and consistency of SQLite
 1.63  06-Jun-2022  skrll 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
 1.62  06-Apr-2022  gutteridge 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.
 1.61  05-Dec-2021  msaitoh s/trival/trivial/ in comment.
 1.60  18-May-2019  abhinav branches: 1.60.2;
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
 1.59  11-Mar-2019  christos remove unneeded header.
 1.58  11-Mar-2019  christos adjust to the new mandoc api
 1.57  24-Aug-2018  abhinav Adjust makemandb for the latest mandoc

ok christos@
 1.56  16-Aug-2018  kre 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).
 1.55  10-May-2017  abhinav branches: 1.55.8; 1.55.10;
Get rid of unnecessary variable.
 1.54  02-May-2017  abhinav 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.
 1.53  01-May-2017  abhinav Avoid dereferencing pointer at multiple places, instead use a local variable.
 1.52  01-May-2017  abhinav 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.
 1.51  01-May-2017  abhinav Avoid copying strings where it is not needed.
 1.50  30-Apr-2017  abhinav Avoid a call to strncmp when comparing only the first character of the string.
 1.49  29-Apr-2017  abhinav Bring the comment in sync with code (after changes brought by the last commit).
 1.48  29-Apr-2017  abhinav 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).
 1.47  20-Apr-2017  joerg branches: 1.47.2;
Use libarchive 3.x interface and not obsolete 2.x versions.
 1.46  19-Dec-2016  abhinav branches: 1.46.2;
Escape hyphen when parsing .Nd
 1.45  17-Dec-2016  abhinav 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@
 1.44  03-Oct-2016  abhinav We don't need to parse the sections we don't index, so stop early. Saves few
instructions.
 1.43  03-Oct-2016  abhinav 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@
 1.42  17-Jul-2016  abhinav 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@
 1.41  17-Jul-2016  abhinav 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>
 1.40  15-Jul-2016  christos Sync with API changes.
 1.39  06-Jul-2016  abhinav branches: 1.39.2;
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
 1.38  05-Jul-2016  abhinav Reuse variable from previous line.
 1.37  13-Apr-2016  christos PR/51062: Abhinav Upadhyay: Allow non numeric sections to be indexed and
searched by apropos(1).
Fold long lines.
 1.36  13-Apr-2016  christos PR/51040: Abhinav Upadhyay: Fix memory leak
 1.35  13-Apr-2016  christos PR/51039: Abhinav Upadhyay: Check for return value of chdir(2)
 1.34  13-Apr-2016  christos PR/51034: Abhinav Upadhyay: Close database connection when failed to commit
 1.33  31-Mar-2016  christos PR/51034: Abhinav Upadhyay: makemandb(8): Close database connection when
failed to commit
 1.32  24-Mar-2016  christos PR/51006: Abhinav Upadhyay: makemandb(8) should parse escape sequences
in the NAME section
 1.31  28-Jan-2016  christos Don't crash if we have a missing section.
 1.30  18-Dec-2015  christos Adjust to the new mdocml
 1.29  07-Apr-2015  plunky 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.
 1.28  12-Mar-2015  joerg MDOC_MAX is a valid token if the type is text. Adjust.
 1.27  04-Mar-2015  christos - handle section numbers that are not single digits
- don't allocate and free needlessly
 1.26  02-Mar-2015  joerg Explicitly deal with end of lists. PR 49708.
 1.25  18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.24  03-Jun-2014  wiz branches: 1.24.2;
Fix a bug that caused an error about a UNIQUE constraint violation.
Patch from Abhinav Upadhyay.
 1.23  24-May-2014  wiz Replace non-breaking space with hyphen, and call hyphen replacement
from one more place.
Improves 'man -k midi' output.

From Abhinav Upadhyay.
 1.22  10-Feb-2014  chs branches: 1.22.2;
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.
 1.21  05-Jan-2014  joerg Sync with interface change in mdocml 1.12.3.
 1.20  13-Nov-2013  wiz Skip files of size 0 from indexing.

From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.19  15-May-2013  christos avoid stdio assertion, failing later
 1.18  10-Feb-2013  christos remove trailing whitespace
 1.17  14-Jan-2013  christos Since mdocml decided to name headers that conflict with system ones (term.h)
move the header inclusion one up.
 1.16  08-Nov-2012  christos If you cannot parse .SH NAME, like in the case of the ksh93 man page
where the .SH is followed by a conditional:

.SH NAME
.if \nZ=0 \{\
text text text
.\}

at least don't core-dump.
 1.15  06-Oct-2012  wiz Make mandb path configurable. makemandb (and related tools) use
the path from the _mandb variable from man.conf now.

Set _mandb in man.conf to same value as was used before.

From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.14  07-Sep-2012  wiz branches: 1.14.2;
Use emalloc in one more place, like the rest of the code does.
From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.13  29-Aug-2012  wiz Add -Q flag:
Print only fatal error messages (i.e., when the database is left in
an inconsistent state and needs manual intervention).

From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.12  25-Aug-2012  wiz Sync usage with manpage.
 1.11  11-Aug-2012  wiz Bug fix for PR 46733:
> makemandb always reports the same number for "Total Number of new or
> updated pages enountered" and "Total number of (hard or symbolic)
> links found".

Patch from Abhinav Upadhyay.
 1.10  08-Jul-2012  uwe Fix typo in a message.
 1.9  07-May-2012  wiz PR 46419 by Abhinav Upadhyay using his updated patch:
Clean up after removing man page aliases.
 1.8  04-May-2012  wiz The new apropos(1) incorrectly displays hyphens in the first line
of the search results for a few man pages (for man(7) based man
pages).

Use patch from Abhinav Upadhyay in PR 46408 to fix this.
 1.7  02-Mar-2012  joerg branches: 1.7.2;
Fix inverted condition when handling stale entries.
From Abhinav Upadhyay.
 1.6  27-Feb-2012  joerg Expand workaround for .so usage to do the chdir call just before
starting parsing, not during the tree iteration. This gives it a chance
to work.
 1.5  16-Feb-2012  joerg Add support for compressed man pages in all the usual formats.
 1.4  15-Feb-2012  joerg Also handle hyphen replacement if it was used as plain input and no
backslash sequence was used at all in the line.
 1.3  15-Feb-2012  joerg Be a bit more friendly to man pages using the roff .so command by
changing the current directory to the parent of the man -p entry, e.g.
/usr/share/man for /usr/share/man1.
 1.2  07-Feb-2012  joerg branches: 1.2.2;
Fix C&P error with $NetBSD$
 1.1  07-Feb-2012  joerg Import the new apropos/whatis.

This code has been developed by Abhinav Upadhyay as part of Google's Summer
of Code 2011. It uses libmandoc to parse man pages and builds a Full
Text Index in a SQLite database. The combination of indexing the full
manual page, filtering out stop words and ranking individual matches
based on the section gives a much improved user experience.

The old makewhatis and friends are kept under MKMAKEMANDB=no for now.
 1.2.2.7  08-Feb-2013  riz Pull up following revision(s) (requested by christos in ticket #786):
usr.sbin/makemandb/makemandb.c: revision 1.16
If you cannot parse .SH NAME, like in the case of the ksh93 man page
where the .SH is followed by a conditional:
.SH NAME
.if \nZ=0 \{text text text
.\}
at least don't core-dump.
 1.2.2.6  20-Nov-2012  riz Pull up following revision(s) (requested by tron in ticket #676):
usr.sbin/makemandb/apropos.c: revision 1.7
usr.sbin/makemandb/makemandb.8: revision 1.3
usr.sbin/makemandb/makemandb.8: revision 1.4
usr.sbin/makemandb/makemandb.8: revision 1.5
etc/rc.d/makemandb: revision 1.4
etc/weekly: revision 1.29
usr.sbin/makemandb/makemandb.c: revision 1.10
usr.sbin/makemandb/makemandb.c: revision 1.11
usr.sbin/makemandb/makemandb.c: revision 1.12
usr.sbin/makemandb/makemandb.c: revision 1.13
usr.sbin/makemandb/makemandb.c: revision 1.14
usr.sbin/makemandb/apropos.1: revision 1.5
etc/daily: revision 1.87
Add HISTORY section. From Abhinav Upadhyay in private mail.
Sync with reality, From Abhinav Upadhyay in private mail.
Fix typo in a message.
Bug fix for PR 46733:
> makemandb always reports the same number for "Total Number of new or
> updated pages enountered" and "Total number of (hard or symbolic)
> links found".
Patch from Abhinav Upadhyay.
Sort options in SYNOPSIS.
Sync usage with manpage.
Add -Q flag:
Print only fatal error messages (i.e., when the database is left in
an inconsistent state and needs manual intervention).
From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
Use new makemandb -Q flag to be really quiet.
Fix usage, from Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
Use emalloc in one more place, like the rest of the code does.
From Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.2.2.5  09-May-2012  riz Pull up following revision(s) (requested by wiz in ticket #229):
usr.sbin/makemandb/makemandb.c: revision 1.9
usr.sbin/makemandb/DBSCHEMA: revision 1.2
usr.sbin/makemandb/apropos-utils.c: revision 1.5
usr.sbin/makemandb/apropos-utils.h: revision 1.3
PR 46419 by Abhinav Upadhyay using his updated patch:
Clean up after removing man page aliases.
 1.2.2.4  07-May-2012  riz Pull up following revision(s) (requested by wiz in ticket #228):
usr.sbin/makemandb/makemandb.c: revision 1.8
The new apropos(1) incorrectly displays hyphens in the first line
of the search results for a few man pages (for man(7) based man
pages).
Use patch from Abhinav Upadhyay in PR 46408 to fix this.
 1.2.2.3  05-Mar-2012  sborrill Pull up the following revisions(s) (requested by joerg in ticket #77):
usr.sbin/makemandb/makemandb.c: revision 1.7

Fix inverted condition when handling stale entries.
 1.2.2.2  02-Mar-2012  riz Pull up following revision(s) (requested by joerg in ticket #70):
usr.sbin/makemandb/makemandb.c: revision 1.6
Expand workaround for .so usage to do the chdir call just before
starting parsing, not during the tree iteration. This gives it a chance
to work.
 1.2.2.1  18-Feb-2012  riz Pull up following revision(s) (requested by joerg in ticket #4):
usr.sbin/makemandb/apropos.c: revision 1.5
external/bsd/mdocml/dist/read.c: revision 1.6
external/bsd/mdocml/dist/mandoc.h: revision 1.2
usr.sbin/makemandb/makemandb.c: revision 1.3
usr.sbin/makemandb/makemandb.c: revision 1.4
usr.sbin/makemandb/makemandb.c: revision 1.5
usr.sbin/makemandb/Makefile: revision 1.2
etc/man.conf: revision 1.30
usr.sbin/makemandb/apropos.1: revision 1.3
external/bsd/mdocml/Makefile.inc: revision 1.15
Be a bit more friendly to man pages using the roff .so command by
changing the current directory to the parent of the man -p entry, e.g.
/usr/share/man for /usr/share/man1.
Also handle hyphen replacement if it was used as plain input and no
backslash sequence was used at all in the line.
Add support for apropos -s like in the old apropos. Fix capitalisation.
Add note about optional quotation. From Abhinav Upadhyay.
Merge mandoc.h r1.99 and read.c 1.28 from upstream:
Add mparse_readmem, which allows application to run the parser directly
from memory, e.g. after de-compressing a document.
Add support for compressed man pages in all the usual formats.
Use mmap when dealing with plain files.
Add entries for bzip2 and xz.
 1.7.2.7  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.2.6  23-Jan-2013  yamt sync with head
 1.7.2.5  16-Jan-2013  yamt sync with (a bit old) head
 1.7.2.4  30-Oct-2012  yamt sync with head
 1.7.2.3  23-May-2012  yamt sync with head.
 1.7.2.2  17-Apr-2012  yamt sync with head
 1.7.2.1  02-Mar-2012  yamt file makemandb.c was added on branch yamt-pagecache on 2012-04-17 00:09:49 +0000
 1.14.2.4  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.3  23-Jun-2013  tls resync from head
 1.14.2.2  25-Feb-2013  tls resync with head
 1.14.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.22.2.1  10-Aug-2014  tls Rebase.
 1.24.2.3  14-Apr-2015  snj Pull up following revision(s) (requested by christos in ticket #675):
usr.sbin/makemandb/makemandb.c: revision 1.27
- handle section numbers that are not single digits
- don't allocate and free needlessly
 1.24.2.2  15-Mar-2015  snj Pull up following revision(s) (requested by joerg in ticket #589):
usr.sbin/makemandb/makemandb.c: revision 1.28
MDOC_MAX is a valid token if the type is text. Adjust.
 1.24.2.1  07-Mar-2015  snj Pull up following revision(s) (requested by skrll in ticket #564):
usr.sbin/makemandb/makemandb.c: revision 1.26
Explicitly deal with end of lists. PR 49708.
 1.39.2.4  26-Apr-2017  pgoyette Sync with HEAD
 1.39.2.3  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.39.2.2  04-Nov-2016  pgoyette Sync with HEAD
 1.39.2.1  26-Jul-2016  pgoyette Sync with HEAD
 1.46.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.47.2.2  11-May-2017  pgoyette Sync with HEAD
 1.47.2.1  02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.55.10.1  10-Jun-2019  christos Sync with HEAD
 1.55.8.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.60.2.1  06-Jun-2022  martin Pull up following revision(s) (requested by skrll in ticket #1465):

usr.sbin/makemandb/makemandb.c: revision 1.63

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.

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

RSS XML Feed