Ingo Schwarze [Sat, 18 Aug 2018 04:32:10 +0000 (04:32 +0000)]
Massively reduce the amount of text, cutting it down to what is needed
to understand existing man(7) code and deleting parts that would only
be useful for writing new documents, which we strongly discourage:
* Delete the MANUAL STRUCTURE section which merely duplicates mdoc(7).
* Delete internal cross references only useful for writing new code.
* Delete many instances of "included only for compatibility" as the
whole language is only provided for compatibility.
* Fix a few minor errors and omissions.
Ingo Schwarze [Fri, 17 Aug 2018 20:33:37 +0000 (20:33 +0000)]
Remove more pointer arithmetic passing via regions outside the array
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.
Ingo Schwarze [Thu, 16 Aug 2018 15:05:34 +0000 (15:05 +0000)]
Do not calculate a pointer to a memory location before the beginning of
a static array. Christos Zoulas, Robert Elz, and Andreas Gustafsson
point out that is undefined behaviour by the C standard even if we
never access the pointer.
Ingo Schwarze [Thu, 16 Aug 2018 14:07:11 +0000 (14:07 +0000)]
Document \*(.T.
While here, delete the section about predefined strings.
For manual pages, the concept is not important enough to be discussed
in such a prominent place, and some aspects of the text were also
misleading. Add a shorter version of the relevant parts to the
description of the \* escape sequence instead.
Ingo Schwarze [Thu, 16 Aug 2018 13:54:06 +0000 (13:54 +0000)]
Implement the \*(.T predefined string (interpolate device name)
by allowing the preprocessor to pass it through to the formatters.
Used for example by the groff_char(7) manual page.
Ingo Schwarze [Wed, 15 Aug 2018 14:37:41 +0000 (14:37 +0000)]
Change comment: NetBSD just fixed their headers; but leave the
workaround in place for now for the benefit of older systems,
and other systems might contain similar problems.
Ingo Schwarze [Wed, 15 Aug 2018 02:15:52 +0000 (02:15 +0000)]
Autodetect whether _GNU_SOURCE or _OPENBSD_SOURCE are needed; the
latter is a NetBSD idiosyncrasy reported by wiz@. Also take into
account that NetBSD declares getsubopt(3) in the wrong header.
Ingo Schwarze [Fri, 10 Aug 2018 20:40:45 +0000 (20:40 +0000)]
The groff man-ext macros define fonts CB, CI, and CR,
and some groff manual pages actually use them in .ft requests.
It's easy enough to handle these .ft requests in mandoc, too.
Ingo Schwarze [Thu, 9 Aug 2018 17:30:36 +0000 (17:30 +0000)]
If somebody asks "man 3 chmod",
don't respond with the lie: "No entry for chmod in the manual."
Instead, say "No entry for chmod in section 3 of the manual."
Came up after a question from kn@; OK kn@.
Ingo Schwarze [Wed, 8 Aug 2018 14:30:48 +0000 (14:30 +0000)]
Even though we strongly discourage escaping hyphens in manual pages
in general, when introducing the *typographic* term "hyphen",
actually display a real hyphen in output modes supporting it.
Ingo Schwarze [Wed, 8 Aug 2018 14:16:08 +0000 (14:16 +0000)]
Reorder the text in the "Dashes and Hyphens" subsection to keep the
simplest and most important instructions together and at the
beginning. No text change.
Suggested by jmc@.
Ingo Schwarze [Wed, 8 Aug 2018 14:03:27 +0000 (14:03 +0000)]
Clarify the confusing "(text)" annotation in the character lists.
In some cases, it meant "render as an ASCII character in output
modes that have a notion of codepoints" (e.g. UTF-8, HTML); in other
cases, "render in the text font in output modes that also provide
a special font for mathematical symbols" (e.g. PostScript, PDF).
Also explicitly annotate the escape sequences that use a special
font if available.
OK bentley@
Ingo Schwarze [Wed, 8 Aug 2018 13:54:05 +0000 (13:54 +0000)]
After years of deliberation, finally provide a clear recommendation
for hyphens and minus signs in manual pages.
Since there is consensus that a typographically perfect solution is
impossible, let's KISS - just write "-", don't bother with "\-", all
currently relevant manual page formatters can handle "-" reasonably.
OK jmc@ bentley@
Ingo Schwarze [Wed, 1 Aug 2018 16:00:58 +0000 (16:00 +0000)]
Fix an off-by-one string read access that could happen if an empty
string argument preceded a string argument beginning with "--".
Found by Leah Neukirchen <leah at vuxu dot org> with -Wpointer-compare.
Ingo Schwarze [Wed, 1 Aug 2018 15:40:17 +0000 (15:40 +0000)]
After rewriting the parse buffer from scratch, we also have to reset
the parse point to the beginning of the new buffer or we risk out
of bounds accesses. Bug found by Leah Neukirchen <leah at vuxu dot
org> with valgrind on Void Linux.
Ingo Schwarze [Wed, 1 Aug 2018 13:46:15 +0000 (13:46 +0000)]
Avoid a read access one byte beyond the end of an allocated string
which occurred in situations like ".Fl a Cm --"; found by
Leah Neukirchen <leah at vuxu dot org> with valgrind on Void Linux.
more 1.14.4 release preparations:
autodetect whether the compiler can use -W and -static,
clearer output from ./configure,
and adjust some configuration instructions
Issue a STYLE message when normalizing the date format in .Dd/.TH.
Leah Neukirchen pointed out that mdoclint(1) used to warn about a
leading zero before the day number, so we know that both NetBSD and
Void Linux want the message. It does no harm on OpenBSD because
Mdocdate always does the right thing anyway.
jmc@ agrees that it makes sense in contexts not using Mdocdate.
Remove more redundant element selectors where the class selector
is already sufficient. John Gardner tells me that "CSS selectors
should only contain what's necessary to target their subjects".
Ingo Schwarze [Mon, 25 Jun 2018 14:53:58 +0000 (14:53 +0000)]
Get rid of the last explicit length in HTML style= attributes.
Even though style=height is not particularly harmful for responsive
design except for very large arguments which don't really occur in
practice, it is not useful either: nobody should use .sp in manual
pages, in particular not with an argument. Even if somebody does,
ignoring the argument will likely make the output look better rather
than worse. Consequently, simplify by dropping a useless feature.
Ingo Schwarze [Mon, 25 Jun 2018 13:45:57 +0000 (13:45 +0000)]
Do not write <colgroup> elements. Their only purpose is to enforce
author-specified column widths, which can harm responsive design and
provide no real benefit: HTML rendering engines usually do just
fine automatically selecting appropriate column widths.
Ingo Schwarze [Mon, 25 Jun 2018 13:33:04 +0000 (13:33 +0000)]
Ignore author-specified indentation for .RS; it harms responsive
design. Use the existing @media-dependent indent instead.
This removes the last style= attribute from man(7) output.
Ingo Schwarze [Mon, 18 Jun 2018 01:49:15 +0000 (01:49 +0000)]
Revert previous: style=height is still used by roff_html.c, and it
doesn't actually harm responsive design, so keep it for now.
Bug reported in de.comp.os.unix.bsd via naddy@, thanks.
Ingo Schwarze [Sun, 10 Jun 2018 16:15:43 +0000 (16:15 +0000)]
In HTML output, for lists that have an -indent argument, just use
a uniform indentation in CSS adapted to the viewport width and
ignore the value of the argument taken from mdoc(7). While
author-specified widths somewhat work as a micro-optimization in
terminal and typeset output, they are nothing but harmful in HTML
style= attributes because they break responsive design, whereas
using a reasonable default indent almost never results in ugly
output. Admittedly, the author-specified width might occasionally
look even better, but only slightly so, and only for some viewport
sizes.
Based on guidance provided by John Gardner.
Ingo Schwarze [Sun, 10 Jun 2018 15:12:35 +0000 (15:12 +0000)]
When formatting man(7) documents that do not contain .SH macros
with -Tps or -Tpdf, do not squeeze the whole text beyond the right
margin. Bug reported by Will Backman during BSDCan.
Ingo Schwarze [Tue, 29 May 2018 20:32:45 +0000 (20:32 +0000)]
Remove redundant value= attributes from option elements,
and use type=search rather than type=text for the input element
because it tends to better support autocompletion.
Both suggested by John Gardner <gardnerjohng at gmail dot com>.
Ingo Schwarze [Tue, 29 May 2018 01:55:50 +0000 (01:55 +0000)]
Ignore author-specified -width arguments for -tag and -hang lists
in HTML output. For terminal and typeset output, such arguments
kind of work to achieve presentational micro-optimization.
But for HTML, they only do harm.
Large increases usually look ugly. Large reductions are impossible
since the default is not large in the first place. Small tweaks in
either direction are not important; at least not important enough
to justify making responsive design impossible.
Triggered by John Gardner's suggestion to further reduce style=
attributes in the HTML code, in particular those containing hard-coded
lengths.
Ingo Schwarze [Mon, 28 May 2018 15:39:25 +0000 (15:39 +0000)]
John Gardner tells me that among frontend developers, gratuitous use
of double selectors like "element.class" is considered poor style.
When doing selection mainly by elements is not appropriate because
most elements require several different styles, exclusively selecting
by class is less cumbersome, more concise, and more flexible.
So drop the elements from the selectors, except where they are
required for disambiguation and except where they add clarity due
to the presence of child selectors.
Ingo Schwarze [Mon, 28 May 2018 14:13:36 +0000 (14:13 +0000)]
URL-fragment strings can only contain certain characters.
Fixing HTML syntax violations e.g. in pf.conf(5) and ifconfig(8)
reported by Anton Lazarov <lists at wrant dot com>.
Ingo Schwarze [Sat, 26 May 2018 20:04:41 +0000 (20:04 +0000)]
Start with baby steps towards responsive design:
Use a @media width query to select a set of default indentations.
Suggested by John Gardner <gardnerjohng at gmail dot com>.
Ingo Schwarze [Sat, 26 May 2018 17:38:01 +0000 (17:38 +0000)]
Use em units rather than ex units for horizontal lengths.
John Gardner and others tell me it produces more predictable results
and is generally considered better style.
Also use 0em instead of 0ex, in general.
Ingo Schwarze [Fri, 25 May 2018 20:23:51 +0000 (20:23 +0000)]
Do not write duplicate id= attributes, they violate HTML syntax.
Append suffixes for disambiguation. Issue first reported by Jakub
Klinkovsky <j dot l dot k at gmx dot com> (Arch Linux).
Ingo Schwarze [Sun, 20 May 2018 21:37:34 +0000 (21:37 +0000)]
Protect against malicious manual pages containing .ll requests with
excessive arguments: apply the same cutoff as for the -O width=
command line argument.
While here, also place some assertions at strategical places to
prevent excessive indentations from being printed in case of bugs.
In the past, we had more than one bug that caused mandoc to print
effectively infinite output, filling up people's /tmp/ file system,
which is not funny. We cannot prevent bugs from crashing the
program, but we can at least make filling up the disk less likely.
Triggered by a remark from sthen@ on source-changes@.
Ingo Schwarze [Fri, 18 May 2018 14:23:00 +0000 (14:23 +0000)]
In a nutshell, all mobile browsers are broken.
By default, no matter the physical screen size, they use a fixed
viewport width of about 1000px, then scale down the rendered page
to make that huge viewport fit on the physical screen.
That results in poor rendering for bad websites which assume a
large fixed-size viewport (typically requiring zooming in to be able
to actually read any text), but in atrocious rendering for good
websites that make no assumption about the screen size (unreadably
small text in the top left corner, most of the screen empty).
A standard way to disable that insane behaviour and just render
normally on the actual physical screen size does not exist.
The closest thing is the CSS3 Device Adaptation Module Level 1
https://drafts.csswg.org/css-device-adapt/
but https://caniuse.com/#feat=css-deviceadaptation tells me
that basically no browser implements it, not even on mobile.
The next closest thing is the HTML meta viewport element - even though
the problem has nothing to do with HTML and is purely a CSS issue.
Standardization is not even planned for that one:
* HTML 5.2 mentions it in passing without specifying it:
https://www.w3.org/TR/html/document-metadata.html#the-meta-element
* The Web Hypertext Application Technology Working Group
provides very incomplete information:
https://wiki.whatwg.org/wiki/MetaExtensions
* CSS3 Device Adaptation Module Level 1 already wants to deprecate it,
explaining mostly how to migrate *away* from it to some castle in
the sky that no browser implements:
https://drafts.csswg.org/css-device-adapt/#viewport-meta
While i strongly believe in sticking to well-established standards,
in the absence of standards and with atrocious behaviour being
universal, there appears to be no alternative to using whatever
works. The meta viewport element appears to be the only way to
make real-world mobile browsers decently render any HTML page that
does not have a fixed-width layout of 1000px. So use it, grudgingly.
Originally suggested by xcv at dr dot com.
Direction supported by espie@.
Ingo Schwarze [Mon, 14 May 2018 14:10:23 +0000 (14:10 +0000)]
Some broken terminal emulators (e.g. sakura) do the equivalent
of "stty cols 0". Ignore that insanity rather than setting
conf.output.width to an invalid value and embarking on infinite loops.
Issue reported by Jesper Wallin <jesper at ifconfig dot se>, thanks!
Ingo Schwarze [Wed, 9 May 2018 00:46:10 +0000 (00:46 +0000)]
Fix a long-standing issue:
Some macros (Nd, Oo) can contain blocks but rendered as elements that
can only contain phrasing content, resulting in invalid HTML nesting.
Switch them to <div>.
Also move the related "display: inline" style from the HTML to the CSS.
Ingo Schwarze [Tue, 8 May 2018 21:42:34 +0000 (21:42 +0000)]
Eliminate the class=It-* attributes.
Cleaner HTML, more idiomatic CSS, and minus 30 lines of C code.
Suggested by John Gardner <gardnerjohng at gmail dot com>.
Ingo Schwarze [Tue, 8 May 2018 17:52:55 +0000 (17:52 +0000)]
Switch the emitted HTML element from <b> to <code> for the fixed
syntax element macros .Nm, .Fl, .Cm, .Ic, .In, .Fd, .Fn, and .Cd.
Adjust both the internal and external style sheets such that
rendering remains unchanged in typical browsers.
Based on feedback from John Gardner <gardnerjohng at gmail dot com>.
Simpler description of output formats, shortening the manual page by 15 lines.
Avoid the double redirection from -Tutf8 via -Tlocale to -Tascii.
Add LC_CTYPE to the ENVIRONMENT section.
While here, also correct a few inaccuracies and tweak some wordings.
Triggered by a question from Laura Morales <lauretas at mail dot com>.
Better mandoc(1) -I and -T options for Heirloom comparisons.
Filter through col(1) -b for Heirloom because it produces double encoding.
Switch on mandoc(1) -Wall in groff comparisons.
Update usage.
replace my vague and idiosyncratic term "selflink"
with the clearer and more usual "permalink";
suggested by John Gardner <gardnerjohng at gmail dot com>
Avoid the misunderstanding that the essential purpose of -l is
similar to the purpose of the -a option in mandoc(1), which is not
the point: the fact that -l implies -a is merely a minor detail.
The point of -l is to make man(1) behave like mandoc(1).
Move the mention of -a to the end to de-emphasize it.
Nate Bargmann reported that this seriously confused him,
and i can see why.
Compatibility with man-db:
In page name mode (= man(1) default mode), also try to interpret
names containing slashes as absolute or relative file names.
Missing feature reported by Nate Bargmann on <groff at gnu dot org>,
and the man-db maintainer Colin Watson <cjwatson at debian dot org>
kindly explained to me how this is supposed to work.
Use TIOCGWINSZ to reduce the default -Owidth during interactive use
on terminals narrower than 79 columns and the default -Oindent on
terminals narrower than 66 columns.
Requested by and feedback from pirofti@;
mpi@ and juanfra@ also like the general direction.
Make sure that mandoc only goes into UTF-8 mode if the user really
selected UTF-8, not some other multibyte locale. This obviously
makes no difference on OpenBSD but improves portability.
Issue reported by <Nakayama at NetBSD> via wiz@.
preserve comments before .Dd and .TH (typically Copyright and license)
in full HTML output, but not with -Ofragment, e.g. in man.cgi(8);
suggested by Thomas Klausner <wiz at NetBSD>
Two new low-level roff(7) features:
* .nr optional third argument (auto-increment step size)
* \n+ and \n- numerical register auto-increment and -decrement
bentley@ reported on Dec 9, 2013 that lang/sbcl(1) uses these.
When accessing an undefined number register, define it to be zero, like
the previous commit for strings and macros, only technically simpler.
Desired behaviour also mentioned by Werner Lemberg in 2011.
This diff adds functionality but is -21 +19 LOC. :-)
Using an undefined string or macro will cause it to be defined as empty.
Observed by Werner Lemberg on Nov 14, 2011
and rotting on my TODO list ever since.
Do not use a non-portable .R man(7) macro. Neither groff nor the
heirloom-doctools support it. Work around the gap by using .BR
with an empty first argument. This was noticed more than once in
the past, but i always forgot to fix it.
Ingo Schwarze [Fri, 16 Mar 2018 20:41:41 +0000 (20:41 +0000)]
Ouch, fix previous: In the edge case of a single-character string
containing nothing but a single hyphen, the pointer got incremented
twice at one point, causing a read overrun found by naddy@.
Ingo Schwarze [Thu, 15 Mar 2018 18:10:31 +0000 (18:10 +0000)]
Soften the language discouraging special character escape sequences.
After i improved their ASCII renderings in groff and mandoc some time
ago, mathematical symbols can now be used in specialised mathematical
manual pages like libm and some X libraries.
Tweaks and OK jmc@.
Ingo Schwarze [Fri, 23 Feb 2018 21:35:19 +0000 (21:35 +0000)]
After opening a file with gzdopen(3), we have to call gzclose(3) or
we leak memory internally used by zlib to keep compression state.
Bug reported by Wolfgang Mueller <vehk at vehk dot de> who also
provided an incomplete patch, part of which i'm using in this commit.
Ingo Schwarze [Fri, 23 Feb 2018 18:25:57 +0000 (18:25 +0000)]
Logically, the following are are type names - just like .Vt,
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
Ingo Schwarze [Fri, 23 Feb 2018 16:47:10 +0000 (16:47 +0000)]
Invalidate the tag_files.tfd after fclose(3)ing the stram associated
with it. In main() assert that the tfd was actually invalidated.
This avoids closing an invalid fd.
From tb@; OK deraadt@ on an earlier version.
Ingo Schwarze [Wed, 7 Feb 2018 20:31:39 +0000 (20:31 +0000)]
In man(7) and cat pages, cut off excessive one line descriptions.
An extreme example of how rogue files could mess up apropos(1) output
was reported by bentley@: qwtlicense(3) in the x11/qwt port.
Ingo Schwarze [Wed, 7 Feb 2018 20:04:57 +0000 (20:04 +0000)]
Fix the mandoc_strndup() utility function. All existing callers seem
safe so far, but implementing it with an unchecked memcpy(3) is just
wrong and quite dangerous.