]> git.cameronkatri.com Git - mandoc.git/log
mandoc.git
9 years agoUnify some node handling functions that use TOKEN_NONE.
Ingo Schwarze [Sun, 19 Apr 2015 14:25:41 +0000 (14:25 +0000)]
Unify some node handling functions that use TOKEN_NONE.
* mdoc_word_alloc(), man_word_alloc() -> roff_word_alloc()
* mdoc_word_append(), man_word_append() -> roff_word_append()
* mdoc_addspan(), man_addspan() -> roff_addtbl()
* mdoc_addeqn(), man_addeqn() -> roff_addeqn()
Minus 50 lines of code, no functional change.

9 years agoDecouple the token code for "no request or macro" from the individual
Ingo Schwarze [Sun, 19 Apr 2015 14:00:19 +0000 (14:00 +0000)]
Decouple the token code for "no request or macro" from the individual
high-level parsers to allow further unification of functions that
only need to recognize this code, but that don't care about different
high-level macrosets beyond that.

9 years agoUnify node handling functions:
Ingo Schwarze [Sun, 19 Apr 2015 13:50:25 +0000 (13:50 +0000)]
Unify node handling functions:
* node_alloc() for mdoc and man_node_alloc() -> roff_node_alloc()
* node_append() for mdoc and man_node_append() -> roff_node_append()
* mdoc_head_alloc() and man_head_alloc() -> roff_head_alloc()
* mdoc_body_alloc() and man_body_alloc() -> roff_body_alloc()
* mdoc_node_unlink() and man_node_unlink() -> roff_node_unlink()
* mdoc_node_free() and man_node_free() -> roff_node_free()
* mdoc_node_delete() and man_node_delete() -> roff_node_delete()
Minus 130 lines of code, no functional change.

9 years agoDelete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),
Ingo Schwarze [Sat, 18 Apr 2015 17:53:21 +0000 (17:53 +0000)]
Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(),
man_node() from the mandoc(3) semi-public interface and the internal
wrapper functions print_mdoc() and print_man() from the HTML formatters.
Minus 60 lines of code, no functional change.

9 years agoUnify {mdoc,man}_{alloc,reset,free}() into roff_man_{alloc,reset,free}().
Ingo Schwarze [Sat, 18 Apr 2015 17:28:36 +0000 (17:28 +0000)]
Unify {mdoc,man}_{alloc,reset,free}() into roff_man_{alloc,reset,free}().
Minus 80 lines of code, no functional change.
Written on the train from Koeln to Wolfsburg returning from p2k15.

9 years agoMove mdoc_hash_init() and man_hash_init() to libmandoc.h
Ingo Schwarze [Sat, 18 Apr 2015 17:01:58 +0000 (17:01 +0000)]
Move mdoc_hash_init() and man_hash_init() to libmandoc.h
and call them from mparse_alloc() and choose_parser(),
preparing unified allocation of struct roff_man.

9 years agoProfit from the unified struct roff_man and reduce the number of
Ingo Schwarze [Sat, 18 Apr 2015 16:34:25 +0000 (16:34 +0000)]
Profit from the unified struct roff_man and reduce the number of
arguments of mparse_result() by one.  No functional change.
Written on the ICE Bruxelles-Koeln on the way back from p2k15.

9 years agoReplace the structs mdoc and man by a unified struct roff_man.
Ingo Schwarze [Sat, 18 Apr 2015 16:06:39 +0000 (16:06 +0000)]
Replace the structs mdoc and man by a unified struct roff_man.
Almost completely mechanical, no functional change.
Written on the train from Exeter to London returning from p2k15.

9 years agolook at COHERENT troff
Ingo Schwarze [Sat, 18 Apr 2015 16:05:45 +0000 (16:05 +0000)]
look at COHERENT troff

9 years agoflorian want <img> tags for https://tlakh.xyz/p2k15.7.html
Ingo Schwarze [Thu, 16 Apr 2015 20:36:04 +0000 (20:36 +0000)]
florian want <img> tags for https://tlakh.xyz/p2k15.7.html

9 years agoRestore the page headers and page footers that accidentally got lost
Ingo Schwarze [Thu, 16 Apr 2015 20:22:27 +0000 (20:22 +0000)]
Restore the page headers and page footers that accidentally got lost
in rev. 1.225.  Regression reported by florian@.

