]> git.cameronkatri.com Git - mandoc.git/log
mandoc.git
9 years agoclean up post_dt() validation function;
Ingo Schwarze [Mon, 16 Feb 2015 19:02:48 +0000 (19:02 +0000)]
clean up post_dt() validation function;
improved diagnostics, minus six lines of code

9 years agoDelete the -V option. It serves no purpose but keeps confusing people.
Ingo Schwarze [Mon, 16 Feb 2015 16:23:54 +0000 (16:23 +0000)]
Delete the -V option.  It serves no purpose but keeps confusing people.

Keeping track of the versions of installed software is the job of
the package manager, not of the individual binaries.  If individual
binaries include version numbers, that tends to goad people into
writing broken configuration tests that inspect version numbers
instead of properly testing for features.

9 years agostrtonum(3) compat glue
Ingo Schwarze [Mon, 16 Feb 2015 14:56:22 +0000 (14:56 +0000)]
strtonum(3) compat glue

9 years agoClamp width and indent settings to sensible values.
Ingo Schwarze [Mon, 16 Feb 2015 14:11:41 +0000 (14:11 +0000)]
Clamp width and indent settings to sensible values.
Ignore errors for now.
Patch from tedu@.

9 years agoTweak the wording to avoid the possible misunderstanding that .In
Ingo Schwarze [Sun, 15 Feb 2015 17:57:45 +0000 (17:57 +0000)]
Tweak the wording to avoid the possible misunderstanding that .In
could only be used in the SYNOPSIS section.  It is fine anywhere.
Issue noticed by bentley@.

9 years agoshut up about tabs in SYNOPSIS .Fd lines, there is no good way to avoid them
Ingo Schwarze [Sat, 14 Feb 2015 13:23:57 +0000 (13:23 +0000)]
shut up about tabs in SYNOPSIS .Fd lines, there is no good way to avoid them

9 years agoAfter almost five years and 99 revisions, mdoc_macro.c rev. 1.182
Ingo Schwarze [Thu, 12 Feb 2015 13:54:50 +0000 (13:54 +0000)]
After almost five years and 99 revisions, mdoc_macro.c rev. 1.182
finally fixed the four issues explained in the mdoc_macro.c rev. 1.83
commit message.

9 years agoDo not confuse .Bl -column lists that just broken another block
Ingo Schwarze [Thu, 12 Feb 2015 13:00:52 +0000 (13:00 +0000)]
Do not confuse .Bl -column lists that just broken another block
with newly opened .Bl -column lists;
fixing an assertion failure jsg@ found with afl:
test case #481, Bl It Bl -column It Bd El text text El

9 years agoDelete the mdoc_node.pending pointer and the function calculating
Ingo Schwarze [Thu, 12 Feb 2015 12:24:33 +0000 (12:24 +0000)]
Delete the mdoc_node.pending pointer and the function calculating
it, make_pending(), which was the most difficult function of the
whole mdoc(7) parser.  After almost five years of maintaining this
hellhole, i just noticed the pointer isn't needed after all.

Blocks are always rewound in the reverse order they were opened;
that even holds for broken blocks.  Consequently, it is sufficient
to just mark broken blogs with the flag MDOC_BROKEN and breaking
blocks with the flag MDOC_ENDED.  When rewinding, instead of iterating
the pending pointers, just iterate from each broken block to its
parents, rewinding all that are MDOC_ENDED and stopping after
processing the first ancestor that it not MDOC_BROKEN.  For ENDBODY
markers, use the mdoc_node.body pointer in place of the former
mdoc_node.pending.

This also fixes an assertion failure found by jsg@ with afl,
test case #467 (Bo Bl It Bd Bc It), where (surprise surprise)
the pending pointer got corrupted.

Improved functionality, minus one function, minus one struct field,
minus 50 lines of code.

9 years agodo not access a NULL pointer if an .Eo block lacks a tail;
Ingo Schwarze [Wed, 11 Feb 2015 14:15:12 +0000 (14:15 +0000)]
do not access a NULL pointer if an .Eo block lacks a tail;
found by jsg@ with afl, test case #16

