aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
Commit message (Collapse)AuthorAgeFilesLines
* Audit malloc(3)/calloc(3)/realloc(3) in VERSION_1_12.Ingo Schwarze2014-04-231-3/+3
|
* backport man(7) .Nd improvementIngo Schwarze2014-03-231-46/+9
|
* introduce mandoc_aux to 1.12Ingo Schwarze2014-03-231-1/+2
|
* cope with the mparse_result() interface changeIngo Schwarze2014-03-191-2/+2
|
* cope with mparse_alloc() interface changeIngo Schwarze2014-03-191-5/+5
|
* Cope with the mparse_alloc() interface change.Ingo Schwarze2014-01-051-4/+9
|
* My audit of mandoc revealed one missing (unsigned char) castIngo Schwarze2013-11-211-2/+2
| | | | | in a tolower() argument containing arbitrary char data. Thanks to deraadt@ for triggering the audit.
* On __sun, use <sys/byteorder.h>, BE_64(x), and <db_185.h>.Ingo Schwarze2013-10-101-9/+11
| | | | | | | Thanks to Thomas Klausner <wiz at NetBSD dot org> for providing failing SmartOS build logs such that i could write this patch without access to a __sun system and for confirming that these patches help.
* Cleanup suggested by gcc-4.8.1, following hints by Christos Zoulas:Ingo Schwarze2013-10-051-2/+4
| | | | | | | | - avoid bad qualifier casting in roff.c, roff_parsetext() by changing the mandoc_escape arguments to "const char const **" - avoid bad qualifier casting in mandocdb.c, index_merge() - do not complain about unused variables in test-*.c - garbage collect a few unused variables elsewhere
* DragonFly needs explicit #include <sys/endian.h> to use be64toh(),Ingo Schwarze2013-10-021-1/+2
| | | | | while most other systems include that indirectly via <sys/types.h>. Reported by Franco Fichtner <franco at lastsummer dot de>.
* Fix build on Solaris.Ingo Schwarze2013-10-011-2/+18
| | | | | | | Initial version for SmartOS by ONODERA Ryo <ryoon at netbsd dot org>. Generalized for Solaris by Jonathan Perkin <jperkin at netbsd dot org>. Received via Thomas Klausner <wiz at netbsd dot org>. Style cleanup by myself.
* Fix typo in filenames: mandocdb.{db,index} -> mandoc.{db,index}Ingo Schwarze2013-09-181-2/+2
|
* Merge OpenBSD rev. 1.43:Ingo Schwarze2013-09-171-5/+5
| | | | | Kristaps changed the size member of struct manpaths from int to size_t. No functional change.
* Merge OpenBSD rev. 1.34.Ingo Schwarze2013-09-171-13/+52
| | | | | Do not truncate the production database when starting to build a new one. Suggested by deraadt@.
* merge OpenBSD rev. 1.41:Ingo Schwarze2013-09-171-92/+137
| | | | backout non-portable code
* Similar to rev. 1.58:Ingo Schwarze2013-09-171-1601/+1433
| | | | Consistently use the PATH_MAX since it is specified by POSIX.
* For the strings table, ohash_init is only called in ofmerge(),Ingo Schwarze2013-07-021-17/+16
| | | | | so move the str_info structure into that function. No functional change.
* Turning off synchronous mode logically belongs to opening the database,Ingo Schwarze2013-07-021-10/+12
| | | | so move the statement into the function dbopen().
* Restore the check whether each page added to the databaseIngo Schwarze2013-07-021-19/+87
| | | | | is actually reachable by man(1). This check got lost when the database backend was changed from Berkeley to sqlite.
* The mdoc_handler flags are unused and will never be used.Ingo Schwarze2013-06-071-127/+124
| | | | | Having a mask is sufficient to trigger putmdockey. Simplify by dropping the flags; no functional change.
* In .Xr database entries, mention the manual section again;Ingo Schwarze2013-06-071-3/+14
| | | | | the section was dropped when switching from db to sqlite. Use the customary format foo(N).
* The string hash table is only needed to combine multiple occurencesIngo Schwarze2013-06-071-110/+68
| | | | | | | | | | | | | | | | | | | | | | of the same string within the same manual, so initialize and purge it for each manual in ofmerge() instead of one single time in main(). There is no point in saving manual names and descriptions in that table because each of them occurs only once, or very few times. The is no point in saving section numbers there because they are so much shorter than the descriptions. Testing with the complete tree /usr/share/man/ on my notebook shows that this change slightly reduces memory consumption by about 20% while there is no measurable difference in execution time. As a bonus, this allows to delete the functions stradd() and stradds(), the "next" member from struct str, and the global struct str *words. While adapting the places in the code using stradd(), i noticed that parsing of the mdoc(7) .Nd macro was completely broken and that for formatted manual pages with unusable NAME section, the description was never set in the struct of. This commit fixes both bugs as well.
* Optimize stradds() and putkeys() to not call ohash_qlookupi()Ingo Schwarze2013-06-061-45/+28
| | | | | | | 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-22/+9
| | | | | 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-22/+15
| | | | | 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-1/+2
| | | | | | 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-14/+10
| | | | so make the function void; no functional change.
* Two sanity checks got lost in treescan()Ingo Schwarze2013-06-051-30/+37
| | | | | | | | | 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-122/+160
| | | | | | | | | | | | | | | | | | 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-17/+17
| | | | | | 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-2/+4
| | | | | 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-44/+65
| | | | | | | | | | 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-2/+2
| | | | (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-1/+3
| | | | I can test properly for this feature.
* Add a compatibility interface for ohash.Kristaps Dzonsons2012-06-091-3/+8
| | | | | | | | | | 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-33/+49
| | | | | | 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-4/+4
|
* Re-tooled mandocdb using sqlite3 and ohash.Kristaps Dzonsons2012-06-081-1320/+1402
| | | | | | | | | | 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-2/+2
| | | | | | | | | | 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-3/+3
|
* Being reluctant to add yet more trailing whitespace, i rather backIngo Schwarze2012-04-151-9/+9
| | | | 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-10/+58
| | | | | 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-64/+49
|
* Merge some/most of schwarze@'s OpenBSD changes into mandoc: many moreKristaps Dzonsons2012-03-231-117/+159
| | | | | | | | | | | | | | | 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-16/+44
| | | | | 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-4/+19
|
* First memory leak in mandocdb.c freeing "struct of". Also properlyKristaps Dzonsons2011-12-251-3/+8
| | | | const-ify several strings.
* Use the traditional name "whatis.db" for the mandocdb(8) databases.Ingo Schwarze2011-12-251-2/+2
| | | | Requested by deraadt@, ok kristaps@.
* For binary compatability of the databases across architectures,Ingo Schwarze2011-12-251-9/+9
| | | | | | | 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-213/+329
| | | | | | | | | | | | 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@.