summaryrefslogtreecommitdiffstats
path: root/mansearch.h
Commit message (Collapse)AuthorAgeFilesLines
* header cleanup:Ingo Schwarze2014-12-011-0/+2
| | | | | | * add missing forward declarations * remove needless header inclusions * some style unification
* remove unneccessary inclusion protection; patch from deraadt@Ingo Schwarze2014-12-011-4/+0
|
* Make makewhatis(8) understand .so links to .gz pages.Ingo Schwarze2014-11-271-1/+0
| | | | | | | | Drop the FORM_GZ annotation in the mpages table; it is conceptually wrong because it ought to be in the mlinks table: An uncompressed .so link file can point to a compressed manual page file and vice versa. Besides, it is no longer needed because mparse_open() handles it all. Sprinkle some KNF while here.
* In man(1) mode, prefer file name matches over .Dt name matches overIngo Schwarze2014-11-181-4/+5
| | | | | | first .Nm entries over other NAME .Nm entries over SYNOPSIS .Nm entries. For example, this makes sure "man ypbind" does not return yp(8). Re-run "makewhatis" to profit from this change.
* In man(1) mode without -a, stop searching after the first manual treeIngo Schwarze2014-11-111-0/+1
| | | | | that contained at least one match in order to not prefer mdoc(1) from ports over mdoc(7). As a bonus, this results in a speedup.
* If a manual page is installed gzip(1)ed, let makewhatis(8) takeIngo Schwarze2014-09-031-0/+5
| | | | | | | note in mandoc.db(5), such that man(1) -w and apropos(1) -w can report the correct filename. This is a prerequisite for letting apropos -a and man support gzip'ed manuals in the future, which doesn't work yet.
* In man(1) mode, change to the right directory before starting the parser,Ingo Schwarze2014-09-011-0/+1
| | | | | | | just like traditional man(1) does, such that .so links have a chance to work. After this point, we don't need the current directory for anything else before exit, so we don't need to worry about getting back and we can safely ignore failure.
* Fully integrate apropos(1) into mandoc(1).Ingo Schwarze2014-08-171-7/+12
| | | | | | | | | Switch the argmode on the progname, including man(1). Provide -f and -k options to switch the argmode. Store the argmode inside struct search, generalizing the flags. Derive the deftype from the argmode when needed instead of storing it. Store the outkey inside struct search instead of passing it alone. While here, get rid of the trailing blanks in Makefile.depend.
* Sort result pages first by section number, then by name.Ingo Schwarze2014-07-241-0/+1
| | | | | | | | By moving the sort from cgi.c to mansearch.c, we get two advantages: Easier access to the data needed for sorting, in particular the section number, and the apropos(1) command line utility profits as well. Feature requested by deraadt@.
* Fix whatis(1) to correctly match words instead of any substrings.Ingo Schwarze2014-07-121-1/+2
| | | | | While here, also provide an internal mode (MANSEARCH_MAN) to match complete names, to be used by man.cgi(8).
* Further apropos(1) speed optimization was trickier than anticipated.Ingo Schwarze2014-04-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Contrary to what i initially thought, almost all time is now spent inside sqlite3(3) routines, and i found no easy way calling less of them. However, sqlite(3) spends substantial time in malloc(3), and even more (twice that) in its immediate malloc wrapper, sqlite3MemMalloc(), keeping track of all individual malloc chunk sizes. Typically about 90% of the malloced memory is used for purposes of the pagecache. By providing an mmap(3) MAP_ANON SQLITE_CONFIG_PAGECACHE, execution time decreases by 20-25% for simple (Nd and/or Nm) queries, 10-20% for non-NAME queries, and even apropos(1) resident memory size as reported by top(1) decreases by 20% for simple and by 60% for non-NAME queries. The new function, mansearch_setup(), spends no measurable time. The pagesize chosen is optimal: * Substantially smaller pages yield no gain at all. * Larger pages provide no additional benefit and just waste memory. The chosen number of pages in the cache is a compromise: * For simple queries, a handful of pages would suffice to get the full speed effect, at an apropos(1) resident memory size of about 2.0 MB. * For non-NAME queries, a large pagecache with 2k pages (2.5 MB) might gain a few more percent in speed, but at the expense of doubling the apropos(1) resident memory size for *all* queries. * The chosen number of 256 pages (330 kB) allows nearly full speed gain for all queries at the price of a 15% resident memory size increase.
* Next speed optimization step for the new apropos(1).Ingo Schwarze2014-04-101-41/+47
| | | | | | | | | | | | | | Split manual names out of the common "keys" table into their own "names" table. This reduces standard apropos(1) search times (i.e. searching for names and descriptions only) by typically about 70% for the full /usr/share/man database. (Yes, that multiplies with the previous optimization step, so both together have reduced search times by a factor of more than six. I'm not done yet, expect more to come.) Even with the minimal databases built with makewhatis(8) -Q, this step still reduces search times by 15-20%. For both cases, database sizes and build times hardly change (+/-2%).
* After careful gprof(1)ing of the new apropos(1), move the descriptionsIngo Schwarze2014-04-091-39/+39
| | | | | | | | | | | | back from the keys table to the mpages table: I found a good way to still use them in searches, without complication of the code. On my notebook, this reduces typical apropos(1) search times by about 40%, it reduces /usr/share/man database size by 6% in makewhatis(8) -Q mode and by 2% in standard mode (less overhead storing pointers to mpages), and it doesn't measurably change database build times (may even be going down by a percent or so because less data is being copied around in ohashes).
* Remember which names are in the NAME section.Ingo Schwarze2014-04-041-41/+42
| | | | | | | This helps to find missing MLINKS. Database build times do not change and database growth is minimal (1.2% with -Q, 0.7% without -Q in /usr/share/man), so making this optional would be pointless.
* Sort the macro keys by their real-world frequency to reduce the averageIngo Schwarze2014-01-181-40/+40
| | | | | | | | mask size. No functional change. This shrinks the standard /usr/share/man database by 7%, now at 10.3x the size of whatis.db, and with -Q even by 11%, now at 3.0x of whatis.db. Now i'm out of ideas to easily shrink the size of the database.
* Drop Nd from the mpages table, it is still in the keys table.Ingo Schwarze2014-01-061-1/+0
| | | | | This shrinks the database in standard mode by 3%, in -Q mode by 9%, without loss of functionality.
* Put section and architecture info into the keys table,Ingo Schwarze2014-01-051-0/+2
| | | | | | | | | | in preparation for removing them from the mpages table, aiming for cleaner and more uniform interfaces. Database growth is below 4%, part of which will be reclaimed. As a bonus, this allows searches like: ./obj/apropos An=kettenis -a arch=ppc ./obj/apropos An=kettenis -a sec~[^4]
* Experimental feature to let apropos(1) show different keys than .Nd.Ingo Schwarze2013-12-311-0/+3
| | | | | | | | This really takes us beyond what grep -R /usr/*/man/ can do because now you can search for pages by *one* criterion and then display the contents of *another* macro from those pages, like in $ apropos -O Ox Fa~wchar to get an impression how long wide character handling is available.
* Change the mansearch() interface to use the mlinks table in the databaseIngo Schwarze2013-12-271-1/+2
| | | | | | and return a list of names with sections, used by apropos(1) for display. While here, improve uniformity of the interface by allocating the file name dynamically, just like the names list and the description.
* No point in inventing yet another file name for the database.Ingo Schwarze2013-06-061-1/+1
| | | | | | We are not going back to Berkeley DB and don't care about overwriting any obsolete files that may be lying around. So, go back from "mandocdb.db" to "mandoc.db".
* Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from <sys/param.h>.Ingo Schwarze2013-06-051-1/+1
| | | | | | Consistently use the PATH_MAX since it is specified by POSIX, while MAXPATHLEN is not. In preparation for using this at a few more places.
* Merge whatis.1 into apropos.1 (and remove), add whatis bits to aproposKristaps Dzonsons2012-06-091-4/+52
| | | | (via mansearch), and merge mandocdb.h into mansearch.h (and remove).
* Add a new mansearch.h interface, which replaces apropos_db.cKristaps Dzonsons2012-06-081-0/+38
This is a much more minimal interface that stuffs all operations into a single function. It uses sqlite3 and ohash.