9 years agoexplicit blocks close out .Nd; fixing data structure corruption
Ingo Schwarze [Wed, 11 Feb 2015 13:37:57 +0000 (13:37 +0000)]
explicit blocks close out .Nd; fixing data structure corruption
eventually leading to NULL pointer access;
found by jsg@ with afl, text case #455.

9 years agoBe more careful to not generate empty .In, .St, and .Xr nodes.
Ingo Schwarze [Tue, 10 Feb 2015 17:47:45 +0000 (17:47 +0000)]
Be more careful to not generate empty .In, .St, and .Xr nodes.
That could happen when their first argument was another called macro,
causing a NULL pointer access in .St validation found by jsg@ with afl.

Make in_line_argn() easier to understand by using one state
variable rather than two.

9 years agoDo not read past the end of the buffer if an "f" layout font modifier
Ingo Schwarze [Tue, 10 Feb 2015 11:03:13 +0000 (11:03 +0000)]
Do not read past the end of the buffer if an "f" layout font modifier
is followed by the end of the input line instead of a font specifier.
Found by jsg@ with afl, test case #591.

While here, improve functionality as well:
* There is no "r" font modifier.
* Font specifiers (as opposed to font modifiers) are case sensitive.
* One-character font specifiers require trailing whitespace.
* Ignore parenthised and two-letter font specifiers.

9 years agotrim trailing white space, no code change;
Ingo Schwarze [Tue, 10 Feb 2015 08:05:30 +0000 (08:05 +0000)]
trim trailing white space, no code change;
from Svyatoslav Mishyn <juef at openmailboxd dot org>, Crux Linux

9 years agoClosing a block validates it, which may end up deleting it,
Ingo Schwarze [Sat, 7 Feb 2015 16:42:33 +0000 (16:42 +0000)]
Closing a block validates it, which may end up deleting it,
so if we are in a loop over blocks, cleanly restart the loop
rather than risking use after free; found by jsg@ with afl.

9 years agosome tweaks to the DIAGNOSTICS section
Ingo Schwarze [Sat, 7 Feb 2015 15:15:20 +0000 (15:15 +0000)]
some tweaks to the DIAGNOSTICS section

9 years agoignore O_CLOEXEC when the operating system doesn't provide it;
Ingo Schwarze [Sat, 7 Feb 2015 07:53:01 +0000 (07:53 +0000)]
ignore O_CLOEXEC when the operating system doesn't provide it;
needed for some older versions of SunOS;
from jperkin@ via wiz@, both at NetBSD

9 years agotrivial sync to OpenBSD: <sys/param.h> no longer needed
Ingo Schwarze [Sat, 7 Feb 2015 07:42:56 +0000 (07:42 +0000)]
trivial sync to OpenBSD: <sys/param.h> no longer needed

9 years agobe more careful about argc == 0
Ingo Schwarze [Sat, 7 Feb 2015 06:28:08 +0000 (06:28 +0000)]
be more careful about argc == 0

9 years agoreplace the last legacy generic message type, "argument count wrong",
Ingo Schwarze [Fri, 6 Feb 2015 16:06:25 +0000 (16:06 +0000)]
replace the last legacy generic message type, "argument count wrong",
by more specific messages, improving diagnostics for .cc .tr .Bl -column

9 years agobetter error reporting regarding .OP .RS .UR .TH arguments
Ingo Schwarze [Fri, 6 Feb 2015 11:54:36 +0000 (11:54 +0000)]
better error reporting regarding .OP .RS .UR .TH arguments

9 years agobetter diagnostics about excess arguments to .PD .ft .sp
Ingo Schwarze [Fri, 6 Feb 2015 09:38:43 +0000 (09:38 +0000)]
better diagnostics about excess arguments to .PD .ft .sp

9 years agobetter error reporting for .br .fi .nf with arguments
Ingo Schwarze [Fri, 6 Feb 2015 08:28:35 +0000 (08:28 +0000)]
better error reporting for .br .fi .nf with arguments

9 years agoDelete the legacy generic warning type MANDOCERR_ARGCWARN,
Ingo Schwarze [Fri, 6 Feb 2015 07:13:14 +0000 (07:13 +0000)]
Delete the legacy generic warning type MANDOCERR_ARGCWARN,
replacing the last instances by more specific warnings.
Improved functionality, minus 50 lines of code.

