summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mandocdb.c
AgeCommit message (Collapse)Author
2018-12-14Major cleanup; may imply minor changes in edge cases of error reporting.Ingo Schwarze
Finally, drop support for the run-time configurable mandocmsg() callback. It was over-engineered from the start, never used for anything in a decade, and repeatedly caused maintenance headaches. Consolidate reporting infrastructure into two files, mandoc.h and mandoc_msg.c, mopping up the bits and pieces that were scattered around main.c, read.c, mandoc_parse.h, libmandoc.h, the prototypes of four parsing-related functions, and both parser structs.
2018-12-13Cleanup, no functional change:Ingo Schwarze
Split the top level parser interface out of the utility header mandoc.h, into a new header mandoc_parse.h, for use in the main program and in the main parser only. Move enum mandoc_os into roff.h because struct roff_man is the place where it is stored. This allows removal of mandoc.h from seven files in low-level parsers and in formatters.
2018-08-17Remove more pointer arithmetic passing via regions outside the arrayIngo Schwarze
that is undefined according to the C standard. Robert Elz <kre at munnari dot oz dot au> pointed out i wasn't quite done yet.
2018-02-23Logically, the following are are type names - just like .Vt,Ingo Schwarze
some of them with an optional variable name following: - .Ft - .Fa in the SYNOPSIS - .Fn second and later arguments in the SYNOPSIS So add these to the .Vt macro table in the mandoc.db(5) database. During my LibreSSL work, i'm getting really tired of typing $ man -k Vt,Ft,Fa=some_type_name over and over again; now, this becomes just: $ man -k Vt=some_type_name
2018-02-07In man(7) and cat pages, cut off excessive one line descriptions.Ingo Schwarze
An extreme example of how rogue files could mess up apropos(1) output was reported by bentley@: qwtlicense(3) in the x11/qwt port.
2017-08-26Fix previous: mmap(2) returns MAP_FAILED on failure, not NULL.Ingo Schwarze
Bug pointed out by tedu@.
2017-08-26Do not fork and exec cmp(1); instead, simply fstat(2), mmap(2), andIngo Schwarze
compare the files directly, allowing a much stricter pledge(2), at very little cost: merely 15 additional lines of very simple code. Suggested by George Brown <321 dot george at gmail dot com> on misc@.
2017-08-26No need to fork and exec rm(1) -rf, we know that we have exactlyIngo Schwarze
one file and exactly one directory to remove. While here, increase the size of the buffer such that the file name actually fits. Minus 17 lines of code, no functional change. Opportunity for simplification reported by George Brown <321 dot george at gmail dot com> on misc@.
2017-07-28When the mparse_alloc() prototype changed in read.c 1.151, updatingIngo Schwarze
the enum constant was forgotten in this call. No functional change since the mmsg argument is NULL anyway. Found by florian@ with clang.
2017-07-15Improve rev. 1.199 further:Ingo Schwarze
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@.
2017-06-24Split -Wstyle into -Wstyle and the even lower -Wbase, and addIngo Schwarze
-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@.
2017-05-17Never create empty databases.Ingo Schwarze
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@.
2017-05-05Move .sp to the roff modules. Enough infrastructure is in placeIngo Schwarze
now that this actually saves code: -70 LOC.
2017-05-05move .ll to the roff modulesIngo Schwarze
2017-05-04Parser reorg:Ingo Schwarze
Generate the first node on the roff level: .br Fix some column numbers in diagnostic messages while here.
2017-04-24Continue parser unification:Ingo Schwarze
* 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[].
2017-03-03Fix a copy-and-paste error that caused man(7) manuals withoutIngo Schwarze
a section number in .TH to be misinterpreted as preformatted. Found by jsg@ with cppcheck.
2017-02-09No need to cast NULL when assigning it to a variable;Ingo Schwarze
from Christos Zoulas <christos at NetBSD>.
2017-02-09Be consistent in protecting __attribute__ attributes with __;Ingo Schwarze
from Christos Zoulas <christos @ NetBSD>.
2017-01-27warn about missing one-line description;Ingo Schwarze
missing feature found in the TODO file
2017-01-27Parse the section number from the content of preformatted pagesIngo Schwarze
and warn if it doesn't match the directory where the file was found.
2017-01-27If parsing a page reveals that it is neither mdoc(7) nor man(7),Ingo Schwarze
fall back to treating it as preformatted rather than treating it as man(7) anyway.
2017-01-27fix base directory detection for makewhatis -tIngo Schwarze
2017-01-27Always register names taken from file names in the names ohash.Ingo Schwarze
Bug found by makewhatis -p crashing in mlink_check().
2017-01-11Do text production for .Bt, .Ex, .Rv, .Ud at the validation stageIngo Schwarze
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@.
2017-01-10Use new NODE_NOSRC and NODE_NOPRT flags for .Bx and .At.Ingo Schwarze
More rigorous AST and 40 lines less code.
2017-01-10For the .Ux/.Ox family of macros, do text production at the validationIngo Schwarze
stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
2016-10-22cast off_t and uint64_t for printf(3)Ingo Schwarze
to make sure that widths match on all platforms; from Ed Maste <emaste at freebsd dot org>; OK guenther@
2016-10-200x%llu is a bad idea, make that 0x%llx;Ingo Schwarze
noticed while investigating a report from Ed Maste
2016-10-18Fix a comment: We don't have manpath(1). No code change.Ingo Schwarze
2016-10-18Simplify and correct support for reproducible builds, such that databaseIngo Schwarze
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.
2016-09-02When "makewhatis -d" tries to add to a database that doesn't (yet) exist,Ingo Schwarze
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.
2016-09-01remove "sparc" from a commentIngo Schwarze
2016-08-22When trying to edit an existing database with makewhatis(8) -d or -uIngo Schwarze
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@.
2016-08-17When the content of a manual page does not specify a section, theIngo Schwarze
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.
2016-08-05fix a typo that prevented names from .Dt from getting priority overIngo Schwarze
names from .Sh NAME; no dire consequences on OpenBSD since we no longer have MLINKS for mdoc(7) pages
2016-08-01Repair makewhatis -t, sorry for breaking it in the previous commit.Ingo Schwarze
Committing this quickly because it hurts package builders. Regression reported by naddy@.
2016-08-01Remove the dependency on SQLite without loss of functionality.Ingo Schwarze
Drop the obsolete names_check() now that we deleted MLINKS. Run "doas makewhatis" after compiling and installing this. Earlier version tested by jmc@ and jturner@; "commit it all" deraadt@ "commit and dodge" krw@
2016-07-19Use __attribute__((__format__ throughout.Ingo Schwarze
Triggered by a smaller patch from Christos Zoulas.
2016-07-15add missing prototypes, no code change;Ingo Schwarze
noticed by Christos Zoulas with -Wmissing-prototypes
2016-07-09getopt(3) is declared in <unistd.h>, and <getopt.h> is not needed;Ingo Schwarze
from Joerg Sonnenberger via Thomas Klausner, NetBSD.
2016-03-15'accomodate' -> 'accommodate' in comments.Kenneth R Westerback
Started by diff from Mical Mazurek.
2016-01-08Delete the redundant "nchild" member of struct roff_node, replacingIngo Schwarze
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.
2016-01-08Prefer warn(3) over perror(3) at the few places where it was used.Ingo Schwarze
It is useful to see the program name. Suggested by Christos Zoulas (NetBSD).
2016-01-08Simplify the mparse_open() interface.Ingo Schwarze
Just return the file descriptor or -1 on error; there is just one kind of error anyway. Suggested by Christos Zoulas (NetBSD).
2016-01-08It was very surprising that a function called mparse_readfd()Ingo Schwarze
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).
2016-01-04Improve handling of .Va and .Vt macros.Ingo Schwarze
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.
2015-12-15pledge(2) style:Ingo Schwarze
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.
2015-11-07Modernization, no functional change intended:Ingo Schwarze
Use the POSIX function getline(3) rather than the slightly dangerous BSD function fgetln(3).
2015-11-06Use getprogname(3) rather than __progname.Ingo Schwarze
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.