aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
Commit message (Collapse)AuthorAgeFilesLines
* use the new function man_validate() here, tooIngo Schwarze2015-10-221-1/+2
|
* In order to become able to generate syntax tree nodes on the roff(7)Ingo Schwarze2015-10-201-1/+2
| | | | | | | | 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-8/+6
| | | | | | | | | | | | | * 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.
* Reduce the amount of code by moving the three copies of the ohashIngo Schwarze2015-10-131-52/+10
| | | | | callback functions into one common place, preparing for the use of ohash for some additional purposes. No functional change.
* Garbage collect an unused variable, no functional change;Ingo Schwarze2015-10-121-4/+3
| | | | found by Svyatoslav Mishyn <juef at openmailbox dot org> with cppcheck.
* Clear dform and dsec when exiting a first-level directory in treescan().Ingo Schwarze2015-10-121-20/+23
| | | | | Fixes a segfault reported by bentley@. While here, do some style cleanup in the same function.
* To make the code more readable, delete 283 /* FALLTHROUGH */ commentsIngo Schwarze2015-10-121-7/+1
| | | | | | that were right between two adjacent case statement. Keep only those 24 where the first case actually executes some code before falling through to the next case.
* Finally use __progname, err(3) and warn(3).Ingo Schwarze2015-10-111-17/+10
| | | | | | | | | | That's more readable and less error-prone than fumbling around with argv[0], fprintf(3), strerror(3), perror(3), and exit(3). It's a bad idea to boycott good interfaces merely because standards committees ignore them. Instead, let's provide compatibility modules for archaic systems (like commercial Solaris) that still don't have them. The compat module has an UCB Copyright (c) 1993...
* modernize style: "return" is not a functionIngo Schwarze2015-10-061-43/+43
|
* for portability, use (char *)NULL in execlp(3) as discussed on tech@ OpenBSDIngo Schwarze2015-09-161-3/+3
| | | | (didn't blow up anywhere yet, but better safe than sorry)
* Do not fork and exec gunzip(1), just link with libz instead.Ingo Schwarze2015-07-191-5/+1
| | | | | | | As discussed with deraadt@, that's cleaner and will help tame(2). Something like this was also suggested earlier by bapt at FreeBSD. Minus 50 lines of code, deleting one interface function (mparse_wait), no functional change intended.
* Unify mdoc_deroff() and man_deroff() into a common function deroff().Ingo Schwarze2015-04-231-3/+3
| | | | | | | | No functional change except that for mdoc(7), it now skips leading escape sequences just like it already did for man(7). Escape sequences rarely occur in mdoc(7) code and if they do, skipping them is an improvement in this context. Minus 30 lines of code.
* Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),Ingo Schwarze2015-04-181-9/+8
| | | | | | man_node() from the mandoc(3) semi-public interface and the internal wrapper functions print_mdoc() and print_man() from the HTML formatters. Minus 60 lines of code, no functional change.
* Profit from the unified struct roff_man and reduce the number ofIngo Schwarze2015-04-181-11/+9
| | | | | arguments of mparse_result() by one. No functional change. Written on the ICE Bruxelles-Koeln on the way back from p2k15.
* Replace the structs mdoc and man by a unified struct roff_man.Ingo Schwarze2015-04-181-3/+3
| | | | | Almost completely mechanical, no functional change. Written on the train from Exeter to London returning from p2k15.
* Third step towards parser unification:Ingo Schwarze2015-04-021-24/+24
| | | | | Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta. Written of the train from London to Exeter on the way to p2k15.
* Second step towards parser unification:Ingo Schwarze2015-04-021-29/+29
| | | | | | | | | Replace struct mdoc_node and struct man_node by a unified struct roff_node. To be able to use the tok member for both mdoc(7) and man(7) without defining all the macros in roff.h, sacrifice a tiny bit of type safety and make tok an int rather than an enum. Almost mechanical, no functional change. Written on the Eurostar from Bruxelles to London on the way to p2k15.
* First step towards parser unification:Ingo Schwarze2015-04-021-23/+24
| | | | | | Replace enum mdoc_type and enum man_type by a unified enum roff_type. Almost mechanical, no functional change. Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.
* Parse the new man.conf(5) "output" directive.Ingo Schwarze2015-03-271-23/+23
| | | | The next step will be to actually use the parsed data.
* Fix hardlink detection on platforms having padding in struct inodev,Ingo Schwarze2015-03-131-1/+2
| | | | | | typically 64bit platforms. This was basically broken since forever. Not only is the padding used, but it was used uninitialized. Problem reported by jmc@.
* When makewhatis(8) scans a tree, ignore trailing garbage on filenames.Ingo Schwarze2015-02-271-2/+3
| | | | | | | | | | This is relevant because some ports install files like man1/xsel.1x, as reported by patrick keshishian <pkeshish at gmail dot com> on misc@. We can probably improve functionality and simplify the code by ignoring file name extensions altogether; we already know the section number from the name of the directory. But so close to lock, i'm keeping the fix minimal.
* Support homebrew-style linking on Mac OS X.Ingo Schwarze2015-01-211-2/+10
| | | | Idea found together with Alexis Hildebrandt <surryhill at gmail dot com>.
* Fatal errors no longer exist.Ingo Schwarze2015-01-151-9/+6
| | | | | | If a file can be opened, mandoc will produce some output; at worst, the output may be almost empty. Simplifies error handling and frees a message type for future use.
* Fix a potential NULL pointer access in an error message after waitpid()Ingo Schwarze2015-01-031-23/+16
| | | | | failure; found using detailed information provided by Ulrich Spoerlein <uqs at FreeBSD> about FreeBSD Coverity CID 1261304.
* Explicitly set the *data member of struct ohash_info to NULL.Ingo Schwarze2015-01-021-2/+4
| | | | | | | It is never dereferenced, but it gets copied around, which worries static analysis tools and might also confuse human auditors. FreeBSD Coverity CID 1261298, 1261299, 1261300, reported by Pedro Giffuni and Ulrich Spörlein <pfg@ and uqs@ at FreeBSD>.
* When a file is given on the command line, actually exists, and its nameIngo Schwarze2014-12-301-1/+2
| | | | | | | relative to the respective manual tree is longer than PATH_MAX, do not leak the memory allocated to hold the name. Not sure that can actually happen, but better safe than sorry. FreeBSD Coverity Scan CID 1261303, reported by Pedro Giffuni <pfg@>.
* Integrate the makewhatis binary into the mandoc binaryIngo Schwarze2014-12-091-2/+2
| | | | | just like we do it on OpenBSD. Smaller and neater. While here, let ./configure set INSTALL_TARGETS.
* Improve parsing of function names.Ingo Schwarze2014-12-051-25/+28
| | | | This gets rid of the last bogus entries in base and Xenocara.
* Do not misinterpret function arguments as function names;Ingo Schwarze2014-12-051-1/+4
| | | | improves semantic analysis of more than 300 manuals.
* Render text before, not after accumulating flag bits, such that flagsIngo Schwarze2014-12-051-117/+108
| | | | | for different representations of the same string end up in the same database entry. Improves name classification for 500 manuals.
* When finding a .so link after the page was already processed,Ingo Schwarze2014-12-041-4/+17
| | | | | do not clobber the existing names flags; instead, OR the additional flags into them.
* correctly store .Dt and .TH information in the names tableIngo Schwarze2014-12-041-11/+28
|
* in the SYNOPSIS, add .Fo and first .Fn arguments to the names tableIngo Schwarze2014-12-041-2/+17
|
* In the SYNOPSIS, if .Nm occurs without argument, give the first .NmIngo Schwarze2014-12-041-25/+48
| | | | that occurred in the document a NAME_SYN entry in the names table.
* Make makewhatis(8) understand .so links to .gz pages.Ingo Schwarze2014-11-271-15/+19
| | | | | | | | Drop the FORM_GZ annotation in the mpages table; it is conceptually wrong because it ought to be in the mlinks table: An uncompressed .so link file can point to a compressed manual page file and vice versa. Besides, it is no longer needed because mparse_open() handles it all. Sprinkle some KNF while here.
* Simplify the mparse_open()/mparse_wait() interface.Ingo Schwarze2014-11-261-6/+3
| | | | | Don't bother the user with the PID of the child process, store it inside the opaque mparse handle.
* Three fixes with respect to the names table:Ingo Schwarze2014-11-191-4/+14
| | | | | | 1. Do not mask out NAME_FIRST before its first use. 2. Avoid duplicate NAME_FILE entries. 3. Correctly mask NAME_FILE for .so links.
* Make the character table available to libroff so it can check theIngo Schwarze2014-10-281-4/+4
| | | | | | | | validity of character escape names and warn about unknown ones. This requires mchars_spec2cp() to report unknown names again. Fortunately, that doesn't require changing the calling code because according to groff, invalid character escapes should not produce output anyway, and now that we warn about them, that's fine.
* Fix a regression in term.c rev. 1.229 reported by bentley@:Ingo Schwarze2014-10-271-2/+2
| | | | | | | | | | In UTF-8 output, do not print anything if mchars_spec2cp() returns 0. In particular, this repairs handling of zero-width spaces (\&). While here, let mchars_spec2cp() return 0xFFFD instead of -1 if the character is not found, simplifying the using code. In HTML output, do not print obfuscated ASCII characters and do not test for one-char escapes, mchars_spec2cp() already does that.
* add missing entry for .ll to the dispatch table;Ingo Schwarze2014-10-121-1/+2
| | | | patch from Martin <Natano at natano dot net>, thanks
* If a manpath directory (for example, a _whatdb entry from man.conf(5)Ingo Schwarze2014-09-091-12/+16
| | | | | | | | | | | | | or an entry in the MANPATH environment variable) does not exist, silently skip it. This brings makewhatis(8) back closer to the behaviour of espie@'s version and ought to shut up the weekly(8) whining observed by henning@ on machines not having xbase installed. Also, don't error out after the first unusable manpath entry, still try the others. Of course, still complain about non-existent directories specified on the command line and about any directories failing for other reasons than ENOENT.
* Do not report a page as arch=any merely because .Dt lacks the third argument.Ingo Schwarze2014-09-071-3/+3
| | | | | Pages found outside arch-specific dirs still get arch=any, of course. Issue reported by justinhenryhaynes at gmail dot com on misc@, thanks!
* fix debugging outputIngo Schwarze2014-09-071-2/+2
|
* Add *.gz support to apropos(1) -a, man(1), and even mandoc(1).Ingo Schwarze2014-09-031-54/+15
| | | | Implemented by moving the zip code from makewhatis(8) to the parser lib.
* If a manual page is installed gzip(1)ed, let makewhatis(8) takeIngo Schwarze2014-09-031-11/+8
| | | | | | | note in mandoc.db(5), such that man(1) -w and apropos(1) -w can report the correct filename. This is a prerequisite for letting apropos -a and man support gzip'ed manuals in the future, which doesn't work yet.
* When makewhatis(8) finds an .so link after the manual being pointed toIngo Schwarze2014-09-011-1/+8
| | | | | | | | has already been processed, add the file names to the names table, too, not just to the mlinks table. This fixes a bug where apropos(1) and the new man(1) wouldn't find some of the Xenocara manuals via some of their .so links. After rebuilding, run "makewhatis /usr/X11R6/man" or just wait for weekly(8).
* do not leak a file descriptor on fdopen(3) failure; from doug@Ingo Schwarze2014-08-231-1/+3
|
* Improve build system and autodetection.Ingo Schwarze2014-08-161-3/+3
| | | | | | | | | * Make ./configure standalone, that's what people expect. * Let people write a ./configure.local from scratch, not edit existing files. * Autodetect wchar, sqlite3, and manpath and act accordingly. * Autodetect the need for -L/usr/local/lib and -lutil. * Get rid of config.h.p{re,ost}, let ./configure only write what's needed. * Let ./configure write a Makefile.local snippet, that's quite flexible.
* Provide a fallback version of fts(3) for systems lacking it.Ingo Schwarze2014-08-111-1/+5
| | | | | | I chose the OpenBSD version because it apparently contains various bugfixes that never made it into libnbcompat. To reduce size and complexity, i stripped out the features we don't need.
* Get rid of HAVE_CONFIG_H, it is always defined; idea from libnbcompat.Ingo Schwarze2014-08-101-3/+2
| | | | | | Include <sys/types.h> where needed, it does not belong in config.h. Remove <stdio.h> from config.h; if it is missing somewhere, it should be added, but i cannot find a *.c file where it is missing.