summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* change spelling of centre to center: consistent with other man pagesIngo Schwarze2015-01-205-9/+9
| | | | and the name of the syntax elements being described; from tedu@
* Make the man(1) and apropos(1) options -s and -S much less expensive:Ingo Schwarze2015-01-201-48/+22
| | | | | | | | | | | | | | Do not append an SQL clause looking into the large "keys" table. Instead, filter the result of the SQL query in buildnames() where equivalent data from the much smaller "mlinks" table is already available for free. This is relevant because man(1) uses the equivalent of "-S ${MACHINE}" by default since main.c rev. 1.216, to make sure that manuals for the current architecture are shown. With many ports installed, this patch can speed up man(1) by a factor of more than a hundred. Slowness reported by Theo Buehler <theo at math dot ethz dot ch>, thanks!
* Let man(1) show manuals for the current architecture by default,Ingo Schwarze2015-01-161-0/+5
| | | | | and support the MACHINE environment variable as documented in man(1). Missing feature reported by pascal@.
* Parse and ignore .IX (generate index entry) macros because pod2man(1)Ingo Schwarze2015-01-161-0/+2
| | | | | emits them, by default without defining them, relying on the roff(7) quirk that undefined macros have no effect.
* Fatal errors no longer exist.Ingo Schwarze2015-01-1512-158/+91
| | | | | | 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.
* downgrade .so failure from FATAL to ERRORIngo Schwarze2015-01-153-27/+26
|
* downgrade ".so with absolute path" from FATAL to ERROR;Ingo Schwarze2015-01-144-9/+10
| | | | allows to get rid of ROFF_ERR
* simplify by getting rid of ROFF_ERR in tbl(7) parsing; no functional changeIngo Schwarze2015-01-144-13/+12
|
* To get rid of SYSERR entries in enum mandocerr, downgrade problems withIngo Schwarze2015-01-143-44/+26
| | | | | | missing and unreadable files from SYSERR to ERROR. Needed for upcoming work. As a bonus, this minimally simplifies code and documentation.
* if earlier files set a non-zero exit status,Ingo Schwarze2015-01-141-6/+12
| | | | do not allow later files to reset it to zero
* Simplify handling of system errors: just exit(3).Ingo Schwarze2015-01-142-41/+15
| | | | | We already do the same for malloc(3) failure. The is no virtue in trying to survive failure of fork(2) and the like.
* Be developer-friendly, 'cause OpenBSD devs like to:Ingo Schwarze2015-01-131-4/+105
| | | | | | | | | | | | | cd /usr/src/share/man/man4; vi newdev.4 Makefile; make install; man newdev When a manual is missing from an outdated database, let man(1) show it anyway, using a KISS file system lookup as a fallback. Requested by deraadt@. 87 new lines of code doesn't seem too much bloat to me. Of course, keeping your mandoc.db(5) files up to date with makewhatis(8) or weekly(8) is still required for apropos(1) to find your new pages.
* do not spawn a pager when there is no output; issue pointed out by deraadt@Ingo Schwarze2015-01-131-24/+35
|
* Bugfix: When the invocation of a user-defined macro follows a roffIngo Schwarze2015-01-071-0/+1
| | | | | conditional request on the same input line, don't skip the first few bytes of its content.
* Fix a potential NULL pointer access in an error message after waitpid()Ingo Schwarze2015-01-031-22/+15
| | | | | failure; found using detailed information provided by Ulrich Spoerlein <uqs at FreeBSD> about FreeBSD Coverity CID 1261304.
* Given the excessively technical description in the old mdoc_samples(7)Ingo Schwarze2015-01-031-6/+15
| | | | | | | | | | manual and its successor groff_mdoc(7), i always considered .Ql as purely physical markup, but it turns out describing it better allows to give it a semantic meaning (in-line literal display) that doesn't contradict existing usage. One less physical, one more semantic macro, yay! Found in a discussion with Steffen Nurpmeso <sdaoden at yandex dot com>.
* Explicitly set the *data member of struct ohash_info to NULL.Ingo Schwarze2015-01-021-1/+3
| | | | | | | 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>.
* Fix a buffer overrun triggered by a trailing backslash at EOF inIngo Schwarze2015-01-011-4/+6
| | | | | | | an unclosed conditional body. If the memory contained the byte sequence "\}" after the end of the buffer before the next NUL, this could even write beyond the end of the buffer, specifically '&' to the location of the '}'. Found by jsg@ with afl.
* Fix a read buffer overrun triggered by trailing \s- or trailing \s+Ingo Schwarze2015-01-011-3/+3
| | | | without the required subsequent argument; found by jsg@ with afl.
* Don't dereference NULL pointers when formatting missing denominators,Ingo Schwarze2015-01-012-9/+12
| | | | | subscripts, superscripts, or "from" or "to" arguments. Found by jsg@ with afl.
* If man(1) only has one single argument, always interpret it as a name,Ingo Schwarze2015-01-011-1/+2
| | | | | | never as a section. Who would have thought that people call their manual pages 7z(1), 9c(1), 9p(1), and 9p(3)... Patch from Sebastien Marie <semarie dash openbsd at latrappe dot fr>.
* describe .Ql more precisely;Ingo Schwarze2014-12-311-2/+5
| | | | defect pointed out by Steffen Nurpmeso <sdaoden at yandex dot com>
* When showing more than one formatted manual page, insert horizontal linesIngo Schwarze2014-12-313-1/+21
| | | | | | between pages. Suggested by Theo Buehler <theo at math dot ethz dot ch>. Even in UTF-8 output mode, do not use fancy line drawing characters such that you can easily use /^--- to skip to the next manual in your pager.
* fix wrong paths below FILES; from Theo Buehler <theo at math dot ethz dot ch>Ingo Schwarze2014-12-301-4/+4
|
* When a file is given on the command line, actually exists, and its nameIngo Schwarze2014-12-301-0/+1
| | | | | | | 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@>.
* Improve documentation of the header/footer macros .Dt, .Os, .TH:Ingo Schwarze2014-12-282-26/+28
| | | | | | * State the defaults for .Os and the fourth .TH argument. * Sync the section titles, and stop advertising obscure sections that aren't actually fully supported and certainly not recommended for use.
* mdoc(7) already uses the mandoc(1) -Ios argument in the footer lineIngo Schwarze2014-12-287-5/+20
| | | | | | when .Os has no argument, so do the same for man(7) when .TH has less than four arguments; there is no reason to treat both differently. Issue found following a question from Thomas Klausner <wiz at NetBSD>.
* improve previous: do the size check up front to avoid leaking memoryIngo Schwarze2014-12-281-6/+4
|
* Reduce memory and time consumption on certain malformed input filesIngo Schwarze2014-12-252-2/+11
| | | | | | by limiting the length of expanded input lines during the (usually recursive) expansion of user defined strings. Resource hogging found by jsg@ with afl.
* Support negative indentations for mdoc(7) displays and lists.Ingo Schwarze2014-12-243-78/+84
| | | | | | Not exactly recommended for use, rather for groff compatibility. While here, introduce similar SHRT_MAX limits as in man(7), fixing a few cases of infinite output found by jsg@ with afl.
* For .RS, we need to save the information how much we actually indentedIngo Schwarze2014-12-242-27/+14
| | | | | | | because negative indents can get truncated, in which case we no longer know how to restore the original indent at the end of the block. This also solves another case of effectively infinite output found by jsg@ with afl, triggered by very large negative indents.
* Prevent unsigned integer underflow when a number is too wideIngo Schwarze2014-12-241-3/+7
| | | | | for a table cell with an "nz" layout specification, causing essentially infinite output as found by jsg@ with afl.
* When a man(7) document contains unreasonably large numbers forIngo Schwarze2014-12-242-10/+21
| | | | | | | | | | | indentations or paragraph distances, large output may be generated, which is practically the same as an endless loop; found by jsg@ with afl. Reject such unreasonably large numbers beyond arbitrary limits similar to those used by groff (max. 65 blank lines between paragraphs and max. SHRT_MAX characters per output line) and fall back to defaults when exceeded. Having the limits behave in exactly the same way is not relevant.
* support negative horizontal widths in man(7);Ingo Schwarze2014-12-237-129/+93
| | | | minus twenty lines of code in spite of enhanced functionality
* fix typo in previousIngo Schwarze2014-12-231-2/+2
|
* some scaling unit fixes:Ingo Schwarze2014-12-236-69/+49
| | | | | - .sp with an invalid argument is .sp 1v, not .sp 0v - in man(1), trailing garbage doesn't make scaling units invalid
* even if the second argument to .IP is invalid, don't print itIngo Schwarze2014-12-231-3/+2
|
* Fix vertical scaling. Obviously, nobody ever had a serious look at this.Ingo Schwarze2014-12-231-7/+18
| | | | | Basic units, centimeters, points, ens, ems, and the rounding algorithm were all wrong, only inches, pica, and the default vertical span worked.
* In a2roffsu(), do not parse the number twice.Ingo Schwarze2014-12-231-43/+12
| | | | | Gets rid of 25 lines of code and one static buffer. No functional change for numbers shorter than BUFSIZ characters.
* correctly handle scaling units after .PDIngo Schwarze2014-12-231-2/+4
|
* The code already pays attention not to close the same block twice.Ingo Schwarze2014-12-221-2/+2
| | | | | | | Similarly, avoid having the same block break two other blocks. In some situations, this could lead to an endless loop in rew_sub() found by jsg@ with afl. Minimal example: .Po Ao Pc Bo Pc Ac Bc
* Use -m for macro set selection in mandoc(1) mode only, not in man(1)Ingo Schwarze2014-12-211-7/+7
| | | | | | and apropos(1) mode. While here, put a space character between options and option arguments in error messages. Both reported by Alessandro DE LAURENZIS <just22 dot adl at gmail dot com>.
* ISO C99 explicitly forbids forward references to enum types (6.7.2.3.3.);Ingo Schwarze2014-12-213-5/+8
| | | | patch from daniel@
* Fix two issues causing a class of assertion failures found by jsg@ with afl.Ingo Schwarze2014-12-201-8/+19
| | | | | | | | 1) rew_sub(): Make sure REWIND_MORE is acted upon even when followed by REWIND_NONE. This prevents .It from ending up inside other children of .Bl. 2) blk_exp_close(): Only allow extension of .Bl when it has at least one .It. Otherwise, a broken child block could be moved in front of the .Bl, effectively resulting in a .Bl that ended before it began.
* resolve some code duplication; no functional changeIngo Schwarze2014-12-201-26/+18
|
* Enforcing an arbitrary, implementation dependent, undocumented limitIngo Schwarze2014-12-194-18/+28
| | | | | | by calling assert() when valid user input exceeds it is a bad idea. Allocate the terminal font stack dynamically instead of crashing above 10 entries. Issue found by jsg@ with afl.
* Rewrite the low-level UTF-8 parser from scratch.Ingo Schwarze2014-12-191-75/+58
| | | | | | | | | | | | | | It accepted invalid byte sequences like 0xc080-c1bf, 0xe08080-e09fbf, 0xeda080-edbfbf, and 0xf0808080-f08fbfbf, produced valid roff Unicode escape sequences from them, and the algorithm contained strong defenses against any attempt to fix it. This cures an assertion failure in the terminal formatter caused by sneaking in ASCII 0x08 (backspace) by "encoding" it as an (invalid) multibyte UTF-8 sequence, found by jsg@ with afl. As a bonus, the new algorithm also reduces the code in the function by about 20%.
* update usage() and the list of non-standard (i.e. non-posix) options;Ingo Schwarze2014-12-182-3/+5
| | | | from jmc@
* Don't let .Ta creep into an already-closed list; same as for .It.Ingo Schwarze2014-12-181-1/+2
| | | | Fixes an assertion found by jsg@ with afl.
* Only keep leading .Sm inside a list when it immediately precedesIngo Schwarze2014-12-181-1/+4
| | | | | the first .It. Otherwise, move it out together with whatever follows. Fixing an assertion failure found by jsg@ with afl.