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.
Ingo Schwarze [Sat, 2 Jun 2012 20:16:23 +0000 (20:16 +0000)]
Minimal implementation of .EX and .EE for GNU compatibility.
Do not use this, it is not portable and only defined in esr's man-ext.
For example, sox(1) wants these macros.
Ingo Schwarze [Thu, 31 May 2012 22:41:19 +0000 (22:41 +0000)]
Fix blank line handling in .if.
In particular, two cases were wrong:
- single-line .if with trailing whitespace gave no blank line
- multiline .if with \{ but without \{\ gave no blank line
While here, simplify roff_cond() by partially reordering the code.
Ingo Schwarze [Thu, 31 May 2012 22:38:16 +0000 (22:38 +0000)]
While i already got my fingers dirty on mandoc_escape(),
profit of the occasion to pull out some spaghetti, that is,
three confusing variables and fourteen pointless assignments
among them; instead, always operate on the official pointers
**start, **end, and *sz, each of which conveys an obvious meaning.
No functional change intended, and the new tests confirm that
everything still (err...) "works", as far as that word can be
applied to the kind of roff(7) mock-up code i'm polishing here.
Ingo Schwarze [Thu, 31 May 2012 22:34:06 +0000 (22:34 +0000)]
Make recursive parsing of roff(7) escapes actually work in the general case,
in particular when the inner escapes are preceded or followed by other terms.
While doing so, remove lots of bogus code that was trying to make pointless
distinctions between numeric and non-numeric escape sequences, while both
actually share the same syntax and we ignore the semantics anyway.
This prevents some of the strings defined in the pod2man(1) preamble
from producing garbage output, in particular in scandinavian words.
Of course, proper rendering of scandinavian national characters
cannot be expected even with these fixes.
Ingo Schwarze [Thu, 31 May 2012 22:29:13 +0000 (22:29 +0000)]
Implement the roff \z escape sequence, intended to output the next
character without advancing the cursor position; implement it to
simply skip the next character, as it will usually be overwritten.
With this change, the pod2man(1) preamble user-defined string \*:,
intended to render as a diaeresis or umlaut diacritic above the
preceding character, is rendered in a slightly less ugly way,
though still not correctly. It was rendered as "z.." and is now
rendered as ".".
Given that the definition of \*: uses elaborate manual \h positioning,
there is little chance for mandoc(1) to ever render it correctly,
but at least we can refrain from printing out a spurious "z", and
we can make the \z do something semi-reasonable for easier cases.
Ingo Schwarze [Sun, 27 May 2012 18:02:49 +0000 (18:02 +0000)]
Fix the vertical spacing around tbl(7) instances in man(7).
Groff forces the document author to manually request sufficient spacing
after .TE - that is, at least .sp 1v after a table with the "box" option
and at least .sp 2v after a table with the "doublebox" option - or else
it clobbers the box. I consider that insane, so i'm not imitating groff
in that respect. Instead, i add at least as much vertical space as groff,
or more where required to avoid clobbering the box.
Consequently, output will be identical for input that looks sane with
groff, and mandoc will make output look better for input that looks bad
with groff.
"Please check them in and I'll look into them later!" kristaps@
Ingo Schwarze [Sun, 27 May 2012 17:54:54 +0000 (17:54 +0000)]
Do not handle vertical lines as additional tbl(7) columns,
instead save their properties with the following column.
This simplifies layout parsing and saves a lot of code
related to column handling.
At output time, print all white space and vertical lines
separating columns before printing the following column,
and none after printing the preceding column, considerably
simplifying white space handling and width calculations.
No functional change, but it saves 150 lines of code,
and it allows the next patch to tbl_term.c, tbl_literal().
"Please check them in and I'll look into them later!" kristaps@
Ingo Schwarze [Sun, 27 May 2012 17:48:57 +0000 (17:48 +0000)]
Support -Ios='OpenBSD 5.1' to override uname(3) as the source of the
default value for the mdoc(7) .Os macro.
Needed for man.cgi on the OpenBSD website.
Problem with man.cgi first noticed by deraadt@;
beck@ and deraadt@ agree with the way to solve the issue.
"Please check them in and I'll look into them later!" kristaps@
Ingo Schwarze [Sun, 27 May 2012 14:42:05 +0000 (14:42 +0000)]
The .\} -> .\& -> pset() bug reported by naddy has already been fixed;
i'm really sure because i both stepped through the code with gdb
and wrote an OpenBSD regression test for it.
While here, note that bentley@ reported .ti .ce .fc missing.
Discourage the use of esr's man-ext macros:
If man(7) has any advantage compared to mdoc(7), it's portability,
and using man-ext would needlessly give that advantage away.
ok kristaps@