9 years agoshorten "outdated mandoc.db" warning message; requested by deraadt@
Ingo Schwarze [Thu, 16 Apr 2015 16:36:21 +0000 (16:36 +0000)]
shorten "outdated mandoc.db" warning message; requested by deraadt@

9 years agoDo not mistreat empty arguments to font alternating macros
Ingo Schwarze [Mon, 6 Apr 2015 22:06:23 +0000 (22:06 +0000)]
Do not mistreat empty arguments to font alternating macros
as vertical spacing requests.  Bug found with xmahjongg(6).

9 years agoOn a new RS nesting level, the saved width starts from the default
Ingo Schwarze [Mon, 6 Apr 2015 14:59:21 +0000 (14:59 +0000)]
On a new RS nesting level, the saved width starts from the default
width, not from the saved width of the previous level.
Improves xterm(1) and XSetEventQueueOwner(3); found in transcode_filter(1).

9 years agoUse the default width for .RS without arguments.
Ingo Schwarze [Mon, 6 Apr 2015 13:35:08 +0000 (13:35 +0000)]
Use the default width for .RS without arguments.
Reduces groff-mandoc differences in base and Xenocara by about 4%.
Found while looking at wpa_supplicant(8).

9 years agoIf a partial explicit block extending to the next input line follows
Ingo Schwarze [Sun, 5 Apr 2015 23:04:41 +0000 (23:04 +0000)]
If a partial explicit block extending to the next input line follows
the end macro of a broken block, put all of it into the breaking block.
Needed for example by mutella(1).

9 years agoReduce code duplication, no functional change:
Ingo Schwarze [Sun, 5 Apr 2015 22:44:20 +0000 (22:44 +0000)]
Reduce code duplication, no functional change:
Both partial and full implicit blocks can break explicit blocks.
Put the code to handle both cases into a common function.

9 years agoArguments to end macros of broken partial explicit blocks
Ingo Schwarze [Sun, 5 Apr 2015 14:43:36 +0000 (14:43 +0000)]
Arguments to end macros of broken partial explicit blocks
must go inside the breaking block.  For example, in
.It Ic cmd Oo
.Ar optional_arg Oc Ar mandatory_arg
the mandatory_arg is still inside the .It block.
Used for example by mutella(1).

9 years agoallow using an alternate mandoc binary
Ingo Schwarze [Sun, 5 Apr 2015 09:30:24 +0000 (09:30 +0000)]
allow using an alternate mandoc binary

9 years agoGive man(7) section and subsection headers hanging indentation.
Ingo Schwarze [Sat, 4 Apr 2015 18:52:51 +0000 (18:52 +0000)]
Give man(7) section and subsection headers hanging indentation.
Reduces groff-mandoc differences in base by about 2.5% due to
various Perl manuals having long section titles.
Quirk found in argtable2(3).

9 years agoRounding rules for horizontal scaling widths are more complicated.
Ingo Schwarze [Sat, 4 Apr 2015 17:47:18 +0000 (17:47 +0000)]
Rounding rules for horizontal scaling widths are more complicated.
There is a first rounding to basic units on the input side.
After that, rounding rules differ between requests and macros.
Requests round to the nearest possible character position.
Macros round to the next character position to the left.

Implement that by changing the return value of term_hspan()
to basic units and leaving the second scaling and rounding stage
to the formatters instead of doing it in the terminal handler.

Improves for example argtable2(3).

9 years agoDon't allow breaking the output line after hyphens following escape
Ingo Schwarze [Sat, 4 Apr 2015 13:53:42 +0000 (13:53 +0000)]
Don't allow breaking the output line after hyphens following escape
sequences.  Improves tic(1), sxpm(1), and a few Perl manuals.
Quirk found by naddy@ in milter-greylist(8).

9 years agoFix a quirk with respect to empty .HP.
Ingo Schwarze [Sat, 4 Apr 2015 11:44:43 +0000 (11:44 +0000)]
Fix a quirk with respect to empty .HP.
Found while writing a regression test for man_macro.c rev. 1.66.
Incidentally, this brings rendering of XFreeEventData(3) closer to groff.

9 years agoVastly simplify man(7) block unwinding, similar to mdoc_macro.c 1.171.
Ingo Schwarze [Fri, 3 Apr 2015 23:19:15 +0000 (23:19 +0000)]
Vastly simplify man(7) block unwinding, similar to mdoc_macro.c 1.171.
Drop one enum type, two static functions, 70 lines of code.
Also fixes the mpeg_encode(1) manual reported broken by naddy@.

