summaryrefslogtreecommitdiffstats
path: root/apropos.c
Commit message (Collapse)AuthorAgeFilesLines
* Further apropos(1) speed optimization was trickier than anticipated.Ingo Schwarze2014-04-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Drop Nd from the mpages table, it is still in the keys table.Ingo Schwarze2014-01-061-4/+2
| | | | | This shrinks the database in standard mode by 3%, in -Q mode by 9%, without loss of functionality.
* Experimental feature to let apropos(1) show different keys than .Nd.Ingo Schwarze2013-12-311-3/+13
| | | | | | | | 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/+3
| | | | | | 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.
* Simple partial sync with OpenBSD:Ingo Schwarze2013-07-051-10/+10
| | | | | | | * Again accept suffixes on the name of the whatis utility. * The usage line for whatis must not invite expressions. * Revert the argument names in the SYNOPSIS back to the usual ones. * Revert a few gratuitious changes regarding line breaks etc.
* Allow compilation on Mac OSX.Kristaps Dzonsons2012-06-091-0/+1
|
* Merge whatis.1 into apropos.1 (and remove), add whatis bits to aproposKristaps Dzonsons2012-06-091-7/+12
| | | | (via mansearch), and merge mandocdb.h into mansearch.h (and remove).
* Flip apropos to use mansearch instead of apropos_db.Kristaps Dzonsons2012-06-081-166/+31
| | | | | | | | | This makes the utility much smaller and simpler. A lot of functionality has been omitted while the sqlite3 search routines improve (logical operations, etc.). It still needs work to make the output more conventional. Also add the manpage utility, which I use extensively as a mind-meld of apropos and man.
* Forgot chdir(2) into volume path.VERSION.1.12.1Kristaps Dzonsons2012-03-241-0/+1
|
* Small tweaks for release.Kristaps Dzonsons2012-03-241-0/+1
|
* Be insane. Make apropos(1) subsume man(1).Kristaps Dzonsons2012-03-241-18/+90
|
* Simplify by not pre-filtering the result vector for satisfied matches:Kristaps Dzonsons2012-03-241-9/+16
| | | | we can do this in the frontend.
* Revert to mandocdb.{index,db} for database files.Kristaps Dzonsons2012-03-231-3/+4
|
* When parsing catpages, read from the first section (NAME, we hope) untilKristaps Dzonsons2011-12-311-1/+1
| | | | | the next section. Also, remove the limit of 72 characters and enforce this, instead in the apropos frontend.
* implement -C (alternative config file) for apropos(1) and mandocdb(8),Ingo Schwarze2011-12-121-3/+9
| | | | | including various tweaks to the whatis(8) manual; ok kristaps@
* Apropos and man.cgi should strcasecmp their output sorting.Kristaps Dzonsons2011-12-071-1/+1
| | | | | man.cgi should sort in the first place -- it wasn't before. Revert uppercasing of man.cgi title.
* Make `-i' only apply to regular expressions. For the equality operatorKristaps Dzonsons2011-11-291-2/+2
| | | | | | (and thus the default), always use strcasestr(). Discussed on tech@ with schwarze@. While here, fix the apropos.c usage() message to be consistent with apropos(1) and clean up the EXAMPLES in apropos(1).
* Tweak whatis(1):Ingo Schwarze2011-11-281-1/+1
| | | | | | | * Bugfix: Use all arguments, not just the last one. * Use 'Nm~' instead of 'Nm,Nd~' to match OpenBSD behaviour. * For the progname, accept '^whatis', not '^whatis$' to ease testing. ok kristaps@
* Get us a whatis(1) mode for apropos(1).Kristaps Dzonsons2011-11-271-8/+12
| | | | | This is from a patch to tech@ as critiqued by schwarze@, checked in to get the ball rolling.
* Sync to OpenBSD, mostly gratuitous and whitespace differences,Ingo Schwarze2011-11-261-9/+9
| | | | | | | | | but a few serious things as well: * -M overrides MANPATH * -m prepends to the path * put back database close calls that got lost in mandocdb * missing sys/types.h in manpath.c, needed for size_t ok kristaps@
* Have apropos(1) take advantage of manpath.h instead of doing the workKristaps Dzonsons2011-11-231-133/+4
| | | | itself.
* Initial support for man.conf/makepath(1).Kristaps Dzonsons2011-11-201-8/+92
|
* Clarify some behaviour, bringing schwarze@'s patch and mine closer togetherKristaps Dzonsons2011-11-201-22/+21
| | | | | | | | | | | | | | | | (although I still don't have -M, which is a big piece). First, the default search path is the cwd. This will change to use -M once I look over that code. If MANPATH is specified, this replaces the cwd. Both of these are augmented by -m. If paths don't exist or don't have databases, they're silently ignored. This makes perfect sense: you may be given a superset of possible paths. The corner case of no paths (where, say, MANPATH consists of bogus paths or the cwd is unreadable) simply means that no paths are searched.
* Integrate a moderately-patched version of schwarze@'s support for multipleKristaps Dzonsons2011-11-201-19/+89
| | | | | | | | | | | directories containing mandocdb(8) databases. Some changes follow: (1) don't support -M yet; (2) fall back to cwd if no prior manpath has been specified; (3) resolve manpages using realpath() to prevent consecutive chdir()'s over relative paths; (4) note where further error-reporting is required; (5) fix leaking memory on exit in several cases.
* Evaluation with logical subexpressions. This allows support for arbitrary,Kristaps Dzonsons2011-11-181-37/+13
| | | | nested logical subexpressions with AND (-a) and OR (-o) support.
* Have exprcomp() accept a string instead of an array-pointer. Also, collapseKristaps Dzonsons2011-11-141-1/+28
| | | | | the arguments in apropos(1) into a single string passed to exprcomp(). Ok schwarze@.
* Rewrite the expression parser for a more concise syntax:Ingo Schwarze2011-11-131-8/+3
| | | | | | | | | | | | | apropos [search_type[,...]=]substring apropos search_type[,...][,i]~regex ... and expression evaluation must take the search type into account. This allows to: * drop the global -I option and * drop the enum match, just using a boolean int. "go ahead" kristaps@
* Less misleading file names; ok kristaps@.Ingo Schwarze2011-11-131-1/+1
|
* Make apropos's lookup use a find(1)-like expression. I'll write more onKristaps Dzonsons2011-11-091-56/+15
| | | | | | | | | | this when it completes; this is to keep it in-tree. Right now this uses prefix notation. Ignore it. I'll make this into infix notation real soon. The goal of this (exprcomp and exprexec) is to have arbitrary logical expressions.
* Change getopt() to be more like schwarze@'s suggestions.Kristaps Dzonsons2011-11-091-5/+5
|
* Split apropos.c into db.c and apropos.h with simpler code (re-written, butKristaps Dzonsons2011-11-091-536/+24
| | | | | | | | | inspired by apropos.c and mandoc-tools' mandoc-cgi.c). This uses UTF-8 right now for its re-writing, but will soon accomodate for the regular suspects (this is a rather simple matter). I also introduce man.cgi (cgi.c), which is a standalone CGI that replaces mandoc-tools' mandoc.cgi. Right now it's just a framework.
* Make apropos results-gathering able to error out and clean up beforeKristaps Dzonsons2011-10-091-14/+16
| | | | making the utility exit non-zero.
* Remove some unnecessary variables and note that mchars_alloc never returnsKristaps Dzonsons2011-10-091-25/+7
| | | | NULL.
* Use a binary tree (for now, unbalanced) for deduping the records in theKristaps Dzonsons2011-10-091-5/+31
| | | | | | results array. This is much faster than the previous method, a linear search, at a small cost. Note that array offsets are used instead of storing the res pointer because we may realloc the results vector.
* Use mandoc_realloc() in apropos, as we're linking to libmandoc.a.Kristaps Dzonsons2011-10-081-4/+1
|
* Lift hard-coded limit of results.Kristaps Dzonsons2011-10-071-5/+7
|
* Clean up file a bit: remove errx and err function pointers from theKristaps Dzonsons2011-10-071-117/+97
| | | | | | state struct (directly using fprintf and perror to do this); add some in-line documentation; remove state init and destroy directly to the main function.
* Import apropos from mandoc-tools after inlining all source filesKristaps Dzonsons2011-10-061-0/+689
(originally including extern.h, state.c, and sort.c). The apropos utility interfaces with the databases of mandocdb to provide semantic searching capabilities. It Works For Me, but will need lots of cleanup in the coming months.