summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Do not access a NULL pointer if a table contains a horizontal lineschwarze2019-06-111-5/+11
| | | | | | next to a table line having fewer columns than the table as a whole. Bug found by Stephen Gregoratto <dev at sgregoratto dot me> with aerc-config(5).
* Explicitly state that the cases in the inner switch in term_fill()schwarze2019-06-031-1/+3
| | | | | | | | are exhaustive. While there is no bug, being explicit has no downside is is potentially safer for the future. Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4 and 7.4.0 on illumos throw -Wuninitialized false positives.
* Initialize the local variable "lastln" in mparse_buf_r().schwarze2019-06-031-2/+2
| | | | | | | | While there is no bug, it logically makes sense given the meaning of the variable that lastln is NULL as long as firstln is NULL. Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4 and 7.4.0 on illumos throw -Wuninitialized false positives.
* Initialize the local variable "act" in print_mdoc_node().schwarze2019-06-031-1/+2
| | | | | | | | | While there is no bug, it helps clarity, and it is also safer in this particular code because in case a bug gets introduced later, accessing a NULL pointer is less dangerous than accessing an uninitialized pointer. Michal Nowak <mnowak at startmail dot com> reported that gcc 4.4.4 and 7.4.0 on illumos throw -Wuninitialized false positives.
* Support prefers-color-scheme: dark.schwarze2019-06-021-8/+21
| | | | | The :visited rule was contributed by <Armin at Besirovic dot com>. Guidance and OK tj@.
* use proper crossreferencesnaddy2019-05-261-3/+4
|
* Do not print the style message "missing date" when the date is givenschwarze2019-05-211-3/+3
| | | | | | as "$Mdocdate$" without an actual date. That is the canonical way to write a new manual page and not bad style at all. Misleading message reported by kn@ on tech@.
* socppc makes an extended visit to the bigbucket.deraadt2019-05-111-2/+2
| | | | ok kettenis
* avoid duplicate "bad argument" error message, also shortening the codeschwarze2019-05-032-9/+5
|
* Enter dangling .so links into the database, to avoid harassingschwarze2019-05-031-7/+12
| | | | | | | | | users of man(1) about running makewhatis(8), which won't help. Seeing the content of the broken .so request might even help users to figure out how to access the manual page they want. Fixing the last issue reported by Lorenzo Beretta <loreb at github> as part of https://github.com/void-linux/void-packages/issues/9868 .
* When processing unknown output options, prevent passing NULL to printf.anton2019-05-031-3/+4
| | | | ok schwarze@
* In fs_lookup(), use stat(2) rather than access(2) to check file existence.schwarze2019-05-031-7/+12
| | | | | | | | | | | Some mildly broken real-world packages on some operating systems contain dangling symlinks in manual page directories: pestering the user to run makewhatis(8) makes no sense because that won't help. On the other hand, missing read permissions deserve ugly error messages and are unlikely to occur in practice anyway. Fixing an issue reported by Lorenzo Beretta <loreb at github> as part of https://github.com/void-linux/void-packages/issues/9868 .
* In man(1) mode with a specific section requested,schwarze2019-05-031-6/+17
| | | | | | | | | | | | | | | | try harder to find the best match. Use this order of preference: 1. The section in both the directory name and the file name matches exactly. 2. The section in the file name matches exactly. 3. The section in the directory name matches exactly. 4. Neither of them matches exactly. The latter can happen when mansearch() finds substring matches or when the second .Dt argument mismatches the dir and file names. Lorenzo Beretta <loreb at github> reported that this caused real problems on Void Linux, like "man 3 readline" showing readline(3m). See https://github.com/void-linux/void-packages/issues/9868 for details.
* In man(1) mode, when the first argument starts with a digit,schwarze2019-05-031-2/+2
| | | | | | | | | | | | | | | | | | | | optionally followed by a letter, and at least one more argument follows, interpret the first argument as a section name even when additional characters follow after the digit and letter. This is needed because many operating systems have section names consisting of a digit followed by more than one letter - for example Illumos, Solaris, Linux, even NetBSD. There is very little risk of regressions: in the whole corpus of manual pages on man.openbsd.org, there isn't a single manual page name starting with a digit. And even if programs like "0ad" or "4channels" had manual pages, "man 0ad" and "man -a cat 0ad" would still work, only "man -a 0ad cat" will fail with "man: No entry for cat in section 0ad of the manual." Fixing one of the issues reported by Lorenzo Beretta <loreb at github> as part of https://github.com/void-linux/void-packages/issues/9868 .
* In man(1) mode, i.e. when asking for a single manual page by name,schwarze2019-04-303-5/+12
| | | | | | | | | | | | prefer file name matches over .Dt/.TH matches over first NAME matches over later NAME matches, but do not change the ordering for apropos(1) nor for man -a. This reverts main.c rev. 1.213 and mansearch.h rev. 1.23 and includes a partial revert of mansearch.c rev. 1.62. Regression reported by Lorenzo Beretta <loreb at github> as part of https://github.com/void-linux/void-packages/issues/9868 .
* In HTML output, allow switching the desired font for subsequentschwarze2019-04-304-66/+35
| | | | | | | | text without printing an opening tag right away, and use that in the .ft request handler. While here, garbage collect redundant enum htmlfont and reduce code duplication in print_text(). Fixing an assertion failure reported by Michael <Stapelberg at Debian> in pmRegisterDerived(3) from libpcp3-dev.
* improve the description of the message "blank line in fill mode";schwarze2019-04-301-3/+6
| | | | triggered by a misunderstanding by sashan@
* When calling an empty macro, do not clobber existing arguments.schwarze2019-04-211-2/+7
| | | | | Fixing a bug found with the groffer(1) version 1.19 manual page following a report from Jan Stary.
* Implement the roff .break request (break out of a .while loop).schwarze2019-04-211-9/+46
| | | | | | | Jan Stary <hans at stare dot cz> found it in an ancient groffer(1) manual page (version 1.19) on MacOS X Mojave. Having .break not implemented wasn't a particularly bright idea because obviously, it tended to cause infinite loops.
* Set the maximum column index in a tbl(7) to the maximum *right* edgeschwarze2019-03-291-2/+2
| | | | | | | | | | | | | | | of any cell span, not to the maximum *left* edge, which may be smaller if the last column of the table is only reached by horizontal spans, but not by any regular cell in any row of the table. Otherwise, the algorithm calculating column widths accessed memomy after the end of the colwidth[] array, while it was trying to handle the rightmost column(s). Crash reported by Jason Thorpe <thorpej at NetBSD> via https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54069 and via Thomas Klausner (wiz@). Christos@ Zoulas sent a (correct, but slightly confusing) patch. The patch i'm committing here is easier to understand.
* When the last line of the input is empty and the previous line reducedschwarze2019-03-191-1/+3
| | | | | | | the line input buffer to a length of one byte, do not write one byte past the end of the line input buffer. Minimal code to show the bug: printf ".ds X\n.X\n\n" | MALLOC_OPTIONS=C mandoc Bug found by bentley@ in the sysutils/rancid par(1) manual page.
* fix a NULL pointer access on empty tbl(7) data cellsschwarze2019-03-181-3/+5
| | | | that bentley@ found in syncthing-bep(7)
* The header file "html.h" uses enum roff_tok,schwarze2019-03-172-2/+4
| | | | | | so "roff.h" must be included before it. Diff from bcallah@ tweaked by me; he found the bug by compiling with pcc.
* When drawing a horizontal line in tbl(7) UTF-8 output, it is notschwarze2019-03-161-13/+18
| | | | | | | | | | | | | sufficient to look at two data rows, but up to three are needed: the one above to identify vertical lines branching off upward, the row itself (in case the line is in a data row rather than a layout line) to figure out the horizontal line style, and the row below to identify vertical lines branching off downward. As an example, bentley@ reported from the mpv(1) manual page that in a tbl(7) having a vertical line in the middle and a horizontal line in the bottom data row, the vertical line extended below the bottom horizontal line.
* Contrary to what the NetBSD attribute(3) manual page suggests,schwarze2019-03-132-6/+6
| | | | | | | | | | | | | using __dead instead of __attribute__((__noreturn__)) actually hinders portability rather than helping it. Given that mandoc already uses __attribute__ in several files and that in the portable version, ./configure already contains rudimentary support for ignoring it on platforms that do not support it, use __attribute__ directly. This is expected to fix build failures that Stephen Gregoratto <dev at sgregoratto dot me> reported from Arch and Debian Linux.
* mark check_abort() and post_abort() as __dead;schwarze2019-03-112-6/+6
| | | | based on a patch by Christos@ Zoulas at NetBSD
* Mention mandoc.db(5), makewhatis(8), and weekly(8).schwarze2019-03-091-2/+14
| | | | Omission noticed by espie@ long ago, and wording tweaked by jmc@.
* drop redundant '0' flag from "%02.2X" format string;schwarze2019-03-061-2/+2
| | | | found by a compiler warning from gcc 4.9.2 on Linux
* man.cgi also needs to link arch.o; forgotten in rev. 1.116schwarze2019-03-061-2/+2
|
* For TIOCGWINSZ, #include <termios.h> rather than <sys/termios.h>schwarze2019-03-041-2/+2
| | | | | | like almost all other userland programs. This also improves portability: for example, it looks like <sys/termios.h> does not work on FreeBSD, or at least bapt@ did the same change over there.
* When the -S option is given to man(1) and the requested manual pageschwarze2019-03-045-46/+77
| | | | | | | | | | | | name is not found and the requested architecture is unknown, complain about the architecture rather than about the manual page name: $ man -S vax cpu man: Unknown architecture "vax". $ man -S sparc64 foobar man: No entry for foobar in the manual. Friendlier error message suggested by jmc@, who also OK'ed the patch.
* Fix the last straggler where the struct roff_node "line" memberschwarze2019-03-041-2/+2
| | | | | was abused to detect an input line break; instead, use the NODE_LINE flag to improve robustness.
* Reset HTML formatter state, in particular the id_unique hash,schwarze2019-03-033-10/+24
| | | | | | | | after processing each manual page, such that the next page starts from a clean state and doesn't continue suffix numbering. Issue found while looking at https://github.com/Debian/debiman/issues/48 which was brought up by Orestis Ioannou <oorestisime at github>.
* Represent multiple subsequent .IP blocks having a consistentschwarze2019-03-021-16/+68
| | | | | | | | | head argument of *, \-, or \(bu as <ul> rather than as <dl>, using a bit of heuristics. Basic idea suggested by Dagfinn Ilmari Mannsaker <ilmari at github> in https://github.com/Debian/debiman/issues/67 and independently by <Pali dot Rohar at gmail dot com> on <discuss at mandoc dot bsd dot lv>.
* Wrap .Sh/.SH sections and .Ss/.SS subsections in HTML <section> elementsschwarze2019-03-015-20/+35
| | | | | | as recommended for accessibility by the HTML 5 standard. Triggered by a similar, but slightly different suggestion from Laura Morales <lauretas at mail dot com>.
* Format multiple subsequent .IP or multiple subsequent .TP/.TQschwarze2019-02-281-3/+29
| | | | | as a single <dl> list rather than opening a new list for each item; feature suggested by Pali dot Rohar at gmail dot com.
* Remove -S from install commandskn2019-02-241-2/+2
| | | | | | | | As of usr.bin/xinstall/install.c revision 1.68, -S is a no-op and install(1) will always create files safely, thus clean the option usage from the tree. Diff from Lauri Tirkkonen <lotheac at iki dot fi>, thanks.
* Explain the ASCII rendering of single quotes because that repeatedlyschwarze2019-02-231-2/+13
| | | | | | | | | | | caused confusion in the past. People plainly do not expect that there are limits to the compatibility between Unicode and ASCII, but there are. The information belongs here and not into mandoc_char(7) because it explains how the specific output device (-T ascii) works and because it has nothing to do with the question of how characters are represented on the input side.
* The horizontal line in a data cell containing only "_" or "="schwarze2019-02-091-48/+45
| | | | | connects to the horizontally adjacent vertical line or cell; fixing a bug reported by bentley@.
* ignore empty request lines in the table data reader;schwarze2019-02-091-10/+23
| | | | fixing a minibug reported by bentley@
* Let roff_getname() end the roff identifier at a tab characterschwarze2019-02-061-8/+19
| | | | | | | | | | | | | | | | | | | | | | and audit all its callers whether termination is handled correctly. Resulting improvements: * An escape or tab ending the macro name in a macro invocation is discarded, and argument processing is started after it. * An escape or tab ending a name in ".if d" and ".if r" is preserved. * An escape ending a name in ".ds" causes the whole request to be ignored. * A tab ending a name in ".ds" becomes part of the string. * An escape or tab ending a name in ".rm" causes the rest of the line to be ignored. * An escape or tab ending the first name in ".als", ".rn", or ".nr" causes the whole request to be ignored. Kurt Jaeger <pi at FreeBSD> made me aware of https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235456#c0 and in that bug report, comment 0 item (3) is a special case of this class of issues. Yes, the "mh" manual pages are no doubt among the worst on the planet.
* adjust style and comments in roff_getname(); no functional changeschwarze2019-02-061-12/+15
|
* Relax overzealous PATH_INFO validation.schwarze2019-01-311-2/+2
| | | | | | | URIs like https://man.openbsd.org/OpenBSD-2.2/cat1/cat.0 are still required to work because they result from apropos searches for old releases (up to 5.0) which used to install preformatted manual pages. Regression reported by jj@.
* Fix tbl(7) centering in mdoc(7) documents.schwarze2019-01-311-4/+8
| | | | | | | | | | Since resetting of offsets works quite differently in the mdoc(7) and man(7) formatters, the tbl(7) formatter needs to save the global offset on entry and restore it on exit. The additional indentation needed for table centering has to be added to its own offset variable and applied to each line of the table, rather than only to the first. Bug found by bentley@ in emulators/fceux(6).
* The .UR and .MT blocks in man(7) are represented by <a> elementsschwarze2019-01-184-59/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which establish phrasing context, but they can contain paragraph breaks (which is relevant for terminal formatting, so we can't just change the structure of the syntax tree), which are respresented by <p> elements and cannot occur inside <a>. Fix this by prematurely closing the <a> element in the HTML formatter. This menas that the clickable text in HTML output is shorter than what is represented as the link text in terminal output, but in HTML, it is frankly impossible to have the clickable area of a hyperlink extend across a paragraph break. The difference in presentation is not a major problem, and besides, paragraph breaks inside .UR are rather poor style in the first place. The implementation is quite tricky. Naively closing out the <a> prematurely would result in accessing a stale pointer when later reaching the physical end of the .UR block. So this commit separates visual and structural closing of "struct tag" stack items. Visual closing means that the HTML element is closed but the "struct tag" remains on the stack, to avoid later access to a stale pointer and to avoid closing the same HTML element a second time later. This also needs reference counting of pointers to "struct tag" stack items because often more than one child holds a pointer to the same parent item, and only the outermost child can safely do the physical closing. In the whole corpus of nearly half a million manual pages on man.openbsd.org, this problem occurs in exactly one page: the groff(1) version 1.20.1 manual contained in DragonFly-3.8.2, which contains a formatting error triggering the bug.
* In PostScript and PDF output, one AFM unit is not nearly enoughschwarze2019-01-151-3/+4
| | | | | | inter-word spacing, let's try again with 250 AFM units. Regression caused during my recent term_flushln() reorg in rev. 1.138, reported by brynet@ (sorry and many thanks for reporting).
* Improve error reporting when a file given on the command lineschwarze2019-01-112-5/+7
| | | | | | cannot be opened: * Mention the filename. * Report the errno for the file itself, not the one with .gz appended.
* do not access a NULL pointer when formatting a completely empty documentschwarze2019-01-112-5/+5
|
* Remove the HTML title= attributes which harmed accessibility andschwarze2019-01-114-58/+126
| | | | | | | violated the principle of separation of content and presentation. Instead, implement the tooltips purely in CSS. Thanks to John Gardner <gardnerjohng at gmail dot com> for suggesting most of the styling in the new ::before rules.
* After years of gnashing of teeth, i finally found a way to avoidschwarze2019-01-102-15/+8
| | | | | | | | | | | | | | | | | | having to write empty list elements for non-compact .Bl -tag lists: 1. Add margin-bottom to the <dd>. Note that margin-top on the <dt> doesn't work because it would put a short <dt> lower than the <dd>; margin-bottom on the <dt> doesn't work because it would put vertical space before the <dd> for a long <dt>; and margin-top on the <dd> doesn't work because it would put a short <dt> higher than the <dd>. Only margin-bottom on the <dd> has none of these adverse effects. 2. Of course, margin-bottom on the <dd> fails to take care of the vertical spacing before the first list element, so implement that separately by margin-top on the <dl>. 3. For .Bl -tag -compact, reset both to zero.