9 years agobetter handle .Fo and .Fd without argument
Ingo Schwarze [Fri, 6 Feb 2015 03:38:45 +0000 (03:38 +0000)]
better handle .Fo and .Fd without argument
better handle .Fo with more than one argument

9 years agobetter handle empty .Bd .Bl .D1 .Dl blocks
Ingo Schwarze [Fri, 6 Feb 2015 02:04:54 +0000 (02:04 +0000)]
better handle empty .Bd .Bl .D1 .Dl blocks

9 years agobetter handle .In .Sh .Ss .St .Xr without arguments
Ingo Schwarze [Fri, 6 Feb 2015 01:07:22 +0000 (01:07 +0000)]
better handle .In .Sh .Ss .St .Xr without arguments

9 years agofix handling of empty .An macros
Ingo Schwarze [Thu, 5 Feb 2015 01:46:56 +0000 (01:46 +0000)]
fix handling of empty .An macros

9 years agoSimplify by deleting the "lastline" member of struct mdoc_node.
Ingo Schwarze [Thu, 5 Feb 2015 00:14:13 +0000 (00:14 +0000)]
Simplify by deleting the "lastline" member of struct mdoc_node.
Minus one struct member, minus 17 lines of code, no functional change.

9 years agoDiscard excess head arguments for .Bd .Bl .Bk and delete hwarn_eq0().
Ingo Schwarze [Wed, 4 Feb 2015 22:30:10 +0000 (22:30 +0000)]
Discard excess head arguments for .Bd .Bl .Bk and delete hwarn_eq0().
Discard empty .Bk blocks.
Improve related diagnostics.

9 years agoimprove diagnostics regarding arguments of .An .Pp .Lp .br .sp
Ingo Schwarze [Wed, 4 Feb 2015 19:20:12 +0000 (19:20 +0000)]
improve diagnostics regarding arguments of .An .Pp .Lp .br .sp
in particular, get rid of check_count(..., CHECK_EQ, 0)

9 years agofix column numbers of macro arguments in messages
Ingo Schwarze [Wed, 4 Feb 2015 18:59:45 +0000 (18:59 +0000)]
fix column numbers of macro arguments in messages

9 years agodiscard .Rs head arguments and improve .Rs diagnostics
Ingo Schwarze [Wed, 4 Feb 2015 18:03:47 +0000 (18:03 +0000)]
discard .Rs head arguments and improve .Rs diagnostics

9 years agomore specific .Nd diagnostics, allowing to get rid of enum check_lvl
Ingo Schwarze [Wed, 4 Feb 2015 16:38:56 +0000 (16:38 +0000)]
more specific .Nd diagnostics, allowing to get rid of enum check_lvl
and the respective argument of check_count()

9 years agoEnable the integrated man(1) even when database support is disabled,
Ingo Schwarze [Tue, 3 Feb 2015 21:16:02 +0000 (21:16 +0000)]
Enable the integrated man(1) even when database support is disabled,
using the file system lookup fallback code, also reducing the number
of preprocessor conditional directives.
Hopefully, it will make some small Linux distros happy.

9 years agoreduce indentation for better readability
Ingo Schwarze [Tue, 3 Feb 2015 18:37:59 +0000 (18:37 +0000)]
reduce indentation for better readability

9 years agoAvoid closing out an explicit block twice when broken by .It
Ingo Schwarze [Tue, 3 Feb 2015 18:22:05 +0000 (18:22 +0000)]
Avoid closing out an explicit block twice when broken by .It
(assertion failure); regression found in jsg@'s afl test case 847.

9 years agominimal support for Heirloom nroff
Ingo Schwarze [Tue, 3 Feb 2015 15:52:08 +0000 (15:52 +0000)]
minimal support for Heirloom nroff

9 years agoFinally delete the kitchensink functions rew_sub() and rew_dohalt().
Ingo Schwarze [Tue, 3 Feb 2015 01:14:12 +0000 (01:14 +0000)]
Finally delete the kitchensink functions rew_sub() and rew_dohalt().
They were a maintenance and auditing nightmare because if you changed
one bit in there, stuff tended to break at seemingly unrelated places.
No functional change except getting rid of one bogus error message,
but minus 80 lines of code.

