]> git.cameronkatri.com Git - mandoc.git/log
mandoc.git
7 years agoSilently ignore invalid -m input formats rather than erroring out.
Ingo Schwarze [Mon, 20 Mar 2017 14:32:24 +0000 (14:32 +0000)]
Silently ignore invalid -m input formats rather than erroring out.
As observed by Jan Stary <hans at stare dot cz>, this is useful such
that after 'alias man="man -m $HOME/man"', 'man -l foo.1' still works.
Simplify and shorten the description of -m, and use .Ic for macros.

7 years agominor issues found with mandoc -Tlint
Ingo Schwarze [Sat, 18 Mar 2017 19:56:01 +0000 (19:56 +0000)]
minor issues found with mandoc -Tlint

7 years agoCorrect description of MANPATH, and a few more improvements
Ingo Schwarze [Sat, 18 Mar 2017 19:51:19 +0000 (19:51 +0000)]
Correct description of MANPATH, and a few more improvements
to the ENVIRONMENT section; OK jmc@

7 years agoSimplify: write HTTP 303 redirects with relative locations.
Ingo Schwarze [Sat, 18 Mar 2017 16:48:24 +0000 (16:48 +0000)]
Simplify: write HTTP 303 redirects with relative locations.
Suggested by bentley@.

Delete the HTTP_HOST configuration variable that is now obsolete.

7 years agoBugfix: use SCRIPT_NAME for .Xr hyperlinks.
Ingo Schwarze [Sat, 18 Mar 2017 16:19:11 +0000 (16:19 +0000)]
Bugfix: use SCRIPT_NAME for .Xr hyperlinks.
Patch from <andreas at AndreasVoegele dot com>.

7 years agoDocument man(1) section selection priority,
Ingo Schwarze [Fri, 17 Mar 2017 17:24:41 +0000 (17:24 +0000)]
Document man(1) section selection priority,
and correct description of apropos(1) output search order.
Suggested by tb@.

7 years agoUpdate HISTORY and AUTHORS: we no longer use SQLite.
Ingo Schwarze [Fri, 17 Mar 2017 12:56:57 +0000 (12:56 +0000)]
Update HISTORY and AUTHORS: we no longer use SQLite.
Outdated information reported by an Anonymous Coward on undeadly.org.

7 years agoFix regression in mdoc_html.c 1.275, man_html 1.134:
Ingo Schwarze [Fri, 17 Mar 2017 12:10:16 +0000 (12:10 +0000)]
Fix regression in mdoc_html.c 1.275, man_html 1.134:
For .Sh, .Ss, .SH, .SS, only write selflink if an id could be constructed.
Crash reported by Raf Czlonka <rczlonka at gmail dot com>,
analysis of root cause by natano@

7 years agoIn URIs in apropos(1) result tables,
Ingo Schwarze [Wed, 15 Mar 2017 13:49:50 +0000 (13:49 +0000)]
In URIs in apropos(1) result tables,
only write the manpath if it does not match the default.

7 years agoMention the manual page name and section in the HTML page <title>.
Ingo Schwarze [Wed, 15 Mar 2017 13:18:53 +0000 (13:18 +0000)]
Mention the manual page name and section in the HTML page <title>.
Based on a patch from <Anton dot Lindqvist at gmail dot com>,
but simplified and also covering apropos(1) search results.

7 years agoMinimal support for deep linking into man(7) pages.
Ingo Schwarze [Wed, 15 Mar 2017 11:29:53 +0000 (11:29 +0000)]
Minimal support for deep linking into man(7) pages.
As the man(7) language does not provide semantic markup,
only .SH, .SS, and .UR become anchors for now.

7 years agoIt's annoying that people keep writing URIs including redundant parts
Ingo Schwarze [Wed, 15 Mar 2017 10:17:29 +0000 (10:17 +0000)]
It's annoying that people keep writing URIs including redundant parts
like "/OpenBSD-current/manN/".  To discourage that, let man.cgi(8)
redirect search form results to nice, concise URIs.

