Ingo Schwarze [Fri, 31 May 2013 21:37:17 +0000 (21:37 +0000)]
The name "struct tbl" was badly misleading for two reasons:
1) This struct almost exclusively contains the table options.
2) Information about the table as a whole is actually in "struct tbl_node".
Besides, "struct tbl" was almost impossible to search for.
So rename it to "struct tbl_opts". No functional change.
Ingo Schwarze [Thu, 30 May 2013 03:52:59 +0000 (03:52 +0000)]
Reject non-printable characters found in the input stream even when
preceded by a backslash; otherwise, the escape sequence would later
be identified as invalid and the non-printable character would be
passed through to the output backends, sometimes triggering assertions.
Reported by Mike Small <smallm at panix dot com> on the mdocml discuss list.
Ingo Schwarze [Wed, 29 May 2013 22:48:10 +0000 (22:48 +0000)]
Sync to OpenBSD:
* Guard <sys/param.h> inclusion by #ifdef USE_MANPATH
to make it more obvious why this isn't needed on OpenBSD.
Noticed by deraadt@.
* Resolve gratuitious whitespace differences:
Blanks before tabs and on empty lines.
Ingo Schwarze [Sun, 19 May 2013 21:40:24 +0000 (21:40 +0000)]
Support .Bl -offset in -mdoc -Tman.
Issue found when Thomas Klausner <wiz at NetBSD dot org> made me
look at the manuals of his http://www.nih.at/libzip library.
Ingo Schwarze [Sun, 19 May 2013 21:07:51 +0000 (21:07 +0000)]
Move printing of the .RS macro into print_offs() such that print_offs()
takes care of printing the whole line. This reduces code duplication -
in particular after the upcoming commit to repair .Bl -offset -
and makes print_offs() more similar to what print_width() does.
No functional change.
Ingo Schwarze [Sat, 18 May 2013 17:47:47 +0000 (17:47 +0000)]
Should termp_xx_pre() ever get called for a macro it cannot handle,
use abort(3), just like in the three other comparable cases in this file,
instead of ignoring the problem and causing a null pointer access.
Cosmetical issue reported by Ulrich Spoerlein <uqs@spoerlein.net>
found by Coverity Scan CID 976115.
No functional change.
Ingo Schwarze [Sat, 18 May 2013 17:08:43 +0000 (17:08 +0000)]
Remove the variable sz because it's invariantly == 0,
along with the dead code testing whether it's positive.
Reported by Ulrich Spoerlein <uqs@spoerlein.net>,
found by Coverity Scan CID 975717.
While here, remove the now unused **params array as well,
which Coverity apparently missed, at least it wasn't reported...
Ingo Schwarze [Sat, 18 May 2013 16:40:15 +0000 (16:40 +0000)]
Even though the size of a pointer should not depend on the type of the
data pointed to, pass the size of the right pointer type to calloc;
cosmetic issue reported by Ulrich Spoerlein <uqs@spoerlein.net>
found in Coverity Scan CID 978734.
No binary change - ok cmp(1).
Ingo Schwarze [Sat, 5 Jan 2013 22:19:12 +0000 (22:19 +0000)]
In literal mode (.nf), each input line must be kept together
on the same output line, even if it is longer than the output width.
This commit fixes a bug allowing an overly long last line of an
indented block (.RS) to be broken even in literal mode.
The bug was found using the sudo_plugin(4) manual provided by millert@.
I introduced the bug in rev. 1.84 during the g2k12 Budapest hackathon.
Ingo Schwarze [Mon, 31 Dec 2012 22:34:48 +0000 (22:34 +0000)]
Rewrite indentation handling for nested lists in a more systematic way
to fix multiple issues reported by Todd Miller; thanks!
Specifically,
- avoid double indentation after .Bd inside .Bl
- set up correct indentation after .Bl inside .Bl
- set up correct indentation after .Dl and .D1 inside .Bl
While here, also
- set up correct indentation *inside* .Dl and .D1 inside .Bl.
Ingo Schwarze [Mon, 19 Nov 2012 17:57:23 +0000 (17:57 +0000)]
In groff, trying to redefine standard man(7) macros before .TH has no effect;
after .TH, it works. Trying to redefine standard mdoc(7) macros before .Dd
works when calling groff with the -mdoc command line option, but does not
when calling groff with -mandoc; after .Dd, it always works.
Arguably, one might call that buggy behaviour in groff, but it is very
unlikely that anybody will change groff in this respect (certainly, i'm
not volunteering). So let's be bug-compatible.
This fixes the vertical spacing in sox(1).
Merging from OpenBSD libmandoc.h 1.18, read.c 1.8, roff.c 1.47, June 2, 2012.
Ingo Schwarze [Mon, 19 Nov 2012 02:08:33 +0000 (02:08 +0000)]
Three portability improvements by millert@:
* Use "\\ " not "\\~" as the non-breaking space as historic nroff
doesn't support the latter.
* The '-' before the flags needs to be quoted to prevent nroff
from putting a line break between the '-' and the flag character.
* Disable hyphenation and, for nroff, disable justification which is
consistent with how mdoc behaves (and produces more readable manuals).
Ingo Schwarze [Sun, 18 Nov 2012 18:02:23 +0000 (18:02 +0000)]
Correct indentation for lists and displays inside lists.
Inspired by a diff from millert@, but implemented rather
differently and with slightly better functionality.
In particular, this one respects -offset and -width
arguments found in the input file.
Ingo Schwarze [Sat, 17 Nov 2012 00:26:33 +0000 (00:26 +0000)]
Cleanup naming of local variables to make the code easier on the eye:
Settle for "struct man *man", "struct mdoc *mdoc", "struct meta *meta"
and avoid the confusing "*m" which was sometimes this, sometimes that.
No functional change.
Ingo Schwarze [Fri, 16 Nov 2012 18:44:32 +0000 (18:44 +0000)]
End of sentence spacing after trailing punctuation after .In and .Ap
has just been fixed. Note that my problem description was somewhat
misleading, even though Nicolas Joly's problem report was fine.
Ingo Schwarze [Fri, 16 Nov 2012 18:41:18 +0000 (18:41 +0000)]
Two more macros (.Ap and .In) do trailing delimiter handling.
This fixes the end of sentence spacing in OpenBSD open(2)
and in about 150 pages in the NetBSD base system.
Reported by Nicolas Joly <njoly a pasteur point fr>, merci!
Ingo Schwarze [Fri, 16 Nov 2012 17:16:55 +0000 (17:16 +0000)]
Improve formatting of badly nested font blocks.
The basic idea is to already pop the font at the end marker
instead of allowing it to linger until the final end of the block.
This requires a few preliminaries:
* For each block, save a pointer to the previous font
to be used in case the block breaks another and gets extended.
* That requires making node information writable during rendering.
* Now fonts may get popped in the wrong order; hence, after the stack
has already been rewound further by some block that began earlier,
ignore popping a font that was put on the stack later.
* To be able to exploit all this for font blocks, tie processing
to their body, not their block, which is more logical anyway.
Triggered by florian@ reporting vaguely similar issues with list blocks.
Ingo Schwarze [Fri, 16 Nov 2012 13:40:36 +0000 (13:40 +0000)]
Fix a crash triggered by .Bl -tag .It Xo .El .Sh found by florian@.
* When allocating a body end marker, copy the pointer to the normalized
block information from the body block, avoiding the risk of subsequent
null pointer derefence.
* When inserting the body end marker into the syntax tree, do not try to
copy that pointer from the parent block, because not being a direkt child
of the block it belongs to is the whole point of a body end marker.
* Even non-callable blocks (like Bd and Bl) can break other blocks;
when this happens, postpone closing them out in the usual way.
Completed and tested at the OpenBSD impromptu Coimbra hackathon (c2k12).
Thanks to Pedro Almeida and the Laborat'orio de Computa,c~ao Avan,cada
da Universidade de Coimbra (http://www.uc.pt/lca) for their hospitality!
Ingo Schwarze [Wed, 29 Aug 2012 23:38:50 +0000 (23:38 +0000)]
1) Remove documentation of the groff-1.15 compatibility quirk
of suppressing spacing before a third .Xr argument
because that quirk was removed in mdoc_macro.c rev. 1.113.
2) Mark the "section" argument to .Xr as (syntactically) optional,
but still do not encourage omitting it.
The missing .Op was reported by espie@.
Fix handling of paragraph macros inside lists:
* When they are trailing the last item, move them outside the list.
* When they are trailing any other none-compact item, drop them.
The mdoc(7) \*(Ba predefined string actually forces roman font;
that's stupid because it may break enclosing font changes,
but let's do the same for groff bug compatibility.
--> Never use \*(Ba, use just plain "|"! <--
Also, predefined strings are already expanded by the roff(7) parser,
so the mdoc(7) parser has to look for the expanded string.
Always fix the man(7) subsection header (.SS) indent to 3n,
do not let it depend on the default indent provided by -Oindent.
By default, this doesn't change anything because 7 / 2 = 3;
in -Omdoc mode, it makes man(7) output the same as mdoc(7) output.
OpenBSD rev. 1.87
In flush-left mode of both man(7) and mdoc(7), when an output line is broken
at the position of a literal tab, the tab indents the following line.
Fixes the perl(1) SYNOPSIS; reminded by deraadt@; OpenBSD rev. 1.66.
Several -mdoc parser improvements related to vertical spacing:
* So far, .Pp and .Lp were removed before paragraph type blocks.
* Now also remove .br before paragraph type blocks.
* Treat .Lp as a paragraph like .Pp, so remove .Pp, .Lp, .br before it.
* Do not treat .sp as a paragraph, don't remove anything before it.
* After .Sh, .Ss, .Pp, and .Lp, remove .Pp, .Lp, .sp, .br, and blank lines.
* After .sp and .br, remove .br.
OpenBSD rev. mdoc.c 1.89 and mdoc_validate.c 1.106
Translate blank input lines to .sp just like in mdoc(7),
and ignore .sp after .PP. This fixes vertical spacing
for blank lines after .PP and for .sp after .PP.
OpenBSD rev. man.c 1.68 and man_term.c 1.86
In -Tman .Bl -compact, skip the blank line only before the first item
of the first list in a section, not before every item of the first list.
OpenBSD rev. 1.37
If the tag in .Bl -tag .It would leave exactly one blank before the
body of the item, mdoc(7) breaks the line, whereas the .TP used to
translate this to man(7) does not. Thus, insert an explicit roff(7)
line break in this place.
To be able to correctly count the characters, do not pass font escapes
an the like through print_word().
OpenBSD rev. 1.35
In -man -Tascii, support .sp with negative argument.
In -mdoc -Tman, improve the framework to control vertical spacing.
Use both to support .Bl -compact (surprisingly hard to get right).
OpenBSD rev. 1.85 and 1.34, respectively.
The post_nm() validation function crashed when the first .Nm child node
was a non-text node. Fix this by rewriting post_nm() to always set
the meta name to UNKNOWN when the name is missing or unusable.
While here, make MANDOCERR_NONAME an ERROR, as it usually renders
the page content unintelligible.
Bug reported by Maxim <Belooussov at gmail dot com>, thanks.
OpenBSD rev. 1.105
Do not crash in -Tman on:
* .Fn with exactly one argument
* .Bl -hang without a -width
Now all 3776 OpenBSD base manuals build without crashing.
OpenBSD rev. 1.33
multiple fixes to -Tascii .HP rendering:
* do not add an excessive blank line before the block
* in literal mode, start a new line after the tag
getting this to work requires some general (print_man_node) fixes:
* in literal mode, break the output line at the end of each
input line, not just after those input lines ending in text
* but don't break it when there was no output on the line
* and adjust the margins after the .HP tag
these general fixes require an adjustment to -Tascii .TP rendering:
* set up NOBREAK mode before the body, not after the head
finally, based on all this, implement -Tman .Bl -hang in terms of .HP
Remove a hack that was intended for groff-1.15 bug compatibility:
When the width of a tag in .Bl -hang was exactly one character
shorter than the maximum length that would fit, the following text
would have a negative hang of one character (i.e., hang to the left).
That bug is no longer present in groff-1.21, so relax mandoc, too.
OpenBSD rev. 1.65
* implement -Tman .Bl -item -inset -diag -ohang -dash -hyphen -enum .It
* fix -Tman .Bl -bullet .It
* adjust the -Tascii .Bl -bullet -dash -hyphen .It
default and minimum width to new groff standards,
it changed from 4n (in groff 1.15) to 2n (in groff 1.21)
* same for -Tascii -enum, it changed from 5n to 2n
* use -hang formatting for -Tascii -enum -width 2n
* for -Tascii -enum, the default is -width 3n
Implement -Tman .Bf.
To get the spacing right,
* avoid man(7) code line breaks at places where no spacing is allowed
* allow spacing right after .Sm on
* allow spacing after empty .Fl at the end of an input line
OpenBSD rev. 1.25
Add flags to insert a .sp or .br request before the next output,
shortening some frequent idioms and preparing for better vertical
spacing in the SYNOPSIS; no functional change intended.
OpenBSD rev. 1.19
Instead of adding one integer variable for each global boolean output flag
and passing around a structure containing them into each and every function,
just use a single static bitfield.
In preparation for adding more output flags to support more features.
OpenBSD rev. 1.18
Basic implementation of -Tman .Fo and .Fa;
again, some blank lines still missing from the output.
While here, remove the trailing semicolon
from .Fn when outside .Sh SYNOPSIS.
OpenBSD rev. 1.14
minor -mdoc -Tman fixes
* right after .Ns, avoid breaking the line in man code
* after .Fl without arguments, do not insert a blank into man code
* before each .Nm in .Sh SYNOPSIS, insert a .br into man code
* skip .Pp arguments, don't copy them to man code
Ingo Schwarze [Wed, 20 Jun 2012 22:06:30 +0000 (22:06 +0000)]
When i moved some low-level stuff from mdoc(7) and man(7)
to roff(7) some time ago, i forgot to adjust the cross-references.
Reported by Tim van der Molen <tbvdm at xs4all dot nl>, thanks.
Add `cc' support.
This was reported by espie@ and in the TODO.
Caveat: `cc' has buggy behaviour when invoked in groff(1) and followed
by a line-breaking control character macro, e.g., in a -man doc,
.cc |
.B foo
'B foo
|cc
'B foo
will cause groff(1) to behave properly for `.B' but inline the macro
definition for `B' when invoked with the line-breaking macro.
Fix an assert() raised by `RS' when following `TP'.
The reason was that `RS' wasn't BSCOPE'd, so the next-line (BLINE) scope
opened by `TP' would still be in the HEAD macro.
This was from joerg@'s archive of failures.
Remove catman(8): it's superfluous.
Users of man.cgi should be able to just copy in their directories and have
the CGI fine everything on its own or just suck it up or, in the cases
of multiple manroots, have a simple config file.
Besides, now that mandocdb(8) is using relative paths for everything,
needing a fancy "cp -R" is silly.
Add a compatibility interface for ohash.
This include's espie@'s wholesale src/lib/libc/ohash directory from OpenBSD
into compat_ohash.c (with a single copyright/license notice at the top)
and src/include/ohash.h as compat_ohash.h.
The ohash_int.h part of compat_ohash.c has been changed only in that ohash.h
points to compat_ohash.h.
Added HAVE_OHASH test (test-ohash.c) to Makefile.
In mandocdb.c and mansearch.c, check HAVE_OHASH test for inclusion.
Turn off sqlite3 synchronous mode when creating a new database.
This makes it run about 5x faster.
While here, wrap some sqlite3 statements in #defines to extract errors.
(Really, the warning/error/etc. macros should be functionified.)
Remove lint from Makefile.
Disable some parts of the build (man.cgi, etc.) while sqlite3 is being
merged in nice and slow.
Remove the bit swapping stuff in config.h.post.
Remove apropos_db (replaced by mansearch).
Flip apropos to use mansearch instead of apropos_db.
This makes the utility much smaller and simpler.
A lot of functionality has been omitted while the sqlite3 search routines
improve (logical operations, etc.).
It still needs work to make the output more conventional.
Also add the manpage utility, which I use extensively as a mind-meld of
apropos and man.
Re-tooled mandocdb using sqlite3 and ohash.
See the tech@ mailing list entries in June 2012 for details, as well as the
discuss@ mailing list entries from March 2012.
Among other changes, this utility now:
1. uses a single sqlite3 database instead of several berkeley dbs
2. stores utf-8 encoded strings
3. using ohash to aggressively hash its contents
4. using fts() instead of manually walking directories
Add a new mansearch.h interface, which replaces apropos_db.c
This is a much more minimal interface that stuffs all operations into
a single function.
It uses sqlite3 and ohash.