9 years agoBring .Pp/.Lp handling inside .Nm blocks closer to groff;
Ingo Schwarze [Tue, 3 Feb 2015 00:48:47 +0000 (00:48 +0000)]
Bring .Pp/.Lp handling inside .Nm blocks closer to groff;
as a bonus, get rid of another call to rew_sub().

9 years agoSimplify and reindent make_pending(). No functional change
Ingo Schwarze [Mon, 2 Feb 2015 19:23:23 +0000 (19:23 +0000)]
Simplify and reindent make_pending().  No functional change
except that some error messages become less confusing.
Now the function is almost readable (but still requires
nineteen lines of comments for fourteen lines of code).

9 years agoSimplify: Do not call rew_dohalt() from make_pending(),
Ingo Schwarze [Mon, 2 Feb 2015 18:26:32 +0000 (18:26 +0000)]
Simplify: Do not call rew_dohalt() from make_pending(),
the calling macro handler already found the breaking block.
No functional change except tiny variations in error messages.

9 years agoGet rid of all remaining calls to rew_sub() where the target block
Ingo Schwarze [Mon, 2 Feb 2015 15:02:49 +0000 (15:02 +0000)]
Get rid of all remaining calls to rew_sub() where the target block
is known.  This only leaves three that do actual searching.
No functional change, minus 30 lines of code.

9 years agoGet rid of all calls to rew_sub() in blk_exp_close(); only ten calls
Ingo Schwarze [Mon, 2 Feb 2015 04:26:44 +0000 (04:26 +0000)]
Get rid of all calls to rew_sub() in blk_exp_close(); only ten calls
remain in other functions.  As a bonus, this fixes an assertion failure
jsg@ found some time ago with afl (test case 982) and improves minor
details in error reporting.

9 years agoWhen a full block macro gets closed out by a mismatching
Ingo Schwarze [Mon, 2 Feb 2015 04:04:45 +0000 (04:04 +0000)]
When a full block macro gets closed out by a mismatching
block closure macro it calls, do not attempt to open its body.
This can for example happen for (nonsensical) constructions like
.Fo
.Nm Fc
in the SYNOPSIS.  Fixing an assertion failure jsg@ found with afl
some time ago (test case number 731).

9 years agoget rid of rew_sub() in blk_part_imp(); no functional change
Ingo Schwarze [Sun, 1 Feb 2015 23:56:37 +0000 (23:56 +0000)]
get rid of rew_sub() in blk_part_imp(); no functional change

9 years agofix .Eo/.Ec spacing
Ingo Schwarze [Sun, 1 Feb 2015 23:10:35 +0000 (23:10 +0000)]
fix .Eo/.Ec spacing

9 years agoSimplify blk_part_exp(), no functional change.
Ingo Schwarze [Sun, 1 Feb 2015 17:30:45 +0000 (17:30 +0000)]
Simplify blk_part_exp(), no functional change.
* Replace calls to rew_sub() with rew_last() - two less out of 18.
* No need to keep track of the body, it's always opened right after
the head and never used for anything in this function.

9 years agoThe function rew_sub() tries to rewind any all all kinds of blocks
Ingo Schwarze [Sun, 1 Feb 2015 16:47:39 +0000 (16:47 +0000)]
The function rew_sub() tries to rewind any all all kinds of blocks
and elements under any and all circumstances, even handling some
bad block nesting now and then.  Little surprisingly, this ends up
in excessive complexity and has caused many bugs in the past.
Start to slowly disentangle this mess by replacing calls to rew_sub()
immediately following mdoc_head_alloc() by the much simpler rew_last().
Gets rid of the first two rew_sub() calls out of twenty.
No functional change.

9 years agoUse relative offsets instead of absolute pointers for the terminal
Ingo Schwarze [Sat, 31 Jan 2015 00:12:41 +0000 (00:12 +0000)]
Use relative offsets instead of absolute pointers for the terminal
font stack.  The latter fail after the stack is grown with realloc().
Fixing an assertion failure found by jsg@ with afl some time ago
(test case number 51).

9 years agoHave pity on the poor stack.
Ingo Schwarze [Fri, 30 Jan 2015 22:04:44 +0000 (22:04 +0000)]
Have pity on the poor stack.
Replace tail recursion by iteration when walking the syntax trees.
No functional change.