9 years agoIt turns out the man(7) parser suffers from unintelligible handling
Ingo Schwarze [Fri, 3 Apr 2015 17:00:52 +0000 (17:00 +0000)]
It turns out the man(7) parser suffers from unintelligible handling
of block rewinding, just like then mdoc(7) parser did.
First step in getting rid of rew_scope():
Replace the only call where the target block is known.
This commit is analogous to mdoc_macro.c rev. 1.167.
One down, three to go.

9 years agoportability: word boundaries in regular expressions
Ingo Schwarze [Fri, 3 Apr 2015 12:41:02 +0000 (12:41 +0000)]
portability: word boundaries in regular expressions

9 years agoNo need to hardcode /usr/bin/ as the path to more(1); helps portability.
Ingo Schwarze [Fri, 3 Apr 2015 08:46:17 +0000 (08:46 +0000)]
No need to hardcode /usr/bin/ as the path to more(1); helps portability.
We don't hardcode the paths to gunzip(1) and cmp(1) either.
Discussed with ajacoutot@.

9 years agoThird step towards parser unification:
Ingo Schwarze [Thu, 2 Apr 2015 23:48:19 +0000 (23:48 +0000)]
Third step towards parser unification:
Replace struct mdoc_meta and struct man_meta by a unified struct roff_meta.
Written of the train from London to Exeter on the way to p2k15.

9 years agoSecond step towards parser unification:
Ingo Schwarze [Thu, 2 Apr 2015 22:48:17 +0000 (22:48 +0000)]
Second step towards parser unification:
Replace struct mdoc_node and struct man_node by a unified struct roff_node.
To be able to use the tok member for both mdoc(7) and man(7) without
defining all the macros in roff.h, sacrifice a tiny bit of type safety
and make tok an int rather than an enum.
Almost mechanical, no functional change.
Written on the Eurostar from Bruxelles to London on the way to p2k15.

9 years agoFirst step towards parser unification:
Ingo Schwarze [Thu, 2 Apr 2015 21:36:49 +0000 (21:36 +0000)]
First step towards parser unification:
Replace enum mdoc_type and enum man_type by a unified enum roff_type.
Almost mechanical, no functional change.
Written on the ICE train from Frankfurt to Bruxelles on the way to p2k15.

9 years agoLet man(1) and apropos(1) work even when the current directory
Ingo Schwarze [Wed, 1 Apr 2015 12:48:33 +0000 (12:48 +0000)]
Let man(1) and apropos(1) work even when the current directory
is unusable: Only change back to the current directory when the
directory was changed before and the next path is relative.
This is now more similar to what makewhatis(8) does.
Issue reported by espie@.

9 years agoEscape punctuation characters that have a different meaning in -Tpdf.
Ingo Schwarze [Mon, 30 Mar 2015 16:06:14 +0000 (16:06 +0000)]
Escape punctuation characters that have a different meaning in -Tpdf.

