Home | History | Annotate | Download | only in makemandb
History log of /src/usr.sbin/makemandb/apropos.c
RevisionDateAuthorComments
 1.27  03-Aug-2023  rin makemandb: trailing whitespace
 1.26  19-May-2022  gutteridge 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
 1.25  17-May-2022  gutteridge apropos.c: fix pager functionality

Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.
 1.24  25-Nov-2017  abhinav branches: 1.24.6;
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
 1.23  02-Aug-2017  jmcneill Make the 'no results found' message sound less harsh.

Changes "try using better keywords" to "try using different keywords".
 1.22  01-May-2017  abhinav branches: 1.22.2;
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.
 1.21  22-May-2016  abhinav branches: 1.21.6;
Add options to whatis and apropos to accept custom man.conf.

makemandb(8), man(1) already use -C as an option to take man.conf path,
so use the same option for whatis(1) and apropos(1) for consitency.
apropos was using -C/-c to disable/enable context of the search
matches, change that to -M/-m respectively.
 1.20  23-Apr-2016  christos add a newline
 1.19  13-Apr-2016  christos PR/51062: Abhinav Upadhyay: Allow non numeric sections to be indexed and
searched by apropos(1).
Fold long lines.
 1.18  31-Mar-2016  christos PR/51007: Abhinav Upadhyay: apropos.c: Remove unused includes
 1.17  20-Dec-2015  christos if we only asked for stopwords, use the original query.
 1.16  02-Apr-2013  christos instead of having a format and no format flag, and exposing various formatters,
provide a format enum and expose html formatting too.
 1.15  29-Mar-2013  wiz Sync usage with man page.
 1.14  29-Mar-2013  christos - Fix legacy mode to use like instead of match. This loses ranking.
- default to unlimited lines
- fix formatting of legacy mode
 1.13  29-Mar-2013  christos - If the stdout is not a tty, prevent formatting unless forced with -i
- Don't ever page unless asked for with -p
- Introduce "legacy mode" (-l)
1. searches only name and name_desc, prints name(section) - name_description
2. turns off escape formatting (can be forced on with -i)
3. turns off context printing (can be forced on with -c)
- Parse the environment $APROPOS variable as an argument vector.

With these changes one can simply 'export APROPOS=-l' and get the old apropos
behavior.
 1.12  10-Feb-2013  christos add -r flag to elide tty formatting
 1.11  10-Feb-2013  christos remove trailing whitespace
 1.10  14-Jan-2013  christos - move the terminal handling in apropos-utils.c since htmp and pager are also
handled there.
- underline the name, section, and description so that it is prettier.
- change to bold terminal the terminal highlighting to match with less
 1.9  14-Jan-2013  christos Fix the #ifdef NOTYET, namely use the terminal standout mode to highlight the
search terms.
 1.8  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.7  07-Sep-2012  wiz branches: 1.7.2;
Fix usage, from Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>.
 1.6  15-Apr-2012  wiz branches: 1.6.2;
Handle pages with slashes in their names better.
From Abhinav Upadhyay in private mail.
 1.5  15-Feb-2012  joerg Add support for apropos -s like in the old apropos. Fix capitalisation.
Add note about optional quotation. From Abhinav Upadhyay.
 1.4  07-Feb-2012  joerg branches: 1.4.2;
Kill bad magic invocation.
 1.3  07-Feb-2012  joerg getopt returns int, not char.
 1.2  07-Feb-2012  joerg 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.4.2.3  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.4.2.2  19-Apr-2012  riz Pull up following revision(s) (requested by wiz in ticket #186):
usr.sbin/makemandb/apropos.c: revision 1.6
usr.sbin/makemandb/apropos-utils.c: revision 1.3
usr.sbin/makemandb/apropos-utils.c: revision 1.4
Add the result from sqlite3_errmsg() to some error messages.
Now we can get "apropos: Unable to query schema version: database is locked"
instead of just "apropos: Unable to query schema version".
Handle pages with slashes in their names better.
From Abhinav Upadhyay in private mail.
 1.4.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.6.2.5  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.6.2.4  23-Jan-2013  yamt sync with head
 1.6.2.3  30-Oct-2012  yamt sync with head
 1.6.2.2  17-Apr-2012  yamt sync with head
 1.6.2.1  15-Apr-2012  yamt file apropos.c was added on branch yamt-pagecache on 2012-04-17 00:09:49 +0000
 1.7.2.3  23-Jun-2013  tls resync from head
 1.7.2.2  25-Feb-2013  tls resync with head
 1.7.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.21.6.1  02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.22.2.1  05-Aug-2017  snj Pull up following revision(s) (requested by jmcneill in ticket #176):
usr.sbin/makemandb/apropos.c: revision 1.23
Make the 'no results found' message sound less harsh.
Changes "try using better keywords" to "try using different keywords".
 1.24.6.1  03-Jun-2022  martin Pull up following revision(s) (requested by gutteridge in ticket #1461):

usr.sbin/makemandb/apropos.1: revision 1.19
usr.sbin/makemandb/apropos.c: revision 1.25
usr.sbin/makemandb/apropos.c: revision 1.26
usr.sbin/makemandb/apropos.1: revision 1.20
usr.sbin/makemandb/apropos.1: revision 1.21
usr.sbin/makemandb/apropos.1: revision 1.22
usr.sbin/makemandb/apropos.1: revision 1.23
usr.sbin/makemandb/apropos-utils.c: revision 1.46
usr.sbin/makemandb/apropos-utils.c: revision 1.47
usr.sbin/makemandb/apropos-utils.c: revision 1.49

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

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.

apropos.c: fix pager functionality

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

apropos.1: document the PAGER environment variable

apropos(1): use proper -width

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

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.

apropos(1): Use the official spelling for "SQLite".
While here, use .Bx to refer to 3BSD.

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=3D/non-existent apropos -p ...
2. Return proper exit status in case of write errors:
$ apropos ... >/dev/full || echo fail

RSS XML Feed