9 years agostarting a tbl(7) breaks man(7) next-line scope;
Ingo Schwarze [Fri, 30 Jan 2015 21:28:46 +0000 (21:28 +0000)]
starting a tbl(7) breaks man(7) next-line scope;
triggered by a bug report from jsg@

9 years agoDelete the redundant tbl span flags, just inspect the actual data
Ingo Schwarze [Fri, 30 Jan 2015 17:32:16 +0000 (17:32 +0000)]
Delete the redundant tbl span flags, just inspect the actual data
where needed, which is less fragile.
This fixes a subtle NULL pointer access to tp->tbl.cols:
Due to a bug in the man(7) parser, the first span of a table can
end up in a .TP head, in which case tblcalc() was never called.
Found by jsg@ with afl.

9 years agoAbolish struct tbl_head and replace it by an "int col" member in
Ingo Schwarze [Fri, 30 Jan 2015 04:11:50 +0000 (04:11 +0000)]
Abolish struct tbl_head and replace it by an "int col" member in
struct tbl_cell.  No functional change, minus 40 lines of code.

9 years agoAuditing the tbl(7) code for more NULL pointer accesses, i came out
Ingo Schwarze [Fri, 30 Jan 2015 02:09:04 +0000 (02:09 +0000)]
Auditing the tbl(7) code for more NULL pointer accesses, i came out
empty-handed; so this is just KNF and some code simplifications,
no functional change.

9 years agoMake sure every layout line contains at least one cell;
Ingo Schwarze [Fri, 30 Jan 2015 00:29:30 +0000 (00:29 +0000)]
Make sure every layout line contains at least one cell;
fixing a NULL pointer access in term_tbl() that jsg@ found with afl.

9 years agocorrectly handle table layout lines starting with a dot
Ingo Schwarze [Fri, 30 Jan 2015 00:19:46 +0000 (00:19 +0000)]
correctly handle table layout lines starting with a dot

9 years agoRadical cleanup of COMPATIBILITY sections:
Ingo Schwarze [Thu, 29 Jan 2015 00:33:57 +0000 (00:33 +0000)]
Radical cleanup of COMPATIBILITY sections:
Remove lots of lies, dozens of irrelevant implementation details,
and all references to groff versions older than 1.17.  Move relevant
information to the pages where it belongs, and out of mandoc(1) in
particular.  Add some missing general remarks to roff(7), where it
fits the character and purpose of the page much better.

9 years agoClean up eqn(7) error handling:
Ingo Schwarze [Wed, 28 Jan 2015 21:11:53 +0000 (21:11 +0000)]
Clean up eqn(7) error handling:
* When "define" fails, do not drop the whole equation.
* Free memory after "undef".
* Use standard mandoc error types instead of rolling our own.
* Delete obfuscating EQN_MSG() macro.
* Add function prototypes while here.

9 years ago* Polish tbl(7) error reporting.
Ingo Schwarze [Wed, 28 Jan 2015 17:32:07 +0000 (17:32 +0000)]
* Polish tbl(7) error reporting.
* Do not print out macro names in tbl(7) data blocks.
* Like with GNU tbl, let empty tables cause a blank line.
* Avoid producing empty tables in -Tman.

9 years agoFor now, it can't be helped that mandoc tbl(7) ignores high-level macros,
Ingo Schwarze [Wed, 28 Jan 2015 15:03:45 +0000 (15:03 +0000)]
For now, it can't be helped that mandoc tbl(7) ignores high-level macros,
but stop throwing away their arguments.  This fixes information loss in a
handful of Xenocara manuals, at the price of a small amount of formatting
noise creeping through.

9 years agoimplement the tbl(7) "center" layout option
Ingo Schwarze [Wed, 28 Jan 2015 04:19:35 +0000 (04:19 +0000)]
implement the tbl(7) "center" layout option

9 years agoadjust formatting for the tbl(7) layout 'x' modifier (maximize column)
Ingo Schwarze [Wed, 28 Jan 2015 02:23:49 +0000 (02:23 +0000)]
adjust formatting for the tbl(7) layout 'x' modifier (maximize column)
to match groff for up to six maximized columns