~, `, and ' get translated to non-ASCII characters by most troff
implementations when generating PostScript/PDF output.  When the
original ASCII character is meant, it needs to be manually escaped.

Patch from bentley@.

9 years agorefering -> referring; patch from jmc@
Ingo Schwarze [Fri, 27 Mar 2015 21:40:04 +0000 (21:40 +0000)]
refering -> referring; patch from jmc@

9 years agoActually use the new man.conf(5) "output" directive.
Ingo Schwarze [Fri, 27 Mar 2015 21:33:20 +0000 (21:33 +0000)]
Actually use the new man.conf(5) "output" directive.
Additional functionality, yet minus 45 lines of code.

9 years agoParse the new man.conf(5) "output" directive.
Ingo Schwarze [Fri, 27 Mar 2015 17:37:25 +0000 (17:37 +0000)]
Parse the new man.conf(5) "output" directive.
The next step will be to actually use the parsed data.

9 years agoModernize documentation by inserting blanks between option letters
Ingo Schwarze [Fri, 27 Mar 2015 16:36:31 +0000 (16:36 +0000)]
Modernize documentation by inserting blanks between option letters
and option arguments, except for -m because "-m an" and "-m andoc"
look just too weird.  Of course, the traditional form without the
blank will continue to work.

9 years agovarious tweaks from jmc@
Ingo Schwarze [Fri, 27 Mar 2015 16:28:55 +0000 (16:28 +0000)]
various tweaks from jmc@

9 years agooops, forgot to apply the actual patch...
Ingo Schwarze [Fri, 27 Mar 2015 01:01:28 +0000 (01:01 +0000)]
oops, forgot to apply the actual patch...

9 years agoDocument that certain stand-alone accents need escaping in rare cases to
Ingo Schwarze [Fri, 27 Mar 2015 00:57:28 +0000 (00:57 +0000)]
Document that certain stand-alone accents need escaping in rare cases to
prevent them from being converted to Unicode replacements in PDF output.
Issue found by bentley@, OK jmc@ bentley@.

9 years agoAdd man.conf(5). After adding some additional functionality,
Ingo Schwarze [Fri, 27 Mar 2015 00:18:14 +0000 (00:18 +0000)]
Add man.conf(5).  After adding some additional functionality,
one of the next steps will be to use it in addition to manpath(1)
rather than as an alternative to it.

9 years agoAdd a new directive "manpath path"
Ingo Schwarze [Thu, 26 Mar 2015 22:42:32 +0000 (22:42 +0000)]
Add a new directive "manpath path"
to replace the legacy "_whatdb path/whatis.db".
Keep _whatdb support for backward compat, for now.
Discussed with many, jmc@ and ajacoutot@ agree with the general direction.

9 years agomake MANPATH_DEFAULT compile-time configurable
Ingo Schwarze [Sun, 22 Mar 2015 18:14:30 +0000 (18:14 +0000)]
make MANPATH_DEFAULT compile-time configurable

9 years agowhen there is no -m, no -M, no MANPATH and no /etc/man.conf,
Ingo Schwarze [Sat, 21 Mar 2015 17:19:36 +0000 (17:19 +0000)]
when there is no -m, no -M, no MANPATH and no /etc/man.conf,
fall back to /usr/share/man:/usr/X11R6/man:/usr/local/man

9 years agovasprintf(3) needs _GNU_SOURCE on Linux;
Ingo Schwarze [Fri, 20 Mar 2015 15:32:02 +0000 (15:32 +0000)]
vasprintf(3) needs _GNU_SOURCE on Linux;
pointed out by Christian Neukirchen <chneukirchen at gmail dot com>.

9 years agoPatch from Christian Neukirchen <chneukirchen at gmail dot com>:
Ingo Schwarze [Fri, 20 Mar 2015 15:25:12 +0000 (15:25 +0000)]
Patch from Christian Neukirchen <chneukirchen at gmail dot com>:
He reports that on some platforms, it is not possible to use the
same va_list twice.  So use va_copy(3) for additional safety.

9 years agoThe .PD macro can occur in next-line scope. Fixes zshmisc(1).
Ingo Schwarze [Fri, 20 Mar 2015 14:47:52 +0000 (14:47 +0000)]
The .PD macro can occur in next-line scope.  Fixes zshmisc(1).
Issue reported by Christian Neukirchen <chneukirchen at gmail dot com>.

9 years agoSimplify by almost halving the number of macro flags:
Ingo Schwarze [Fri, 20 Mar 2015 12:54:22 +0000 (12:54 +0000)]
Simplify by almost halving the number of macro flags:
1. MAN_EXPLICIT was used iff fp == blk_exp, so just test fp.
2. MAN_FSCOPED was used only for TP, so just test for TP.
3. MAN_NOCLOSE was completely unused.
No functional change.

9 years agoCompat glue needed for Solaris 9 and 10.
Ingo Schwarze [Thu, 19 Mar 2015 14:57:29 +0000 (14:57 +0000)]
Compat glue needed for Solaris 9 and 10.

Thanks to Sevan Janiyan <venture37 at geeklan dot co dot uk> for
reporting the Solaris 10 issues, to Jan Holzhueter <jh at opencsw
dot org> for some additional insight, and to OpenCSW in general for
providing me with a Solaris 9/10/11 testing environment.

9 years agoWe always use FTS_NOCHDIR, so delete the directory changing code.
Ingo Schwarze [Wed, 18 Mar 2015 19:29:48 +0000 (19:29 +0000)]
We always use FTS_NOCHDIR, so delete the directory changing code.
This not only simplifies matters, but also helps operating systems
lacking dirfd(3), for example Solaris 10.  Solaris dirfd issue
reported by Sevan Janiyan <venture37 at geeklan dot co dot uk>.

9 years agoPass the CC set in configure.local to Makefile.local.
Ingo Schwarze [Wed, 18 Mar 2015 17:13:37 +0000 (17:13 +0000)]
Pass the CC set in configure.local to Makefile.local.
Issue found while testing on opencsw.org.

9 years agoSimplify: Now that rc is global anyway, no need to pass it around
Ingo Schwarze [Tue, 17 Mar 2015 13:35:52 +0000 (13:35 +0000)]
Simplify: Now that rc is global anyway, no need to pass it around
as an argument.  No functional change.

9 years agoWhen the user exits the pager before the pager has drained all input
Ingo Schwarze [Tue, 17 Mar 2015 07:33:07 +0000 (07:33 +0000)]
When the user exits the pager before the pager has drained all input
from man(1), man(1) dies from SIGPIPE.  Exiting man(1) is fine in this
case, generating more output would be pointless, but without handling
SIGPIPE, the exit code from man(1) was wrong and csh(1) printed an
ugly message "Broken pipe".  Fix this by handling SIGPIPE explicitly.
Issue noticed by deraadt@.

9 years agonaddy@ found a tough problem - fittingly, in cobfusc(1)...
Ingo Schwarze [Mon, 16 Mar 2015 14:51:14 +0000 (14:51 +0000)]
naddy@ found a tough problem - fittingly, in cobfusc(1)...

9 years agoAvoid off-by-one read access to the termacts array, which could
Ingo Schwarze [Sun, 15 Mar 2015 16:53:41 +0000 (16:53 +0000)]
Avoid off-by-one read access to the termacts array, which could
sometimes result in missing line breaks before subsection headers.
Found by carsten dot kunze at arcor dot de on SuSE 13.2.

9 years agoRemove the first comma from constructs like ", and," and ", or,":
Ingo Schwarze [Fri, 13 Mar 2015 20:20:07 +0000 (20:20 +0000)]
Remove the first comma from constructs like ", and," and ", or,":
You can use "and" and "or" to join sentence clauses,
and you can use commas, but both hinders reading;
patch from jmc@.

9 years agorelease 1.13.3 VERSION_1_13_3
Ingo Schwarze [Fri, 13 Mar 2015 12:35:32 +0000 (12:35 +0000)]
release 1.13.3

9 years agoFix hardlink detection on platforms having padding in struct inodev,
Ingo Schwarze [Fri, 13 Mar 2015 00:19:41 +0000 (00:19 +0000)]
Fix hardlink detection on platforms having padding in struct inodev,
typically 64bit platforms.  This was basically broken since forever.
Not only is the padding used, but it was used uninitialized.
Problem reported by jmc@.

9 years agoWhen manpath(1) is available, enable HAVE_MANPATH even when building
Ingo Schwarze [Wed, 11 Mar 2015 13:15:44 +0000 (13:15 +0000)]
When manpath(1) is available, enable HAVE_MANPATH even when building
without database support.  Required now that we have man(1) even
without database support.

9 years agoWhen interpreting the -O argument as a macro name fails,
Ingo Schwarze [Wed, 11 Mar 2015 13:11:22 +0000 (13:11 +0000)]
When interpreting the -O argument as a macro name fails,
fall back to showing Nd rather than not showing anything.
Issue reported by jmc@.

9 years agoFix previous: size_t is often narrower than off_t.
Ingo Schwarze [Wed, 11 Mar 2015 13:05:20 +0000 (13:05 +0000)]
Fix previous: size_t is often narrower than off_t.
Cluestick applied by joerg at NetBSD.

9 years agoThe st_size member of struct stat is off_t, which is signed,
Ingo Schwarze [Tue, 10 Mar 2015 14:17:52 +0000 (14:17 +0000)]
The st_size member of struct stat is off_t, which is signed,
all required by POSIX.  So don't compare it against against
an unsigned constant.

9 years agoWe can keep track of the pager PID without additional complexity.
Ingo Schwarze [Tue, 10 Mar 2015 13:50:03 +0000 (13:50 +0000)]
We can keep track of the pager PID without additional complexity.
No functional change for now, but more robust in case anybody should
ever add additional child processes.

9 years agoFix a regression caused in rev. 1.212, reported by kristaps@:
Ingo Schwarze [Tue, 10 Mar 2015 03:02:28 +0000 (03:02 +0000)]
Fix a regression caused in rev. 1.212, reported by kristaps@:

When using a pager and the first manual shown is gzip'ed,
the gunzip(1) process ended up as a child of the pager process
such that the man(1) process couldn't wait for it, preventing
proper display of the manual.

Solve this by making the pager a child of the man(1) process
(instead of the other way round), which requires being a bit
more careful about properly closing file descriptors after use
and waiting for the pager before exiting man(1).

9 years agoupdate for 1.13.3
Ingo Schwarze [Mon, 9 Mar 2015 21:00:14 +0000 (21:00 +0000)]
update for 1.13.3

9 years agouse \(dq rather than \*q; patch from bentley@
Ingo Schwarze [Mon, 9 Mar 2015 20:17:23 +0000 (20:17 +0000)]
use \(dq rather than \*q; patch from bentley@

9 years agoFix vertical spacing at the beginning of tables.
Ingo Schwarze [Fri, 6 Mar 2015 15:48:52 +0000 (15:48 +0000)]
Fix vertical spacing at the beginning of tables.
man(7) always prints a blank line, mdoc(7) doesn't.
Problem in mdoc(7) reported by kristaps@.
mdoc(7) part of the patch tested by kristaps@.

9 years agoIn mdoc(7), don't mistreat negative .sp arguments as large positive ones.
Ingo Schwarze [Fri, 6 Mar 2015 13:09:07 +0000 (13:09 +0000)]
In mdoc(7), don't mistreat negative .sp arguments as large positive ones.
Instead, use the same logic as for man(7).

9 years agoprevent the skipvsp flag from creeping past actual text
Ingo Schwarze [Fri, 6 Mar 2015 13:02:43 +0000 (13:02 +0000)]
prevent the skipvsp flag from creeping past actual text

9 years agoFlush the line preceding a table before clearing the right margin,
Ingo Schwarze [Fri, 6 Mar 2015 11:03:03 +0000 (11:03 +0000)]
Flush the line preceding a table before clearing the right margin,
such that that line isn't output with unlimited width.
Problem reported and fix OK by kristaps@.

9 years agoAllow compilation on Mac OS X, which doesn't have MACHINE defined.
Kristaps Dzonsons [Fri, 6 Mar 2015 09:24:59 +0000 (09:24 +0000)]
Allow compilation on Mac OS X, which doesn't have MACHINE defined.
While there, specify some casts to satisfy the compiler warnings.

OK schwarze@

9 years agoin eqn, "prime" is equivalent to \(fm, and - is equivalent to \(mi;
Ingo Schwarze [Wed, 4 Mar 2015 12:19:49 +0000 (12:19 +0000)]
in eqn, "prime" is equivalent to \(fm, and - is equivalent to \(mi;
patch from bentley@

9 years agoIf an eqn(7) starts on a new input line, be sure to output whitespace
Ingo Schwarze [Tue, 3 Mar 2015 21:11:34 +0000 (21:11 +0000)]
If an eqn(7) starts on a new input line, be sure to output whitespace
in front of it.  Issue found by tedu@ in glOrtho(3).

There are also cases of excessive whitespace before and after
equations.  This patch neither fixes them nor makes them worse.

9 years agoIf a non-gz manual is read after a gzipped manual, refrain
Ingo Schwarze [Mon, 2 Mar 2015 14:50:17 +0000 (14:50 +0000)]
If a non-gz manual is read after a gzipped manual, refrain
from throwing a bogus error "wait: No child processes".
As reported by Baptiste Daroussin <bapt at FreeBSD dot org>,
clearing the state variable curp->child after use was forgotten.

9 years agoWhen makewhatis(8) scans a tree, ignore trailing garbage on filenames.
Ingo Schwarze [Fri, 27 Feb 2015 16:22:09 +0000 (16:22 +0000)]
When makewhatis(8) scans a tree, ignore trailing garbage on filenames.
This is relevant because some ports install files like man1/xsel.1x,
as reported by patrick keshishian <pkeshish at gmail dot com> on misc@.

We can probably improve functionality and simplify the code by ignoring
file name extensions altogether; we already know the section number from
the name of the directory.  But so close to lock, i'm keeping the fix
minimal.

9 years agoWhen man(1) and apropos(1) look for a file man1/foo.1 but it's unavailable,
Ingo Schwarze [Fri, 27 Feb 2015 16:02:10 +0000 (16:02 +0000)]
When man(1) and apropos(1) look for a file man1/foo.1 but it's unavailable,
fall back to glob(man1/foo.*), which is more like what old man(1) did.
Do this both for file names from the database and for fs_lookup().
This is relevant because some ports install files like man1/xset.1x.
Regression reported by patrick keshishian <pkeshish at gmail dot com>.

9 years agooops, in NAME, don't nag about the comma after .Nm
Ingo Schwarze [Mon, 23 Feb 2015 13:55:55 +0000 (13:55 +0000)]
oops, in NAME, don't nag about the comma after .Nm

9 years agoimprove NAME section diagnostics;
Ingo Schwarze [Mon, 23 Feb 2015 13:31:03 +0000 (13:31 +0000)]
improve NAME section diagnostics;
confusing messages reported by Jan Stary <hans at stare dot cz>

9 years agoEscape quotes when expanding macro arguments.
Ingo Schwarze [Sat, 21 Feb 2015 14:46:58 +0000 (14:46 +0000)]
Escape quotes when expanding macro arguments.
This fixes a bug naddy@ found in plan9/rc(1).

9 years agoFor selecting a two-digit font size, support the historic syntax \s12
Ingo Schwarze [Fri, 20 Feb 2015 23:55:10 +0000 (23:55 +0000)]
For selecting a two-digit font size, support the historic syntax \s12
in addition to the classic syntax \s(12, the modern syntax \s[12],
and the alternative syntax \s'12'.  The historic syntax only works
for the font sizes 10-39.
Real-world usage found by naddy@ in plan9/rc.

9 years agoCompletely delete all carriage return characters from the input.
Ingo Schwarze [Fri, 20 Feb 2015 22:40:38 +0000 (22:40 +0000)]
Completely delete all carriage return characters from the input.
No change to messages about them (ignore them right before line feeds,
report errors elsewhere).
naddy@ found a manual in the wild containing lots of these (ysm(1)),
and i can't imagine a situation where dropping them could be problematic.

9 years ago\n(.$
Ingo Schwarze [Fri, 20 Feb 2015 13:47:28 +0000 (13:47 +0000)]
\n(.$

9 years agonaddy@ scoured the ports tree for remaining mandoc issues
Ingo Schwarze [Tue, 17 Feb 2015 20:41:50 +0000 (20:41 +0000)]
naddy@ scoured the ports tree for remaining mandoc issues
and identified two top priority issues

9 years agoRender \(lq and \(rq as '"' in -Tascii mode but leave the rendering
Ingo Schwarze [Tue, 17 Feb 2015 20:37:16 +0000 (20:37 +0000)]
Render \(lq and \(rq as '"' in -Tascii mode but leave the rendering
of .Do/.Dc, .Dq, .Lb, and .St untouched.
Reduces groff-mandoc differences in OpenBSD base by about 7%.
Reminded of the issue by naddy@.

9 years agoCope with another one of the many kinds of DocBook stupidity:
Ingo Schwarze [Tue, 17 Feb 2015 18:09:14 +0000 (18:09 +0000)]
Cope with another one of the many kinds of DocBook stupidity:

Instead of just using .br, DocBook sometimes fiddles with the
utterly unportable internal register \n[an-break-flag] that is
only available in the GNU implementation of man(7) and then arms
an input line trap to call the equally unportable internal macro
.an-trap that, in the GNU implementation, inspects that variable;
all the world is GNU, isn't it?

Since naddy@ reports that quite a few ports manuals suffer from
this insanity, let's just translate it to the intended .br.

Et ceterum censeo DocBookem esse delendam.

9 years agoLet .it accept numerical expressions, not just numerical constants.
Ingo Schwarze [Tue, 17 Feb 2015 17:16:52 +0000 (17:16 +0000)]
Let .it accept numerical expressions, not just numerical constants.
For .it, ignore scaling units in roff_getnum().
Inside parentheses, skip whitespace after a sign in roff_getnum().
Parse and ignore unary plus in roff_getnum().
As a bonus, get rid of the only call to mandoc_strntoi() in roff.c.

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.