7 years agoSlightly increase widths calculated from string lengths (mainly
Ingo Schwarze [Tue, 14 Mar 2017 01:35:15 +0000 (01:35 +0000)]
Slightly increase widths calculated from string lengths (mainly
for .Bl -tag lists and SYNOPSIS .Nm blocks), such that the text
still fits even if it is printed in bold font.
This is an ugly band aid - but implementing font-dependent width
measurements would be a major project and even more difficult
for HTML than for PostScript.

Issue reported by Jan Stary <hans at stare dot cz>.

7 years agoPort ctags-style, less(1) :t internal searching from terminal output
Ingo Schwarze [Mon, 13 Mar 2017 20:22:18 +0000 (20:22 +0000)]
Port ctags-style, less(1) :t internal searching from terminal output
to HTML output.  For certain macros appearing at the beginning of .It
heads, write HTML id="..." attributes such that deep linking works.
Write HTML <a> attributes such that you can easily copy out link
targets with the mouse.  Try: http://man.openbsd.org/vmctl.8#create

Feature suggested by <guettliml at Thomas dash Guettler dot de>,
some details of the design and implementation by me.

7 years agoPrint title="..." in addition to id="..." attributes for macro keys
Ingo Schwarze [Mon, 13 Mar 2017 19:01:38 +0000 (19:01 +0000)]
Print title="..." in addition to id="..." attributes for macro keys
that can be searched for by apropos(1), such that you see the
semantic function in a tooltip when hovering with the mouse.

7 years agotest infinite recursion in eqn(7) "define" statements
Ingo Schwarze [Sat, 11 Mar 2017 16:04:18 +0000 (16:04 +0000)]
test infinite recursion in eqn(7) "define" statements

7 years agoImprove detection of recursive eqn(7) "define" statements:
Ingo Schwarze [Sat, 11 Mar 2017 15:43:04 +0000 (15:43 +0000)]
Improve detection of recursive eqn(7) "define" statements:
Do not only catch "define key 'key other stuff'",
but also "define key 'other stuff key'".
Fixing infinite loop found by tb@ with afl(1).

7 years agoIn markdown, autolinks are dangerous. Different compilers disagree
Ingo Schwarze [Sat, 11 Mar 2017 12:35:45 +0000 (12:35 +0000)]
In markdown, autolinks are dangerous.  Different compilers disagree
with respect to what constitutes a valid autolink, and if a compiler
deems an autolink invalid, the input turns into an unintended and
potentially harmful raw HTML tag.  So, never write autolinks.
Instead of <link>, write [link](link).
Instead of <addr>, write [addr](mailto:addr).

Issue pointed out by bentley@, who also agrees with the general
direction of the change.

7 years agoReally commit some files that failed to get committed in this commit:
Ingo Schwarze [Thu, 9 Mar 2017 15:33:40 +0000 (15:33 +0000)]
Really commit some files that failed to get committed in this commit:

Now that markdown output is tested for almost everything, test all
input files in -T markdown output mode by default and only mark
those files with SKIP_MARKDOWN that are not to be tested.
Much easier to read, and almost minus 40 lines of Makefile code.

7 years agoFix blunder in previous: we must keep the line parse buffer
Ingo Schwarze [Thu, 9 Mar 2017 15:29:35 +0000 (15:29 +0000)]
Fix blunder in previous:  we must keep the line parse buffer
consistent even when aborting the parsing of the line.  That buffer
is not our own, but owned and reused by mparse_buf_r(), read.c.
Returning without cleanup leaked memory and caused write overruns
of the old, typically much smaller buffer in mparse_buf_r().
Promptly noticed by tb@ with afl(1), using MALLOC_OPTIONS=C.

7 years agoNow that markdown output is tested for almost everything, test all
Ingo Schwarze [Wed, 8 Mar 2017 22:54:22 +0000 (22:54 +0000)]
Now that markdown output is tested for almost everything, test all
input files in -T markdown output mode by default and only mark
those files with SKIP_MARKDOWN that are not to be tested.
Much easier to read, and almost minus 40 lines of Makefile code.

7 years agoDocument that -T markdown produces ASCII output, and the implied
Ingo Schwarze [Wed, 8 Mar 2017 19:40:59 +0000 (19:40 +0000)]
Document that -T markdown produces ASCII output, and the implied
limitations.  Of course, we could write UTF-8 output instead,
but even the CommonMark specification doesn't require parsers
to support that, so portability would be doubtful.

While here, provide a link to the CommonMark specification.

7 years agoThe CommonMark specification wants that opening parentheses
Ingo Schwarze [Wed, 8 Mar 2017 19:23:43 +0000 (19:23 +0000)]
The CommonMark specification wants that opening parentheses
inside link destinations be escaped.
While here, remove the obsolete ESC_PAR.

7 years agoAccording to the CommonMark specification, backslash escapes
Ingo Schwarze [Wed, 8 Mar 2017 18:17:21 +0000 (18:17 +0000)]
According to the CommonMark specification, backslash escapes
and markdown markup do not work inside code spans.

7 years agoThe CommonMark specification allows list markers fo the form "number) "
Ingo Schwarze [Wed, 8 Mar 2017 17:51:58 +0000 (17:51 +0000)]
The CommonMark specification allows list markers fo the form "number) "
as well as "number. ", so escape closing parentheses after leading digits
to improve portability.

7 years agoDo not increment .Bl -enum list markers beyond two digits.
Ingo Schwarze [Wed, 8 Mar 2017 17:40:55 +0000 (17:40 +0000)]
Do not increment .Bl -enum list markers beyond two digits.
Otherwise, we would indent subsequent paragraphs less than
the CommonMark specification requires, harming portability.

7 years ago.Bl -column never gets blank lines between rows
Ingo Schwarze [Wed, 8 Mar 2017 15:08:36 +0000 (15:08 +0000)]
.Bl -column never gets blank lines between rows

7 years agoadd two result files that were forgotten
Ingo Schwarze [Wed, 8 Mar 2017 14:51:40 +0000 (14:51 +0000)]
add two result files that were forgotten

7 years agoenable -T markdown tests of filled displays and tagged lists
Ingo Schwarze [Wed, 8 Mar 2017 14:45:55 +0000 (14:45 +0000)]
enable -T markdown tests of filled displays and tagged lists

7 years agoAdd a blank after ">" when quoting.
Ingo Schwarze [Wed, 8 Mar 2017 14:30:06 +0000 (14:30 +0000)]
Add a blank after ">" when quoting.
If is allowed by markdown syntax and more human-readable.

7 years agoprevent infinite recursion while expanding the arguments
Ingo Schwarze [Wed, 8 Mar 2017 13:18:10 +0000 (13:18 +0000)]
prevent infinite recursion while expanding the arguments
of a user-defined macro; issue found by tb@ with afl(1)

7 years agoIf a user-defined macro is aborted because it exceeds the stack
Ingo Schwarze [Tue, 7 Mar 2017 20:00:08 +0000 (20:00 +0000)]
If a user-defined macro is aborted because it exceeds the stack
limit, usually due to infinite recursion, discard whatever remains
in all those open stack levels.  Otherwise, insane constructions
like the following could generate macros of enormous size, causing
mandoc(1) to die from memory exhaustion:

.de m  \" original macro definition
.m     \" recursion to blow up the stack
.de m  \" definition to be run during the call of .m marked (*)
very long plain text (some kilobytes)
.m     \" expand the above a thousand times while unwinding the stack
..     \" end of the original definition
.m     \" (*) recursively generate a ridiculously large macro
..     \" end of recursively generated definition
.m     \" execute the giant macro, exhausting memory

Very creative abuse found by tb@ with afl(1).

7 years agoEscape blanks at the end of markdown lines
Ingo Schwarze [Tue, 7 Mar 2017 15:31:24 +0000 (15:31 +0000)]
Escape blanks at the end of markdown lines
such that they don't look like output line breaks.

7 years agofix completely empty .Eo: no blank line wanted
Ingo Schwarze [Tue, 7 Mar 2017 14:04:08 +0000 (14:04 +0000)]
fix completely empty .Eo: no blank line wanted

7 years agofix spacing after empty .Fl
Ingo Schwarze [Tue, 7 Mar 2017 13:28:02 +0000 (13:28 +0000)]
fix spacing after empty .Fl

7 years agoimplement .An -split and -nosplit
Ingo Schwarze [Tue, 7 Mar 2017 13:09:27 +0000 (13:09 +0000)]
implement .An -split and -nosplit

7 years agoFix .In formatting in the SYNOPSIS:
Ingo Schwarze [Tue, 7 Mar 2017 12:39:01 +0000 (12:39 +0000)]
Fix .In formatting in the SYNOPSIS:
No &zwnj; in the middle of **, please.

7 years agoUsing .Nd only makes sense in the NAME section.
Ingo Schwarze [Mon, 6 Mar 2017 17:26:04 +0000 (17:26 +0000)]
Using .Nd only makes sense in the NAME section.
Warn if that macro occurs elsewhere.
Triggered by a question from Dag-Erling Smoergrav <des @ FreeBSD>.

7 years agoURIs need different escaping; reported by reyk@
Ingo Schwarze [Mon, 6 Mar 2017 14:58:10 +0000 (14:58 +0000)]
URIs need different escaping; reported by reyk@

7 years agofirst batch of -T markdown tests
Ingo Schwarze [Sun, 5 Mar 2017 19:59:33 +0000 (19:59 +0000)]
first batch of -T markdown tests

7 years agoInfrastructure for -T markdown tests.
Ingo Schwarze [Sun, 5 Mar 2017 19:57:39 +0000 (19:57 +0000)]
Infrastructure for -T markdown tests.

This is needed because -T marksdown is expected to receive less
maintenance than -T ascii, so we need automation to make sure
that regular parser maintenance doesn't break this output mode.

7 years agoRemove a redundant condition in .%T handling, no functional change.
Ingo Schwarze [Sat, 4 Mar 2017 21:41:29 +0000 (21:41 +0000)]
Remove a redundant condition in .%T handling, no functional change.
Found by jsg@ with scan-build.

7 years agoMake the description of -K autodetection easer to understand.
Ingo Schwarze [Sat, 4 Mar 2017 17:17:34 +0000 (17:17 +0000)]
Make the description of -K autodetection easer to understand.
Basic idea suggested by jmc@, OK jmc@.

7 years agoDebian needs relative symlinks not only for manual pages,
Ingo Schwarze [Sat, 4 Mar 2017 16:36:29 +0000 (16:36 +0000)]
Debian needs relative symlinks not only for manual pages,
but also for program files.
Issue reported by Michael <Stapelberg at debian dot org>
and by Markus <Waldeck at gmx dot de>.

7 years agoMarkdown output mode helped us to find the first parser bug (as such,
Ingo Schwarze [Fri, 3 Mar 2017 15:05:48 +0000 (15:05 +0000)]
Markdown output mode helped us to find the first parser bug (as such,
this bug could cause wrong output in other modes as well):
Do not misinterpret tab characters as .Ta macros when they appear
on non-column .It lines in non-column .Bl lists that are nested
inside a parent .Bl -column list.  (Admittedly, such constructions
are not very useful; don't use them!)
Found by tb@ with afl(1) because the resulting tree corruption
triggered an assertion in the markdown output module.

7 years agonew -mdoc -Tmarkdown output mode; OK millert@ reyk@ tb@;
Ingo Schwarze [Fri, 3 Mar 2017 14:23:23 +0000 (14:23 +0000)]
new -mdoc -Tmarkdown output mode; OK millert@ reyk@ tb@;
thanks to reyk@ and to Vsevolod at FreeBSD for suggesting it

7 years agoremove a few redundant conditions that jsg@ found with cppcheck
Ingo Schwarze [Fri, 3 Mar 2017 13:55:31 +0000 (13:55 +0000)]
remove a few redundant conditions that jsg@ found with cppcheck

7 years agoFix a copy-and-paste error that caused man(7) manuals without
Ingo Schwarze [Fri, 3 Mar 2017 13:41:42 +0000 (13:41 +0000)]
Fix a copy-and-paste error that caused man(7) manuals without
a section number in .TH to be misinterpreted as preformatted.
Found by jsg@ with cppcheck.

7 years agoA missing initialization could randomly cause regular expression
Ingo Schwarze [Fri, 3 Mar 2017 13:11:21 +0000 (13:11 +0000)]
A missing initialization could randomly cause regular expression
searches to be case-insensitive that ought to be case sensitive.
Found by jsg@ with scan-build.

7 years agoFix previous: do not access the byte before the string if the string
Ingo Schwarze [Fri, 3 Mar 2017 11:50:49 +0000 (11:50 +0000)]
Fix previous: do not access the byte before the string if the string
is empty; found by jsg@ with afl(1).

7 years agoPledge man.cgi(8).
Ingo Schwarze [Wed, 22 Feb 2017 16:20:01 +0000 (16:20 +0000)]
Pledge man.cgi(8).
Based on a more complicated patch from semarie@.
Sebastien and tb@ both agree with the simplification.

7 years agoSince SQLite is gone, we no longer need the "flock" pledge.
Ingo Schwarze [Wed, 22 Feb 2017 14:58:48 +0000 (14:58 +0000)]
Since SQLite is gone, we no longer need the "flock" pledge.
Patch from semarie@, OK tb@.

7 years agoHandle an odd edge case where .It is preceded by .Sm.
Ingo Schwarze [Wed, 22 Feb 2017 08:54:41 +0000 (08:54 +0000)]
Handle an odd edge case where .It is preceded by .Sm.
NULL dereference in man.cgi reported by Gabriel Guzman <gabe at
guzman dash nunez dot com> on misc@.

7 years agoDebian wants relative, not absolute symlinks for man pages;
Ingo Schwarze [Wed, 22 Feb 2017 00:00:12 +0000 (00:00 +0000)]
Debian wants relative, not absolute symlinks for man pages;
suggested by Michael Stapelberg

7 years agofix spelling error;
Ingo Schwarze [Tue, 21 Feb 2017 23:44:43 +0000 (23:44 +0000)]
fix spelling error;
found by Michael <Stapelberg at debian dot org> with Lintian

7 years agorelease 1.14.1 VERSION_1_14_1
Ingo Schwarze [Tue, 21 Feb 2017 00:37:03 +0000 (00:37 +0000)]
release 1.14.1

7 years agoresolve trivial differences with OpenBSD:
Ingo Schwarze [Sat, 18 Feb 2017 17:29:28 +0000 (17:29 +0000)]
resolve trivial differences with OpenBSD:
* we include <sys/types.h> for size_t, so we don't need <stdint.h>
* sort declarations in read_whole_file()

7 years agoadd some regress targets
Ingo Schwarze [Sat, 18 Feb 2017 15:29:39 +0000 (15:29 +0000)]
add some regress targets

7 years agopreconv_encode() can take a const input buffer;
Ingo Schwarze [Sat, 18 Feb 2017 13:43:52 +0000 (13:43 +0000)]
preconv_encode() can take a const input buffer;
diff from <christos at NetBSD>

7 years agoProvide an uninstall target, to help cleaning up after installing
Ingo Schwarze [Sat, 18 Feb 2017 13:05:43 +0000 (13:05 +0000)]
Provide an uninstall target, to help cleaning up after installing
with the wrong DESTDIR.  Use with care.

7 years agoproper test for O_DIRECTORY
Ingo Schwarze [Sat, 18 Feb 2017 12:24:24 +0000 (12:24 +0000)]
proper test for O_DIRECTORY

7 years agodouble quotes were fixed, finally
Ingo Schwarze [Sat, 18 Feb 2017 11:53:33 +0000 (11:53 +0000)]
double quotes were fixed, finally

7 years agoUse typographic quotes rather than '"' for .Rs %T (no change for -Tascii
Ingo Schwarze [Fri, 17 Feb 2017 19:15:41 +0000 (19:15 +0000)]
Use typographic quotes rather than '"' for .Rs %T (no change for -Tascii
output, of course).  Patch from bentley@ in November 2014.  This can be
committed now because groff merged Anthony's patch yesterday.

7 years agoMany people have been complaining for a long time that ``...'' looks
Ingo Schwarze [Fri, 17 Feb 2017 18:28:06 +0000 (18:28 +0000)]
Many people have been complaining for a long time that ``...'' looks
ugly in -Tascii output.  For that reason, bentley@ submitted patches
to render "..." instead to groff in November 2014 (yes, more than
two years ago).  Carsten Kunze yesterday merged them for the upcoming
groff-1.22.4 release.  Yay!

Consequently, do the same in mandoc: Render \(Lq and \(Rq (which
are used for .Do, .Dq, .Lb, and .St) as '"' in -Tascii output.
All other output modes including -Tutf8 remain unchanged.

7 years agomore tests for .IP/.nf interaction that i forgot to commit
Ingo Schwarze [Fri, 17 Feb 2017 17:43:12 +0000 (17:43 +0000)]
more tests for .IP/.nf interaction that i forgot to commit

7 years agoNo need to cast NULL when assigning it to a variable;
Ingo Schwarze [Fri, 17 Feb 2017 14:45:55 +0000 (14:45 +0000)]
No need to cast NULL when assigning it to a variable;
from Christos Zoulas <christos at NetBSD>.

7 years agoImprove clarity of some casts;
Ingo Schwarze [Fri, 17 Feb 2017 14:43:54 +0000 (14:43 +0000)]
Improve clarity of some casts;
from Christos Zoulas <christos at NetBSD>.

7 years agoMake the directory explicit where source files are located.
Ingo Schwarze [Fri, 17 Feb 2017 14:40:28 +0000 (14:40 +0000)]
Make the directory explicit where source files are located.
This is simple and seems to help the NetBSD build infrastructure.
From Christos Zoulas <christos at NetBSD>.

7 years agoBe consistent in protecting __attribute__ attributes with __;
Ingo Schwarze [Fri, 17 Feb 2017 14:31:52 +0000 (14:31 +0000)]
Be consistent in protecting __attribute__ attributes with __;
from Christos Zoulas <christos @ NetBSD>.

7 years agoFix a read buffer overrun that copied random data from memory into
Ingo Schwarze [Fri, 17 Feb 2017 03:03:03 +0000 (03:03 +0000)]
Fix a read buffer overrun that copied random data from memory into
text nodes when a string passed to deroff() ended in a backslash
and the byte after the terminating NUL was non-NUL, found by tb@
with afl(1).

Invalid bytes so copied with the high bit set could later sometimes
trigger another out of bounds read access to static memory in
roff_strdup(), so add an assertion there to abort safely in case
of similar data corruption.

7 years agoadd $(LN) configuration variable; requested by Michael <Stapelberg@debian.org>
Ingo Schwarze [Thu, 16 Feb 2017 16:09:33 +0000 (16:09 +0000)]
add $(LN) configuration variable; requested by Michael <Stapelberg@debian.org>

7 years agofix previous: stupid typo
Ingo Schwarze [Thu, 16 Feb 2017 15:19:01 +0000 (15:19 +0000)]
fix previous: stupid typo

7 years agoProvide a variable BINM_CATMAN.
Ingo Schwarze [Thu, 16 Feb 2017 15:12:32 +0000 (15:12 +0000)]
Provide a variable BINM_CATMAN.
Suggested by Michael <Stapelberg@debian.org>.

7 years agoSurprisingly, groff does not support scaling units in .Bl -column
Ingo Schwarze [Thu, 16 Feb 2017 14:38:12 +0000 (14:38 +0000)]
Surprisingly, groff does not support scaling units in .Bl -column
column width specifiers, so stop supporting them, too.
As a side effect, this fixes an assertion failure that tb@ found
with afl(1), triggered by: .Bl -column -4n

7 years agoFix rev. 1.280: -O syntax is different in default apropos(1) output
Ingo Schwarze [Thu, 16 Feb 2017 10:56:07 +0000 (10:56 +0000)]
Fix rev. 1.280: -O syntax is different in default apropos(1) output
mode and in other output modes, so do not error out prematurely.
Also sort local variables in main() while here.

7 years agoFix block scoping error if an explicit block is broken by two
Ingo Schwarze [Thu, 16 Feb 2017 09:47:31 +0000 (09:47 +0000)]
Fix block scoping error if an explicit block is broken by two
implicit blocks (.Aq Bq Po .Pc) that left the outer breaker open
and could in exceptional cases, like between .Bl and .It, cause
tree corruption leading to NULL dereference.
Found by tb@ with afl(1).

While here, do not mark intermediate ENDBODY markers as broken.

7 years agoRemove the ENDBODY_NOSPACE flag, simplifying the code.
Ingo Schwarze [Thu, 16 Feb 2017 03:00:23 +0000 (03:00 +0000)]
Remove the ENDBODY_NOSPACE flag, simplifying the code.

Comparing to groff output, it appears that all cases where it was used
and made a difference actually require the opposite, ENDBODY_SPACE.

I have no idea why i added it back in 2010; maybe to compensate for
some other bug that has long been fixed.

7 years agoStyle improvement, no functional change.
Ingo Schwarze [Wed, 15 Feb 2017 15:58:46 +0000 (15:58 +0000)]
Style improvement, no functional change.

As reported by Yuri Pankov, some versions of GCC whine that "tmp"
might be used uninitialized in fts_open(3).  Clearly, that cannot
actually happen, but explicitly setting it to NULL is safer anyway.
While here, rename the badly named variable "tmp" and make the
inner "if" easier to understand.

Feedback and OK guenther@

7 years agoFix previous: I forgot that i had to change the convention how
Ingo Schwarze [Wed, 15 Feb 2017 14:10:08 +0000 (14:10 +0000)]
Fix previous:  I forgot that i had to change the convention how
a node is marked as "not a macro" when unifying the parsers.
Confirmed to work by Sevan Janiyan.

7 years agoDo not access a NULL pointer if a matrix or square root are empty.
Ingo Schwarze [Sun, 12 Feb 2017 14:19:01 +0000 (14:19 +0000)]
Do not access a NULL pointer if a matrix or square root are empty.
Crashes found by tb@ with afl(1).

7 years agoDo not read one element past the end of the static const termacts array.
Ingo Schwarze [Sat, 11 Feb 2017 21:49:50 +0000 (21:49 +0000)]
Do not read one element past the end of the static const termacts array.
Bug found by Sevan Janiyan <venture37 at geeklan dot co dot uk>
who ran the OpenBSD mandoc test suite on Ubuntu on POWER8 (sic!)
and reported that mdoc/Sh/before.in failed in -Tman mode.
If that isn't power testing, i don't know...

7 years agonew regression tests for mdoc_macro.c revs. 1.211-1.215
Ingo Schwarze [Sat, 11 Feb 2017 20:22:35 +0000 (20:22 +0000)]
new regression tests for mdoc_macro.c revs. 1.211-1.215

7 years agoDisable three UTF-8 tests that expose bugs in wcwidth(3) in the
Ingo Schwarze [Sat, 11 Feb 2017 17:53:33 +0000 (17:53 +0000)]
Disable three UTF-8 tests that expose bugs in wcwidth(3) in the
native C libraries of illumos, Oracle Solaris 11, and SunOS 5.10.
While it is useful to catch wcwidth(3) regressions on OpenBSD, the
purpose of the *portable* mandoc regression suite is not to check
the C library of the host system; that would just hide genuine
mandoc portability issues in the noise.  The remaining UTF-8 tests
are still sufficient to establish that mandoc does the right thing.

Issues reported by Sevan Janiyan <venture37 at geeklan dot co dot uk>
after testing on OmniOS.

7 years agoNever look for broken blocks inside blocks that are already closed.
Ingo Schwarze [Sat, 11 Feb 2017 15:47:16 +0000 (15:47 +0000)]
Never look for broken blocks inside blocks that are already closed.
Fixes the last the of tree corruptions sometimes causing NULL dereference
reported by tb@; this one triggered in cases like: .Bl -column .It Pq Ta

7 years agoDo not prematurely close .Nd containing a broken child.
Ingo Schwarze [Sat, 11 Feb 2017 14:11:17 +0000 (14:11 +0000)]
Do not prematurely close .Nd containing a broken child.
Fixes tree corruption leading to NULL dereference
in insane cases like .Oo Oo .Nd .Pq Oc .Oc Oc
found by tb@ with afl(1).

7 years agoDo not prematurely mark intermediate blocks as broken while scanning
Ingo Schwarze [Sat, 11 Feb 2017 13:24:12 +0000 (13:24 +0000)]
Do not prematurely mark intermediate blocks as broken while scanning
backwards.  Only do so when a block is found that is actually broken.
Logic error found while investigating crashes reported by tb@.

7 years agoFor child macros of block-end macros, only scan backwards for pending
Ingo Schwarze [Fri, 10 Feb 2017 22:19:18 +0000 (22:19 +0000)]
For child macros of block-end macros, only scan backwards for pending
breakers unless the parent of the block is already closed.  While
the scanning is needed in cases like ".Ac Bo" for broken Ao, it is
useless and crashy in cases like ".Ac Bc" for non-broken Ao.

This fixes a NULL pointer dereference that tb@ found with afl(1).

7 years agoIn the SYNOPSIS, .Nm blocks can get broken if one of their children
Ingo Schwarze [Fri, 10 Feb 2017 16:20:34 +0000 (16:20 +0000)]
In the SYNOPSIS, .Nm blocks can get broken if one of their children
gets broken.  In that case, mark them as BROKEN and ENDED and make
sure they get closed out together with the child.

Fixes tree corruption leeding to a NULL dereference found by tb@
with afl(1) in: .Sh SYNOPSIS .Bl .Oo .Nm .Bk .Oc .It (where .Bk is
the child and .Oo is the breaker).
A simpler form of the same corruption (without crash) is visible in:
.Sh SYNOPSIS .Ao .Nm .Bo .Ac .Bc text
where the text ended up inside the .Nm (child .Bo, breaker .Ao).

7 years agoIn -Ttree output mode, show the BROKEN node flag and
Ingo Schwarze [Fri, 10 Feb 2017 15:45:28 +0000 (15:45 +0000)]
In -Ttree output mode, show the BROKEN node flag and
provide a -Onoval output option to show the unvalidated tree.

7 years agosame as mandocdb.c rev. 1.196:
Ingo Schwarze [Thu, 9 Feb 2017 20:53:33 +0000 (20:53 +0000)]
same as mandocdb.c rev. 1.196:
for portability, use (char *)NULL in execlp(3) as discussed on tech@
OpenBSD (didn't blow up anywhere yet, but better safe than sorry)

7 years agoIllumos doesn't have O_DIRECTORY. Work around that for now, may
Ingo Schwarze [Thu, 9 Feb 2017 18:46:44 +0000 (18:46 +0000)]
Illumos doesn't have O_DIRECTORY.  Work around that for now, may
fix it better after the 1.14.1 release.  Portability issue reported
by Sevan Janiyan <venture37 at geeklan dot co dot uk>.

7 years agoEscape literal braces in a regular expression.
Ingo Schwarze [Thu, 9 Feb 2017 15:34:28 +0000 (15:34 +0000)]
Escape literal braces in a regular expression.
Deprecated perlre(1) syntax reported by Thomas Klausner and Sevan Janiyan.

7 years agoOn some systems (e.g. Solaris 11) diff(1) does not support -a.
Ingo Schwarze [Wed, 8 Feb 2017 16:56:15 +0000 (16:56 +0000)]
On some systems (e.g. Solaris 11) diff(1) does not support -a.
Make it easier to get rid of it.

7 years agomention that BUILD_CATMAN doesn't work on SunOS 5.9 and 5.10
Ingo Schwarze [Wed, 8 Feb 2017 16:16:08 +0000 (16:16 +0000)]
mention that BUILD_CATMAN doesn't work on SunOS 5.9 and 5.10

7 years agoconfig glue for recvmsg(2) and CMSG_FIRSTHDR(3);
Ingo Schwarze [Wed, 8 Feb 2017 16:11:40 +0000 (16:11 +0000)]
config glue for recvmsg(2) and CMSG_FIRSTHDR(3);
needed for Solaris 11

7 years agosendmsg(3) may block, so retry
Ingo Schwarze [Wed, 8 Feb 2017 14:50:53 +0000 (14:50 +0000)]
sendmsg(3) may block, so retry

7 years agoeven catman needs libmandoc on systems not having fts
Ingo Schwarze [Wed, 8 Feb 2017 13:36:32 +0000 (13:36 +0000)]
even catman needs libmandoc on systems not having fts

7 years agoprotect <err.h> inclusion
Ingo Schwarze [Wed, 8 Feb 2017 13:34:27 +0000 (13:34 +0000)]
protect <err.h> inclusion

7 years agomore 1.14.1 release preparations
Ingo Schwarze [Wed, 8 Feb 2017 12:24:10 +0000 (12:24 +0000)]
more 1.14.1 release preparations

7 years agoreference a relevant mail for one TODO item
Ingo Schwarze [Wed, 8 Feb 2017 12:20:16 +0000 (12:20 +0000)]
reference a relevant mail for one TODO item