9 years agoMultiple parser and formatter fixes for line drawing in tbl(7).
Ingo Schwarze [Tue, 27 Jan 2015 05:21:44 +0000 (05:21 +0000)]
Multiple parser and formatter fixes for line drawing in tbl(7).
* Allow mixing vertical line bars with the layout options
of the preceding layout cell.
* Correctly combine box options with layout lines.
* Correctly print vertical lines in data rows, with the right spacing.
* Correctly print cross markers and left and right ends of
horizontal lines even if vertical lines differ above and below.
* Avoid the bogus error message "no table data cells"
when a table data section starts with a horizontal line.
No increase in code size.

9 years agoRework tbl(7) layout parsing:
Ingo Schwarze [Mon, 26 Jan 2015 18:42:30 +0000 (18:42 +0000)]
Rework tbl(7) layout parsing:
* Continue parsing even if part of the input is invalid.
* Do not require whitespace between cell specifications.
* Allow tabs as well as blanks between modifiers.
* Mark the 'm' modifier as unsupported.
* Parse and ignore the 'p' and 'v' modifiers.
* Better warning and error messages.
* Get rid of a static buffer.
Improved functionality but minus 50 lines of code.

9 years agoMore improvements regarding tbl(7) options.
Ingo Schwarze [Mon, 26 Jan 2015 13:03:48 +0000 (13:03 +0000)]
More improvements regarding tbl(7) options.
* Treat "allbox" as an alias for "box" for now.
* Parse and ignore the GNU tbl "nowarn" option.
* For separation, allow spaces, tabs, and commas only.
* Mark eqn(7) within tbl(7) as unsupported.
* Simplify the option table.
* Improve and sort documentation.

9 years agoImprove (or rather, rewrite) tbl(7) option parsing.
Ingo Schwarze [Mon, 26 Jan 2015 00:57:22 +0000 (00:57 +0000)]
Improve (or rather, rewrite) tbl(7) option parsing.
* Allow the layout to start after the semicolon on the options line.
* Ignore leading commas.
* Option arguments cannot contain closing parentheses.
* Avoid needless UNSUPP messages.
* Better ERROR reporting.
* Delete unused "linesize" field in struct tbl_opts.
* No need for static buffers.
* Garbage collect one almost empty wrapper function.
Improved functionality, but minus 40 lines of code.

9 years agopreserve .PP before .RE; effect found in audio/pms(1)
Ingo Schwarze [Sat, 24 Jan 2015 10:08:53 +0000 (10:08 +0000)]
preserve .PP before .RE; effect found in audio/pms(1)

9 years agoStrangely, ignoring the roff(7) .na request was implemented in the man(7)
Ingo Schwarze [Sat, 24 Jan 2015 02:41:49 +0000 (02:41 +0000)]
Strangely, ignoring the roff(7) .na request was implemented in the man(7)
parser.  Simplify the code by moving it into the roff(7) parser, also
making it work for mdoc(7).

9 years agochange .Cm to .Ar for macro arguments
Ingo Schwarze [Sat, 24 Jan 2015 02:14:46 +0000 (02:14 +0000)]
change .Cm to .Ar for macro arguments

9 years agoSupport .RE with an argument; needed for audio/pms(1).
Ingo Schwarze [Sat, 24 Jan 2015 01:58:33 +0000 (01:58 +0000)]
Support .RE with an argument; needed for audio/pms(1).

9 years agonew task: escape blank at the beginning of a line
Ingo Schwarze [Sat, 24 Jan 2015 01:45:21 +0000 (01:45 +0000)]
new task: escape blank at the beginning of a line

9 years agoimprove homebrew cellar config example
Ingo Schwarze [Fri, 23 Jan 2015 21:59:31 +0000 (21:59 +0000)]
improve homebrew cellar config example

9 years agoWhile ignoring the .ta (set tab stops) and .ti (temp indent) requests
Ingo Schwarze [Fri, 23 Jan 2015 20:18:40 +0000 (20:18 +0000)]
While ignoring the .ta (set tab stops) and .ti (temp indent) requests
is sometimes harmless, it often causes seriously ugly output,
so flag these requests as unsupported rather than ignoring them.
Discussed with naddy@.

