summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve rev. 1.250 further:Ingo Schwarze2017-07-151-1/+1
| | | | | | | | If a database is empty, we already don't write a database file and delete an existing one. If none exists, that only means the database was empty and remains so, which is not an error. So don't nag about it, in particular because that would be a weekly(8) annoyance. Issue reported by jmc@.
* Split -Wstyle into -Wstyle and the even lower -Wbase, and addIngo Schwarze2017-06-241-1/+2
| | | | | | | | | | | | | | | -Wopenbsd and -Wnetbsd to check conventions for the base system of a specific operating system. Mark operating system specific messages with "(OpenBSD)" at the end. Please use just "-Tlint" to check base system manuals (defaulting to -Wall, which is now -Wbase), but prefer "-Tlint -Wstyle" for the manuals of portable software projects you maintain that are not part of OpenBSD base, to avoid bogus recommendations about base system conventions that do not apply. Issue originally reported by semarie@, solution using an idea from tedu@, discussed with jmc@ and jca@.
* Never create empty databases.Ingo Schwarze2017-05-171-0/+22
| | | | | | | | | | When pkg_add(1)ing packages installing manual pages into some directory, the database in that directory automatically gets created or updated, no change so far. This patch causes the database file to be automatically unlinked when pkg_delete(1)ing the last package having manual pages in that directory, to leave less cruft behind. Suggested by ajacoutot@.
* Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze2017-05-051-1/+0
| | | | now that this actually saves code: -70 LOC.
* move .ll to the roff modulesIngo Schwarze2017-05-051-1/+0
|
* Parser reorg:Ingo Schwarze2017-05-041-2/+4
| | | | | Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
* Continue parser unification:Ingo Schwarze2017-04-241-9/+8
| | | | | | | | * Make enum rofft an internal interface as enum roff_tok in "roff.h". * Represent mdoc and man macros in enum roff_tok. * Make TOKEN_NONE a proper enum value and use it throughout. * Put the prologue macros first in the macro tables. * Unify mdoc_macroname[] and man_macroname[] into roff_name[].
* Fix a copy-and-paste error that caused man(7) manuals withoutIngo Schwarze2017-03-031-1/+1
| | | | | a section number in .TH to be misinterpreted as preformatted. Found by jsg@ with cppcheck.
* No need to cast NULL when assigning it to a variable;Ingo Schwarze2017-02-171-1/+1
| | | | from Christos Zoulas <christos at NetBSD>.
* Be consistent in protecting __attribute__ attributes with __;Ingo Schwarze2017-02-171-1/+1
| | | | from Christos Zoulas <christos @ NetBSD>.
* warn about missing one-line description;Ingo Schwarze2017-01-271-3/+8
| | | | missing feature found in the TODO file
* Parse the section number from the content of preformatted pagesIngo Schwarze2017-01-271-13/+30
| | | | and warn if it doesn't match the directory where the file was found.
* If parsing a page reveals that it is neither mdoc(7) nor man(7),Ingo Schwarze2017-01-271-12/+16
| | | | | fall back to treating it as preformatted rather than treating it as man(7) anyway.
* fix base directory detection for makewhatis -tIngo Schwarze2017-01-271-0/+14
|
* Always register names taken from file names in the names ohash.Ingo Schwarze2017-01-271-4/+6
| | | | Bug found by makewhatis -p crashing in mlink_check().
* Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze2017-01-111-2/+2
| | | | | | | | | rather than in the formatters. Use NODE_NOSRC flag for .Lb and NODE_NOSRC and NODE_NOPRT for .St. Results in a more rigorous syntax tree and in 135 lines less code. This work was triggered by a question from Abhinav Upadhyay <er dot abhinav dot upadhyay at gmail dot com> (NetBSD) on discuss@.
* Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze2017-01-101-2/+2
| | | | More rigorous AST and 40 lines less code.
* For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze2017-01-101-130/+135
| | | | | stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
* cast off_t and uint64_t for printf(3)Ingo Schwarze2016-10-221-1/+2
| | | | | | to make sure that widths match on all platforms; from Ed Maste <emaste at freebsd dot org>; OK guenther@
* 0x%llu is a bad idea, make that 0x%llx;Ingo Schwarze2016-10-201-1/+1
| | | | noticed while investigating a report from Ed Maste
* Compat glue for the FreeBSD comparison function prototype for fts_open(3)Ingo Schwarze2016-10-181-0/+8
| | | | | which differs from what most other systems use. While here, improve diagnostic output of ./configure tests.
* Simplify and correct support for reproducible builds, such that databaseIngo Schwarze2016-10-181-35/+25
| | | | | | | | | | entries come in a well-defined order even in the presence of MLINKS. Do this by using the compar() argument of fts_open(3) rather than trying to sort later, which missed some cases. This also shortens the code by a few lines. Diff from Ed Maste <emaste @ FreeBSD>, adapted to our tree and tweaked a bit by me, final version confirmed by Ed.
* When "makewhatis -d" tries to add to a database that doesn't (yet) exist,Ingo Schwarze2016-09-021-3/+3
| | | | | | | silently create it from scratch instead of printing a warning. The annoying warning message was reported by ajacoutot@, and espie@ convincingly argues that a non-existing database can be considered equivalent to an empty one.
* remove "sparc" from a commentIngo Schwarze2016-09-011-1/+1
|
* When trying to edit an existing database with makewhatis(8) -d or -uIngo Schwarze2016-08-221-4/+4
| | | | | | | but reading the database fails, report the full path to the database on standard error, and mention that the database is automatically recreated from scratch. Suggested by espie@.
* When the content of a manual page does not specify a section, theIngo Schwarze2016-08-171-1/+2
| | | | | | | | empty string got added to the list of sections, breaking the database format slightly and causing the page to not be considered part of any section, not even if a section could be deduced from the directory or from the file name. Bug found due to the bogus pcredemo(3) "manual" in the pcre-8.38p0 package.
* fix a typo that prevented names from .Dt from getting priorityIngo Schwarze2016-08-051-1/+1
| | | | over names from .Sh NAME
* Repair makewhatis -t, regression in rev. 1.221 reported by naddy@.Ingo Schwarze2016-08-011-2/+3
|
* Sort pages in the pages table by file names.Ingo Schwarze2016-07-291-7/+26
|
* No need to populate the TYPE_arch and TYPE_sec bits, the informationIngo Schwarze2016-07-291-24/+7
| | | | | | | | | | | | is provided directly to dba_page_add() in dbadd_mlink() and to dba_page_new() in dbadd(). No need for a dedicated loop for NAME_FILE. It's done in dbadd_mlink() anyway. In this context, also record section numbers taken from filenames and from .Dt and .TH macros, architectures taken from .Dt macros, and fix the filtering of duplicate filename entries.
* Now that our man.conf(5) format is mature and extremely simple,Ingo Schwarze2016-07-191-2/+1
| | | | | | | | delete manpath(1) support. With the mandoc-based man(1), manpath(1) is utterly useless. Just set MANPATH_DEFAULT in configure.local for sane operating system defaults, use man.conf(5) for machine- specific modifications, and use ${MANPATH}, -m, and -M for user preferences.
* Remove the dependency on SQLite without loss of functionality.Ingo Schwarze2016-07-191-368/+91
| | | | | Stop supporting systems that don't have mmap(3). Drop the obsolete names_check() now that we deleted MLINKS.
* Use __attribute__((__format__ throughout.Ingo Schwarze2016-07-191-3/+4
| | | | | | | Triggered by a smaller patch from Christos Zoulas. While here, unify style, move several config tests to config.h, and delete the useless MANDOC_CONFIG_H.
* add missing prototypes, no code change;Ingo Schwarze2016-07-151-0/+3
| | | | noticed by Christos Zoulas with -Wmissing-prototypes
* Add support for Mac OS X's sandbox_init(3) sandbox functionality, whichKristaps Dzonsons2016-07-121-0/+10
| | | | | | | is marked as DEPRECATED in OS X after 2011 or so, but has not been removed and has no replacement. ok schwarze@
* getopt(3) is declared in <unistd.h>, and <getopt.h> is not needed;Ingo Schwarze2016-07-091-1/+0
| | | | from Joerg Sonnenberger via Thomas Klausner, NetBSD.
* 'accomodate' -> 'accommodate' in a comment.Ingo Schwarze2016-03-171-1/+1
| | | | From krw@, started by a diff from Mical Mazurek.
* Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze2016-01-081-8/+9
| | | | | | | | most uses by one, a few by two pointer checks, and only one by a tiny loop - not only making data smaller, but code shorter as well. This gets rid of an implicit invariant that confused both static analysis tools and human auditors. No functional change.
* Prefer warn(3) over perror(3) at the few places where it was used.Ingo Schwarze2016-01-081-3/+3
| | | | | It is useful to see the program name, and we have err.h compat in place anyway. Suggested by Christos Zoulas (NetBSD).
* Simplify the mparse_open() interface.Ingo Schwarze2016-01-081-2/+1
| | | | | | Just return the file descriptor or -1 on error; there is just one kind of error anyway. Suggested by Christos Zoulas (NetBSD).
* It was very surprising that a function called mparse_readfd()Ingo Schwarze2016-01-081-0/+1
| | | | | | | | | | | | | closed the file descriptor passed to it after completing its work, in particular considering the fact that it required its callers to call open(2) or mparse_open() beforehand. Change mparse_readfd() to not call close(2) and change the callers to call close(2) afterwards, more or less bringing open and close to the same level of the code and making review easier. Note that man.cgi(8) already did that, even though it was wrong in the past. Small restructuring suggested by Christos Zoulas (NetBSD).
* Improve handling of .Va and .Vt macros.Ingo Schwarze2016-01-041-13/+28
| | | | | | | tedu@ noticed that no Vt= database entries were generated. Serguey Parkhomovsky suggested the deletion of parse_mdoc_body(). tb@ noticed that the fix requires more than just adding TYPE_Vt to the MDOC_Vt mask in the mdoc_handler array.
* pledge(2) style:Ingo Schwarze2015-12-151-8/+11
| | | | | | | Make sure to always use the idiom 'if (pledge("' such that it can easily be searched for. No functional change. Requested by deraadt@ some time ago.
* Modernization, no functional change intended:Ingo Schwarze2015-11-071-17/+21
| | | | | | Use the POSIX function getline(3) rather than the slightly dangerous BSD function fgetln(3). Remove the related compatibility code.
* Without HAVE_ERR, don't try to include <err.h>, it probably isn't there.Ingo Schwarze2015-11-071-0/+2
| | | | | In that case, the required prototypes are in "config.h". Patch from Peter Bray <pdb_ml at yahoo dot com dot au>.
* merge pledge(2) support from OpenBSDIngo Schwarze2015-11-061-0/+22
|
* Use getprogname(3) rather than __progname.Ingo Schwarze2015-11-061-5/+3
| | | | | | | Suggested by Joerg@ Sonnenberger (NetBSD). Last year, deraadt@ confirmed on tech@ that this "has the potential to be more portable", and micro-optimizing for speed is not relevant here. Also gets rid of one global variable.
* use the new function man_validate() here, tooIngo Schwarze2015-10-221-0/+1
|
* In order to become able to generate syntax tree nodes on the roff(7)Ingo Schwarze2015-10-201-0/+1
| | | | | | | | level, validation must be separated from parsing and rewinding. This first big step moves calling of the mdoc(7) post_*() functions out of the parser loop into their own mdoc_validate() pass, while using a new mdoc_state() module to make syntax tree state handling available to both the parser loop and the validation pass.
* Major character table cleanup:Ingo Schwarze2015-10-131-7/+5
| | | | | | | | | | | | | * Use ohash(3) rather than a hand-rolled hash table. * Make the character table static in the chars.c module: There is no need to pass a pointer around, we most certainly never want to use two different character tables concurrently. * No need to keep the characters in a separate file chars.in; that merely encourages downstream porters to mess with them. * Sort the characters to agree with the mandoc_chars(7) manual page. * Specify Unicode codepoints in hex, not decimal (that's the detail that originally triggered this patch). No functional change, minus 100 LOC, and i don't see a performance change.