summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Optimize stradds() and putkeys() to not call ohash_qlookupi()Ingo Schwarze2013-06-061-44/+27
| | | | | | | and ohash_find() twice. As a bonus, this allows to drop hashget(). While here, rename index to slot to match the terminology in the ohash manual; it also prevents potential clashes with index(3). Drop the slot variable altogether where it is used only once.
* Drop wordaddbuf() which is identical to putkeys().Ingo Schwarze2013-06-061-21/+8
| | | | | Also rename straddbuf() to stradds() to be more similar to putkeys(). Just cleanup, no functional change.
* In dbopen(), check success of remove("mandoc.db~").Ingo Schwarze2013-06-061-21/+14
| | | | | While here, simplify dbopen() and dbclose(): No need for strlcpy() and strlcat() when dealing with constant strings only.
* In parse_catpage(), the comment saying that the filename would beIngo Schwarze2013-06-061-0/+1
| | | | | | used as a default page description if no usable NAME section was found was preserved when moving from db to sqlite, but the code line actually doing that was removed without replacement. So, put it back.
* The return value from parse_man() is completely unused,Ingo Schwarze2013-06-051-13/+9
| | | | so make the function void; no functional change.
* Two sanity checks got lost in treescan()Ingo Schwarze2013-06-051-29/+36
| | | | | | | | | during the switch from db to sqlite; restore these: * Warn and skip when directory and file name mismatch. * Warn and skip when finding special files. * Warning about "mandocdb.db" is useless, it is always present. * While here, do not hardcode "mandocdb.db", use MANDOC_DB.
* Add back the realpath() checks that got lost during the change fromIngo Schwarze2013-06-051-121/+159
| | | | | | | | | | | | | | | | | | db to sqlite; they are needed to prevent corruption of the database when paths containing dot, dotdot, or symlinks are given on the command line. Also make sure the exit-code is really non-zero on system errors and use mandoc(1) exit codes. To make all this simpler, * Drop the "basedir" argument from almost every function and make it global because it is really state info used all over the place. * Move "startdir" and "fd" as local vars into set_basedir() because they are only used for this one purpose, i.e. to move out of basedir again. While here, * Clarify the name of path_arg in the main program; in the -C case, it is not a dir, and anyway there are lots of different dirs around. * Include missing <stdio.h> needed for perror().
* Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from <sys/param.h>.Ingo Schwarze2013-06-051-16/+16
| | | | | | 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.
* Changing existing SQLite databases was utterly broken:Ingo Schwarze2013-06-031-1/+3
| | | | | 1) SQL statements were only prepared when creating a new database. 2) We rely heavily on foreign_keys, but never enabled them.
* Starting the preparations to integrate this into OpenBSD.Ingo Schwarze2013-06-031-43/+64
| | | | | | | | | | As variadic macros are not supported on all architectures, replace them by a real function. While here, * choose a more logical order for "dir" and "file" arguments * choose a more logical order when printing; as a bonus, a simple sed 's/:.*//' will get you valid file names * in ofmerge(), skip diagnostic string comparisons when we don't want warnings anyway
* Merge whatis.1 into apropos.1 (and remove), add whatis bits to aproposKristaps Dzonsons2012-06-091-1/+1
| | | | (via mansearch), and merge mandocdb.h into mansearch.h (and remove).
* Ths SYNCHRONOUS = off optimisation fails on my Mac OSX. Take it out untilKristaps Dzonsons2012-06-091-0/+2
| | | | I can test properly for this feature.
* Add a compatibility interface for ohash.Kristaps Dzonsons2012-06-091-2/+7
| | | | | | | | | | This include's espie@'s wholesale src/lib/libc/ohash directory from OpenBSD into compat_ohash.c (with a single copyright/license notice at the top) and src/include/ohash.h as compat_ohash.h. The ohash_int.h part of compat_ohash.c has been changed only in that ohash.h points to compat_ohash.h. Added HAVE_OHASH test (test-ohash.c) to Makefile. In mandocdb.c and mansearch.c, check HAVE_OHASH test for inclusion.
* Turn off sqlite3 synchronous mode when creating a new database.Kristaps Dzonsons2012-06-081-32/+48
| | | | | | This makes it run about 5x faster. While here, wrap some sqlite3 statements in #defines to extract errors. (Really, the warning/error/etc. macros should be functionified.)
* Use C99 syntax for declaring the string-hash key array.Kristaps Dzonsons2012-06-081-3/+3
|
* Re-tooled mandocdb using sqlite3 and ohash.Kristaps Dzonsons2012-06-081-1319/+1401
| | | | | | | | | | See the tech@ mailing list entries in June 2012 for details, as well as the discuss@ mailing list entries from March 2012. Among other changes, this utility now: 1. uses a single sqlite3 database instead of several berkeley dbs 2. stores utf-8 encoded strings 3. using ohash to aggressively hash its contents 4. using fts() instead of manually walking directories
* Support -Ios='OpenBSD 5.1' to override uname(3) as the source of theIngo Schwarze2012-05-271-1/+1
| | | | | | | | | | default value for the mdoc(7) .Os macro. Needed for man.cgi on the OpenBSD website. Problem with man.cgi first noticed by deraadt@; beck@ and deraadt@ agree with the way to solve the issue. "Please check them in and I'll look into them later!" kristaps@
* update Copyright years according to the CVS logs; no code changeIngo Schwarze2012-05-271-2/+2
|
* Being reluctant to add yet more trailing whitespace, i rather backIngo Schwarze2012-04-151-8/+8
| | | | it out here than merge it to OpenBSD. No binary change.
* Improve mandocdb's ability to handle NAME sections by sucking the entireKristaps Dzonsons2012-03-231-9/+57
| | | | | shebang into a buffer and parsing it that way. This improves on many cruddy -man manuals in the wild.
* Clean up code a bit by pushing warnings into WARNING macro.Kristaps Dzonsons2012-03-231-63/+48
|
* Merge some/most of schwarze@'s OpenBSD changes into mandoc: many moreKristaps Dzonsons2012-03-231-116/+158
| | | | | | | | | | | | | | | warnings about grokking manpages in their respective directories. DO NOT, however, import his temporary-file routines (I don't plan on staying with a recno/btree split) nor the realpath() routines, which destroy relative path-ness. Also pull in the lorder bits. There are some changes I started to make then stopped relating to reporting errors in the correct directories. I'll clean this up in subsequent commits. This puts us more or less on parity with OpenBSD.
* When parsing catpages, read from the first section (NAME, we hope) untilKristaps Dzonsons2011-12-311-15/+43
| | | | | the next section. Also, remove the limit of 72 characters and enforce this, instead in the apropos frontend.
* Do not skip manuals shared across architectures when building databases.Ingo Schwarze2011-12-281-3/+18
|
* First memory leak in mandocdb.c freeing "struct of". Also properlyKristaps Dzonsons2011-12-251-2/+7
| | | | const-ify several strings.
* Use the traditional name "whatis.db" for the mandocdb(8) databases.Ingo Schwarze2011-12-251-1/+1
| | | | Requested by deraadt@, ok kristaps@.
* For binary compatability of the databases across architectures,Ingo Schwarze2011-12-251-8/+8
| | | | | | | use pointers to arrays, not pointers to structs. It is now possible to create databases on sparc64 and use them on i386 and vice versa. Kristaps@ can't think of anything else that might be required, either. Put this in now such that we can move on.
* Implement test mode (makewhatis -t), required for pkg_create(8).Ingo Schwarze2011-12-251-212/+328
| | | | | | | | | | | | Always do all consistency checks; when any one fails, decide whether to print a message, or skip the file, or both, or none. While here, do some cleanup as well: * Bail out on conflicting options. * Do not crash with -a if there are plain files in the root dir. * Collect some related variables into structs. Feedback and OK kristaps@.
* Do not cast void pointers to pointers requiring alignment.Ingo Schwarze2011-12-201-4/+12
| | | | | | | | | This makes mandocdb(8)/apropos(1) work on strict alignment architectures. Basic way to fix this confirmed by deraadt@ and kettenis@, thanks. ok kristaps@ This now works on both sparc64 and i386, but note that the binary database format is still machine-dependent.
* Make the stored "cat"/"mdoc"/"man" strings just be c/d/a single-characterKristaps Dzonsons2011-12-161-8/+6
| | | | | bytes. This cuts down a little in index size and allows for cleaner extraction of information.
* Make paths in the mandocdb(8) index relative to the databases' pathKristaps Dzonsons2011-12-161-42/+34
| | | | | | | prefix. This means that an index in, say, /usr/share/man will point to man1/foo.1 instead of /usr/share/man/man1/foo.1. Not only does this save a lot of space, it also allows manual trees to be moved around without any side effects to the mandocdb(8) databases.
* implement -C (alternative config file) for apropos(1) and mandocdb(8),Ingo Schwarze2011-12-121-5/+11
| | | | | including various tweaks to the whatis(8) manual; ok kristaps@
* Avoid leaking index records:Ingo Schwarze2011-12-101-20/+24
| | | | | Before allocating a record for a file, first make sure we actually want to use the file.
* Fix selection of arch-specific manuals:Ingo Schwarze2011-12-101-2/+6
| | | | | | (1) Correctly compare cat vs. man paths. (2) Compare arch (and section) names case-insensitively. Problem noticed by kristaps@.
* Tweak pformatted():Ingo Schwarze2011-12-091-12/+13
| | | | | | | * If the first section is empty, use the file name as .Nd. * No need to check (len > 0) after successful fgetln(3). * Improve some comments and strip trailing whitespace. ok kristaps@
* Considerably tidy mandocdb(8) catman descriptions by skipping to the firstKristaps Dzonsons2011-12-091-2/+2
| | | | hyphen-space combo, not the last hyphen as done previously.
* Strip backspace encoding from preformatted manuals. This cleans up a lotKristaps Dzonsons2011-12-091-0/+12
| | | | of catpage entries in the mandoc databases.
* Clean up grok of preformatted manual description.Kristaps Dzonsons2011-12-081-28/+35
| | | | | | (1) put fclose() at the end, as line isn't valid afterward (see fgetln()) (2) clean up loops to be more readable to my old eyes (3) mandate trailing newline, nul-terminate, and use strrchr
* index_prune always counted the free slots,Ingo Schwarze2011-12-081-9/+9
| | | | but didn't tell anybody about them, so they weren't reused
* If arguments are passed to mandocdb(8) in "default" mode, then useKristaps Dzonsons2011-12-081-4/+11
| | | | | realpath() to convert them into absolute paths before putting the traversed subdirectory filenames into the index.
* Implement search support for 24 additional macros, extract more informationIngo Schwarze2011-12-071-299/+252
| | | | | | from Fn, and lift section restrictions from An Cd Er Ev Fn Fo In Pa St Va Vt by removing 4 handler functions and 50 lines of code. ok kristaps@
* Fix parsing of file names given on the command line; i broke itIngo Schwarze2011-12-041-4/+3
| | | | when adding support for formatted manual pages.
* Back out lorder, which doesn't seem necessary (?). I think this means allKristaps Dzonsons2011-12-031-1/+0
| | | | fields are endian-neutral, although the recno(3) key is unknown.
* Make sure the btree(3) goop is also BE. This covers both the DB metadataKristaps Dzonsons2011-12-031-0/+1
| | | | and prior commits handle the contained binary fields.
* This is a little gross: Linux and Apple need lots some cajoling to workKristaps Dzonsons2011-12-021-1/+5
| | | | | | | | with byte-swapping. Tested on Mac. Any Linux machines somebody can test on? Anybody? While here, note the correct byte-size in mandocdb(8) and also note field widths and endianness. The btree is now endian-neutral.
* Use OpenBSD's endian functions. Make btree type also be endian-neutral.Kristaps Dzonsons2011-12-011-5/+3
|
* In apropos_db.c, move all btree reading (and safety checks) into theKristaps Dzonsons2011-12-011-4/+4
| | | | | | | | btree_read() function. Also, add a forgotten free() for the type of grokked record. Then in both mandocdb.c and apropos_db.c, make the "rec" field of the btree by in network-order.
* Fix mandocdb(8) to pass over the type when pruning the database. ThisKristaps Dzonsons2011-12-011-25/+53
| | | | | | fixed `-d' perpetually adding the same files. While here, clean up the code and document it. Remove -vv (complain if you want it back in). Document the error messages in a DIAGNOSTICS section of mandocdb(8).
* chdir(2) to the right man page tree before parsing manuals;Ingo Schwarze2011-11-291-1/+17
| | | | ok kristaps@
* Reimplement the global command line options -a and -vIngo Schwarze2011-11-271-26/+20
| | | | | | as static global variables, reducing the maze of arguments passed around among various static functions. Suggested by kristaps@.