9 years agoLet .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"
Ingo Schwarze [Fri, 23 Jan 2015 14:21:01 +0000 (14:21 +0000)]
Let .Aq/.Ao/.Ac print "<>" instead of the normal "\(la\(ra"
when the only child is .Mt, not when the preceding node is .An,
to improve robustness.  Triggered by a question from Svyatoslav
Mishyn <juef at openmailbox dot org> (Crux Linux).

9 years agoWonders of roff(7): Integer numbers in numerical expressions can carry
Ingo Schwarze [Fri, 23 Jan 2015 00:42:00 +0000 (00:42 +0000)]
Wonders of roff(7): Integer numbers in numerical expressions can carry
scaling units, and some manuals (e.g. in devel/grcs) actually use that,
so let's support it.  Missing feature reported by naddy@.

9 years agoSlightly improve \w width measurements:
Ingo Schwarze [Thu, 22 Jan 2015 22:51:43 +0000 (22:51 +0000)]
Slightly improve \w width measurements:
Count special characters with the same width as ASCII characters
and treat all other escape sequences as if they had a width of 0.
Certainly not perfect, but a bit better.
For example, GNU RCS ci(1) needs this; reported by naddy@.

9 years agoTraditional roff(7) explicitly allows certain control characters
Ingo Schwarze [Thu, 22 Jan 2015 21:38:16 +0000 (21:38 +0000)]
Traditional roff(7) explicitly allows certain control characters
in the input stream (SOH, STX, ETX, ENQ, ACK, BEL, BS) for specific
purposes (leaders, backspace, delimiters, .tr), but making sure
these don't leak through to the output is tricky, so mark them as
unsupported for now.

9 years agoDon't let a failing mparse_open() clobber the filename pointer;
Ingo Schwarze [Thu, 22 Jan 2015 19:26:50 +0000 (19:26 +0000)]
Don't let a failing mparse_open() clobber the filename pointer;
fixes error message content and a use after free
for .so with non-existent target when -Wall or -Tlint is given.

9 years agoimprove wording; patch from jmc@
Ingo Schwarze [Thu, 22 Jan 2015 00:09:03 +0000 (00:09 +0000)]
improve wording; patch from jmc@

9 years agoSupport homebrew-style linking on Mac OS X.
Ingo Schwarze [Wed, 21 Jan 2015 22:41:49 +0000 (22:41 +0000)]
Support homebrew-style linking on Mac OS X.
Idea found together with Alexis Hildebrandt <surryhill at gmail dot com>.

