summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
AgeCommit message (Collapse)Author
2022-02-18prefer https links in man pagesJonathan Gray
ok gnezdo@ miod@ jmc@
2022-02-08In the first example, use "mandoc -a" directly rather "mandoc -l".Ingo Schwarze
It feels more natural to me to use -a directly when asking mandoc(1) to use a pager. The reason that "mandoc -l" does exactly the same as "mandoc -a" is that "mandoc" is essentially "man -lc", so the -a implied by -l negates the -c and the -l has no effect because it is already the default for mandoc(1). The more usual command for doing the same is "man -l foo.1 bar.1 ..." but that's off-topic for the mandoc(1) manual page. Patch on tech@ from Anders Damsgaard <anders at adamsgaard dot dk>.
2022-02-06remove please from manual pagesJonathan Gray
ok jmc@ sthen@ millert@
2022-01-13Tedu support for the -xsh4.2 argument to the mdoc(7) .St macroIngo Schwarze
because all of the following hold: * It is an alias for a part of an ancient standard that is no longer important. * To refer to that old standard, -xpg4.2 is readily available and portable. * It is unused in OpenBSD, FreeBSD, and NetBSD. * Groff never supported it. I agreed with G. Branden Robinson that deleting this from mandoc is preferable to adding it to groff.
2022-01-13Only sort the result array if it contains more than one element,Ingo Schwarze
making the mansearch() function easier to read for human auditors. No functional change on OpenBSD. As observed by Mark Millard <marklmi at yahoo dot com>, neither the latest version of POSIX 2008 nor C11 defines what qsort(3) should do for base == NULL && nmemb == 0. My impression is it is indeed undefined behaviour because the standards say that base shall point to an array, NULL does not point to an array, and while there is special wording saying that compar() shall not be called if nmemb == 0, i fail to see any similar wording stating that base shall not be accessed if nmemb == 0. Consequently, this patch is also likely to improve standard conformance and portability. Minor issue found by Stefan Esser <se at FreeBSD> with UBSAN. He sent a patch to bugs@, but my patch differs in a minor way.
2022-01-12More accurately represent cells containing horizontal lines in -T treeIngo Schwarze
output. In particular, do not represent "_" as "-", and distinguish "_" from "\_" and "=" from "\=". Output tweak following a related question from Ted Bullock <tbullock at comlore dot com>.
2022-01-12According to the tbl(7) manual, if a data cell contains only theIngo Schwarze
two character sequence "\_" or "\=", a single or double horizontal line is supposed to be drawn inside the cell, not joining its neighbours. I am not aware of any way to do that with HTML and/or CSS. Still, it seems closer to the intent of the document author to draw a horizontal line with <hr/>, even though that line will join the neighbour cells, rather than printing a literal '_' or '=' character. Formatting tweak inspired by a related question from Ted Bullock <tbullock at comlore dot com>.
2022-01-10When rendering the \h (horizontal motion) low-level roff(7) escapeIngo Schwarze
sequence in -T ps and -T pdf output mode, use an appropriate horizontal distance by correctly using the term_len() utility function. Output from the -T ascii, -T utf8, and -T html modes was already correct and remains unchanged. Lennart Jablonka <hummsmith42 at gmail dot com> found and reported this unit conversion bug (misinterpreting AFM units as if they were en units) when rendering scdoc-generated manuals (which is a low quality generator, but that's no excuse for mandoc misformatting \h) on Alpine Linux. Lennart also tested this patch.
2021-11-05Make sure that the configuration file is always read, even whenIngo Schwarze
running with the -M option or with a MANPATH environment variable that has neither a leading or trailing ":" nor any "::". If -M or MANPATH override the configuration file rather than adding to it, just ignore any "manpath" directives while processing the configuration file. This fixes a bug reported by Jan Stary <hans at stare dot cz> on misc@.
2021-10-24For open/openat, if the flags parameter does not contain O_CREAT, theTheo de Raadt
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert
2021-10-17simplify a few accesses to fields of structs, using auxiliary pointerIngo Schwarze
variables that are already present (and used nearby) in the code; no functional change
2021-10-17Simplify the code building lists of spans, no output change intended.Ingo Schwarze
A comment in the code claimed that the list of spans would be sorted, but the sorting did not actually work. The layout "LSSS,LLSL" resulted in the list "0-3, 1-2", whereas the layout "LLSL,LSSS" resulted in the list "1-2, 0-3". Since sorting serves no purpose, just leave the list unsorted.
2021-10-04Clean up memory handling in spawn_pager(), free(3)ing everythingIngo Schwarze
that is malloc(3)ed. In addition to being less confusing, the new code is also shorter by two lines.
2021-10-04In man(1) mode, properly clean up the resn[] result arrayIngo Schwarze
after processing each name given on the command line. Failure to do so resulted in a memory leak of about 50 kilobytes per name given on the command line. Since man(1) uses a few Megabytes of memory anyway and people rarely give hundreds of names on the command line, this leak did not cause practical problems, but cleaning up properly is better in any case.
2021-10-04Provide a cleanup function for the term_tab module, freeing memoryIngo Schwarze
and resetting the internal state to the initial state. Call this function from the proper place in term_free(). With the way the module is currently used, this does not imply any functional change, but doing proper cleanup is more robust, makes it easier during code review to understand what is going on, and makes it explicit that there is no memory leak.
2021-10-04store the operating system name obtained from uname(3) in the adequateIngo Schwarze
struct together with similar state date rather than in a function-scope static variable, such that it can be free(3)d in roff_man_free(); no functional change
2021-10-04Do not leak 64 bytes of heap memory every time a manual page callsIngo Schwarze
a user-defined macro. Calls of standard mdoc(7) and man(7) macros were unaffected, so the effect on OpenBSD manual pages was small, about 80 Kilobytes grand total for a full run of "makewhatis /usr/share/man". Argument expansion contexts for user-defined macros are stored on a stack that grows as needed if calls of user-defined macros are nested or recursive. Individual stack entries contain dynamically allocated arrays of pointers to arguments; these argument arrays also grow as needed if user-defined macros take more than eight arguments. The mistake was that argument arrays of already initialized expansion contexts were leaked rather than reused on subsequent macro calls. I found this issue in a systematic hunt for memory leaks after Michael <Stapelberg at Debian> reported memory exhaustion problems on the production server manpages.debian.org. This sub-Megabyte leak is not the cause of Michael's trouble, though, where Gigabytes of memory are being wasted. We are still investigating whether the original problem may be related to his supervisor process, which is written in Go, rather than to mandoc.
2021-09-28Revert part of the previous diff to fix a regression (another endless loop)Ingo Schwarze
reported by Michael <Stapelberg at Debian> in the Linux md(4) manual. The reason the colwidth[] array is needed is not that it stores widths different from those in tbl->cols[].width, but that only part of the columns participate in the comparisons, i.e. only those intersecting at least one span the still requires width distribution.
2021-09-10Quirk-compatibility with GNU tbl(1):Ingo Schwarze
With the "nospaces" option, skip space characters before and after "T{", in addition to skipping those at the beginning and end of data cells. Minor issue reported by <Oliver dot Corff at email dot de>.
2021-09-10In a tbl(7) having the "nospaces" option, skip space charactersIngo Schwarze
not only at the end of data cells, but also after "T}", aligning the behaviour of the parser with GNU tbl(1). Issue reported by <Oliver dot Corff at email dot de>.
2021-09-09In HTML output, in cells with an "n" (number) layout, pad numbersIngo Schwarze
on the right side with UTF-8 punctuation and figure spaces such that numbers in different tbl(7) rows align at the decimal point. The exact HTML output format was suggested by <Oliver dot Corff at email dot de>; the implementation in C is mine.
2021-09-09If the layout or data of an individual cell in a tbl(7) containsIngo Schwarze
only "_", "-", or "=", requesting a horizontal line to be drawn across the middle of the cell, print <hr/> in that cell in HTML output. That is arguably slightly ugly because HTML 5 regards <hr/> as semantic markup, meaning "thematic break". If somebody knowns a better way to render a horizontal line across the middle of a table cell with pure HTML and CSS, and without implying a specific meaning, please tell me. Missing feature reported by <Oliver dot Corff at email dot de>.
2021-09-07Fix an infinite loop that could occur during some cases of horizontallyIngo Schwarze
overlapping horizontal spans. One span would calculate a desired target width and start preparations for applying it to some columns, then the other span would overwrite the target width with a different value and also start preparations for applying that one to some columns, which could sometimes confuse the code doing the final distribution to the point of not doing anything at all before entering the next iteration. Fix this by making sure the distribution is done step by step, doing one step at a time rather than allowing multiple steps to conflict. Specifically, always do the smallest useful step first. This change also simplifies the code. For example, the local "colwidth" array is no longer needed. Note that the algorithm still differs from the one implemented in GNU tbl(1), which appears to not even try to harmonize column widths but seems to simply distribute the same amount to all constituent columns, no matter whether their intrinsic width is narrow or wide. Adopting a GNU-compatible algorithm might allow further simplifiction in addition to yielding even more similar output, but i do not want to implement any major changes of the algorithm at this time. The infinite loop was reported by <Oliver dot Corff at email dot de>.
2021-09-07Correctly calculate required column widths for tables containingIngo Schwarze
cells that horizontally span columns which contains "n" (number) formatted cells on other rows. This requires updating total column widths from "n" formatted cells before starting width distribution from the spanning cells to their constituent columns.
2021-09-07we already parse the GNU tbl(7) "nospaces" option,Ingo Schwarze
so let it have the intended effect, too
2021-09-07do not crash when a tbl(7) cell uses roman fontIngo Schwarze
2021-09-04during prioritization for man(1), correctly extract the section nameIngo Schwarze
from the file name extension of gzipped manual page files; bug found on Alpine Linux by Soeren Tempel <soeren at soeren hyphen tempel dot net>, who also tested this patch
2021-09-04mdoc(7): improve output of .At 32vIngo Schwarze
The official designation by AT&T was "UNIX/32V", so use that in the output. That also makes sense because "system/architecture" is a widespread convention to refer to the port of an operating system to a specific architecture, in this case 32V (32bit DEC VAX). The former wording "Version 32V AT&T UNIX" was misleading because 32V is not a version number. Even though UNIX/32V was not officially designated as Version 7 by AT&T, prepend "Version 7" because it was in fact a straightforward port of Version 7 AT&T UNIX. That makes it easier to understand for 21st century readers of manual pages. Suggested by nabijaczleweli at nabijaczleweli dot xyz. Same change as in GNU troff commit 21d30728. OK G dot Branden dot Robinson at gmail dot com (gbranden@ in groff)
2021-09-04In the fallback code to look for manual pages without using mandoc.db(5),Ingo Schwarze
accept files "man<one-digit-section>/<name>.<full-section>" in addition the already supported "man<full-section>/name.[01-9]*". Needed for example on Alpine Linux which puts its Perl manuals into "man3/<name>.3pm" and the POSIX manuals into "man3/<name>.3p". While here, allow the glob(3) at the end of fs_lookup() to add multiple matches to the result set. This improves man -w output and may also help some cases of plain man(1), allowing main() to prioritize properly rather than fs_lookup() picking a random match. None of this really matters for standard manpaths on OpenBSD because both base system and ports developers are highly disciplined about putting manual pages into properly named files and directories, but even on OpenBSD, it may help to access some raw, unported third-party manual page trees. Issue reported and patch tested by Soeren Tempel <soeren at soeren hyphen tempel dot net>.
2021-08-19do not crash when a manpath directory contains a symbolic linkIngo Schwarze
that points to a directory rather than to a regular file; bug reported by Lukas Epple <sternenseemann at systemli dot org>, and my patch also tested by him on NixOS
2021-08-19fix the section number in the <title> element for preformatted pages;Ingo Schwarze
minibug reported by Ian <Ropers at gmail dot com> on misc@
2021-08-14print a BAGARG message if -T markdown is requested on man(7) input;Ingo Schwarze
suggested by Michael Stapelberg at debian dot org
2021-08-10Support two-character font names (BI, CW, CR, CB, CI)Ingo Schwarze
in the tbl(7) layout font modifier. Get rid of the TBL_CELL_BOLD and TBL_CELL_ITALIC flags and use the usual ESCAPE_FONT* enum mandoc_esc members from mandoc.h instead, which simplifies and unifies some code. While here, also support CB and CI in roff(7) \f escape sequences and in roff(7) .ft requests for all output modes. Using those is certainly not recommended because portability is limited even with groff, but supporting them makes some existing third-party manual pages look better, in particular in HTML output mode. Bug-compatible with groff as far as i'm aware, except that i consider font names starting with the '\n' (ASCII 0x0a line feed) character so insane that i decided to not support them. Missing feature reported by nabijaczleweli dot xyz in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=992002. I used none of the code from the initial patch submitted by nabijaczleweli, but some of their ideas. Final patch tested by them, too.
2021-07-18Support auto-tagging for ".It Va".Ingo Schwarze
This combination is somewhat rare because few libraries expose so many global variables that they need a list to enumerate them, but when the idiom does occur, tagging the variable names is generally useful. For example, this helps awk(1), dc(1), make(1), rc.subr(8), ... Missing feature reported and patch reviewed, tested, and OK'ed by kn@.
2021-07-04The mandoc(1) manual already mentions that -T man output modeIngo Schwarze
neither supports tbl(7) nor eqn(7) input. If an input file contains such code anyway, tell the user rather than failing an assert(3)ion. Fixing a crash reported by Bjarni Ingi Gislason <bjarniig at rhi dot hi dot is> in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901636 which the Debian maintainer of mandoc, Michael at Stapelberg dot ch, forwarded to me.
2021-06-28In terminal output of man(7) documents, stop printing two extra blankIngo Schwarze
lines before the NAME section and before the page footer. While these blank lines had a long tradition, they didn't really serve any purpose and merely wasted screen real estate. Besides, this makes output from man(7) more similar to output from mdoc(7). This commit keeps mandoc compatible with groff-current, where G. Branden Robinson committed the same change on June 16 (groff commit 2278d6ed).
2021-06-27add a style message about overlong text lines,Ingo Schwarze
trying very hard to avoid false positives, not at all trying to catch as many cases as possible; feature originally suggested by tb@, OK tb@ kn@ jmc@
2021-06-02In -W style mode, check .Xr links along the full manpath becauseIngo Schwarze
that is more useful for validating manuals of non-base software. Nothing changes in -W all mode: by default for -T lint, we still assume we want to check base system conventions, including usually not wanting to link to non-base manual pages. The use case, a partial idea how to handle it, and a preliminary patch was originally presented by kn@, then refined by me. Final patch tested and OK'ed by kn@.
2021-05-22In revision 1.95 of cgi.c, a meta viewport element was added to the HTML output.anton
Let `mandoc -Thtml' behave the same, makes the generated HTML a bit more pleasant to view on a mobile device. ok schwarze@
2021-05-18When looking for column separators on tbl(7) data lines, properly skipIngo Schwarze
escape sequences; do not misinterpret bytes from the middle of escape sequence names or arguments as column separators. Bug reported and patch tested by Oliver dot Corff at email dot de.
2021-05-16Implement the layout specification "a" (left justify with 1em indentation)Ingo Schwarze
in HTML output mode; before this patch, the indentation was missing. Terminal output already supported the "a" specifier since 2010. Issue reported and patch tested by Oliver dot Corff at email dot de.
2021-05-16implement the tbl(7) layout modifiers "b" (bold) and "i" (italic)Ingo Schwarze
in HTML output mode, similar to tbl_term.c, function tbl_word(); issue reported by Oliver dot Corff at email dot de
2021-05-15When looking for the last layout row used, we need to look at the layoutIngo Schwarze
row used for the previous data line containing data, not at the previous data line outright, which might be a horizontal ruler. If it is, do not restart from the first layout row but still proceed to the next data row, which may have been just read from T&. Bug originally reported by Oliver dot Corff at email dot de on groff at gnu dot org: https://lists.gnu.org/archive/html/groff/2021-03/msg00003.html and forwarded to me by bentley@. Patch OK'ed by bentley@ back in April.
2021-05-01Retire OpenBSD/sgi.Visa Hankala
OK deraadt@
2021-04-28recognise riscv64 as a valid arch in mandocJonathan Gray
ok jmc@ deraadt@
2021-04-04fix spacing issue in macro;Jason McIntyre
2021-03-30In HTML output, correctly render .Bd -unfilled in proportionally-spacedIngo Schwarze
font, rather than with the monospace font appropriate for .Bd -literal. This fixes a minibug reported by anton@. Implemented by no longer relying on the typical browser default of "pre { font-family: monospace }" but instead letting <pre> elements inherit the font family from their parent, then adding an explicit CSS .Li class only for those displays where the manual page author requested it by using the -literal option on the .Bd macro.
2021-02-19Append .html suffix to temporary files enabling browsers to recognise itkn
Occasionally one might read a manual page in a webbrowser, e.g. "MANPAGER=firefox man -T html jq", however temporary files created for pagers lack file extensions and most web browsers are unable to detect a file's content without it. Special case mandoc(1)'s HTML output format by appending the ".html" suffix to file names such that browsers will actually render HTML as such instead of showing it as plain text. Input schwarze
2020-10-30Finally get rid of the "overflow: auto" property of ".Bl-tag > dd"Ingo Schwarze
which has long been know to cause ugly and pointless scroll bars. Matthew Martin <phy1729 at gmail dot com> helpfully explained the following two points to me: 1. What we need to do here is establish a new block formatting context such that the first line of the <dd> content moves down rather than to the right if the preceding <dt> is wide. 2. A comprehensive list of methods to establish block formatting context is available in: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context In that list, i found that "column-count: 1" does the job. It is part of CSS Multi-column Layout Level 1. While that is still in Working Draft status according to https://www.w3.org/Style/CSS/current-work , it is fully supported by all browsers according to https://developer.mozilla.org/en-US/docs/Web/CSS/column-count , probably because it was already part of the second draft of this standard almost 20 years ago: WD-css3-multicol-20010118.
2020-10-30Promote section headers that can can be used unmodified as fragmentIngo Schwarze
identifiers from TAG_WEAK to TAG_STRONG, such that for example ...#DESCRIPTION always works. Suggested by Aman Verma on the discuss@ list.