9 years agoRudimentary implementation of the roff(7) \o escape sequence (overstrike).
Ingo Schwarze [Wed, 21 Jan 2015 20:33:25 +0000 (20:33 +0000)]
Rudimentary implementation of the roff(7) \o escape sequence (overstrike).
This is of some relevance because the pod2man(1) preamble abuses it
for the icelandic letter Thorn, instead of simply using \(TP and \(Tp.
Missing feature found by sthen@ in DateTime::Locale::is_IS(3p).

9 years agoImprove overstriking. When overstriking a wider character with a
Ingo Schwarze [Wed, 21 Jan 2015 19:40:54 +0000 (19:40 +0000)]
Improve overstriking.  When overstriking a wider character with a
narrower one, center the latter horizontally.  After a group of
characters printed in the same position, advance by the width of
the widest one among them.

9 years agopass empty request lines through to tbl(7); sometimes, they end a layout
Ingo Schwarze [Wed, 21 Jan 2015 02:16:52 +0000 (02:16 +0000)]
pass empty request lines through to tbl(7); sometimes, they end a layout

9 years agoblank lines in tables do not need special handling; simplifies code
Ingo Schwarze [Wed, 21 Jan 2015 00:47:04 +0000 (00:47 +0000)]
blank lines in tables do not need special handling; simplifies code
and reduces groff/mandoc differences in OpenBSD base by about 1%

9 years agotypo fixes from jmc@
Ingo Schwarze [Tue, 20 Jan 2015 22:45:07 +0000 (22:45 +0000)]
typo fixes from jmc@

9 years agoSplit the -Werror message level into -Werror (broken manual, probably
Ingo Schwarze [Tue, 20 Jan 2015 21:16:51 +0000 (21:16 +0000)]
Split the -Werror message level into -Werror (broken manual, probably
using mandoc is better than using groff) and -Wunsupp (manual using
unsupported low-level roff(7) feature, probably using groff is better
than using mandoc).  Once this feature is complete, it is intended
to help porting, making the decision whether to USE_GROFF easier.

As a first step, distinguish four classes of roff(7) requests:
1. Supported (currently 24 requests)
2. Currently ignored because unimportant (120)  ->  no message
3. Ignored for good because insecure (14)  ->  -Werror
4. Currently unsupported (68)  ->  these trigger the new -Wunsupp messages

9 years agochange spelling of centre to center: consistent with other man pages
Ingo Schwarze [Tue, 20 Jan 2015 19:39:34 +0000 (19:39 +0000)]
change spelling of centre to center: consistent with other man pages
and the name of the syntax elements being described; from tedu@

9 years agoMake the man(1) and apropos(1) options -s and -S much less expensive:
Ingo Schwarze [Tue, 20 Jan 2015 18:21:18 +0000 (18:21 +0000)]
Make the man(1) and apropos(1) options -s and -S much less expensive:
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!

10 years agoLet man(1) show manuals for the current architecture by default,
Ingo Schwarze [Fri, 16 Jan 2015 21:15:05 +0000 (21:15 +0000)]
Let man(1) show manuals for the current architecture by default,
and support the MACHINE environment variable as documented in man(1).
Missing feature reported by pascal@.

10 years agoParse and ignore .IX (generate index entry) macros because pod2man(1)
Ingo Schwarze [Fri, 16 Jan 2015 16:53:49 +0000 (16:53 +0000)]
Parse and ignore .IX (generate index entry) macros because pod2man(1)
emits them, by default without defining them, relying on the roff(7)
quirk that undefined macros have no effect.

10 years agoFatal errors no longer exist.
Ingo Schwarze [Thu, 15 Jan 2015 04:26:39 +0000 (04:26 +0000)]
Fatal errors no longer exist.
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.

10 years agodowngrade .so failure from FATAL to ERROR
Ingo Schwarze [Thu, 15 Jan 2015 02:29:26 +0000 (02:29 +0000)]
downgrade .so failure from FATAL to ERROR

10 years agodowngrade ".so with absolute path" from FATAL to ERROR;
Ingo Schwarze [Wed, 14 Jan 2015 22:58:16 +0000 (22:58 +0000)]
downgrade ".so with absolute path" from FATAL to ERROR;
allows to get rid of ROFF_ERR

10 years agosimplify by getting rid of ROFF_ERR in tbl(7) parsing; no functional change
Ingo Schwarze [Wed, 14 Jan 2015 22:44:55 +0000 (22:44 +0000)]
simplify by getting rid of ROFF_ERR in tbl(7) parsing; no functional change

10 years agoTo get rid of SYSERR entries in enum mandocerr, downgrade problems with
Ingo Schwarze [Wed, 14 Jan 2015 22:02:49 +0000 (22:02 +0000)]
To get rid of SYSERR entries in enum mandocerr, downgrade problems with
missing and unreadable files from SYSERR to ERROR.
Needed for upcoming work.
As a bonus, this minimally simplifies code and documentation.

10 years agoif earlier files set a non-zero exit status,
Ingo Schwarze [Wed, 14 Jan 2015 21:27:17 +0000 (21:27 +0000)]
if earlier files set a non-zero exit status,
do not allow later files to reset it to zero

10 years agoSimplify handling of system errors: just exit(3).
Ingo Schwarze [Wed, 14 Jan 2015 17:49:15 +0000 (17:49 +0000)]
Simplify handling of system errors: just exit(3).
We already do the same for malloc(3) failure.
The is no virtue in trying to survive failure of fork(2) and the like.

10 years agoBe developer-friendly, 'cause OpenBSD devs like to:
Ingo Schwarze [Tue, 13 Jan 2015 23:17:52 +0000 (23:17 +0000)]
Be developer-friendly, 'cause OpenBSD devs like to:
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.

10 years agodo not spawn a pager when there is no output; issue pointed out by deraadt@
Ingo Schwarze [Tue, 13 Jan 2015 13:22:22 +0000 (13:22 +0000)]
do not spawn a pager when there is no output; issue pointed out by deraadt@