Move mdoc_isdelim() into mandoc.h as mandoc_isdelim(). This allows the
removal of manual delimiter checks in html.c and term.c. Finally, add
the escaped period as a closing delimiter, removing a TODO to this
effect.
Move mandoc_{realloc,malloc,calloc} out of libmandoc.h and into mandoc.h
so that everybody can use them. This follows the convention of
libXXXX.h being internal to a library and XXXX.h being the external
interface. Not only does this allow the removal of lots of redundant
NULL-checking code, it also sets the tone for adding new mandoc-global
routines.
Move check for closing punctuation into its own function. This will
later be modified to remove the need for iscdelim(), which will be used
to unify delimiter checks, which will then allow for the simple removal
of a TODO regarding escaped periods.
Instead of a series of hard-coded strcmps, make argv_a2arg() iterate
over an array of possible argument types, hooking in to mdoc_argnames[].
This knocks off bytes for the duplicated strings and cleans up code
readability.
Ingo Schwarze [Tue, 15 Mar 2011 03:03:54 +0000 (03:03 +0000)]
my $buf = "string"; return $string; is cool in Perl, but not in C;
found by Ulrich Spoerlein <uqs at freebsd> using the clang static analyzer;
"ok, but please document the numbers" kristaps@
Ingo Schwarze [Mon, 7 Mar 2011 01:58:24 +0000 (01:58 +0000)]
Do not leak information about the software used
into PostScript and PDF documents behind the user's back.
Joerg Sonnenberger pointed out that almost all software
creating PostScript and PDF documents does so, even on OpenBSD,
but that doesn't make the leakage much better in my book.
According to all standards i could find, this information is optional.
Issue originally reported by deraadt@; "commit!" kristaps@.
Ingo Schwarze [Mon, 7 Mar 2011 01:35:51 +0000 (01:35 +0000)]
Clean up date handling,
as a first step to get rid of the frequent petty warnings in this area:
- always store dates as strings, not as seconds since the Epoch
- for input, try the three most common formats everywhere
- for unrecognized format, just pass the date though verbatim
- when there is no date at all, still use the current date
Originally triggered by a one-line patch from Tim van der Molen,
<tbvdm at xs4all dot nl>, which is included here.
Feedback and OK on manual parts from jmc@.
"please check this in" kristaps@
Ingo Schwarze [Wed, 9 Feb 2011 22:53:20 +0000 (22:53 +0000)]
Clean up the COMPATIBILITY section;
heavily based on a patch from kristaps@ with some tweaks by me.
- Also talk about -Tps and -Tpdf.
- Use the same list style as in the other mandoc manuals.
- Replace a few macros by ones better suited.
- Some improvements of wording.
ok jmc@ kristaps@
Ingo Schwarze [Sun, 6 Feb 2011 22:33:38 +0000 (22:33 +0000)]
Some pre-handlers produce output, so reorder the code to set up
keep flags before they are called.
Without this bugfix, .Bk was ineffective in some cases.
"looks reasonable" kristaps@
Add initial libmdoc and libman top-most machinery for accepting TBL
directives. For now this will just ignore them (except for -Ttree,
which just notes that an EQN's been accepted).
Add initial EQN support to mandoc. This parses, then throws away, data
between EQ and EN roff blocks. EQN is different from TBL in that data
after .EQ is unilaterally considered an equation until an .EN. Thus,
there's no need to jump through hoops in having table spans and so on.
This is ONLY the parse code framework in libroff. EQN is not yet passed
into the backends.
If `Ns' is specified on its own line, it should be ignored. This is
shitty groff behaviour. Do the same, but raise a warning to this
effect. This from a TODO noted by schwarze@.
Ingo Schwarze [Sun, 30 Jan 2011 16:05:37 +0000 (16:05 +0000)]
Implement the \N'number' (numbered character) roff escape sequence.
Don't use it in new manuals, it is inherently non-portable, but we
need it for backward-compatibility with existing manuals, for example
in Xenocara driver pages.
ok kristaps@ jmc@ and tested by Matthieu Herrb (matthieu at openbsd dot org)
Ingo Schwarze [Tue, 25 Jan 2011 12:24:27 +0000 (12:24 +0000)]
Since tbl_data() can now produce multiple spans, let parsebuf()
generate man(7) or mdoc(7) nodes for all these spans,
not only for the last one.
Restores the horizontal lines in the cpu(4/hppa) tables.
ok kristaps@
Ingo Schwarze [Tue, 25 Jan 2011 12:16:22 +0000 (12:16 +0000)]
Do not skip data after horizontal lines in the layout.
Instead, let one line of input data add two new spans
to the tbl tree during one single call of tbl_data().
Note that this causes the horizontal line to get parsed
into the tbl tree, but not yet used in the output,
which will be fixed next.
Avoids data loss in cpu(4/hppa).
ok kristaps@
Ingo Schwarze [Tue, 25 Jan 2011 01:12:02 +0000 (01:12 +0000)]
Ignore .ns (no-space mode), .ps (change point size), .ta (tab control)
for now. All of these just cause a bit too much or too little
whitespace, but no serious formatting problems.
Triggered by reports from brad@.
Ingo Schwarze [Tue, 25 Jan 2011 00:40:14 +0000 (00:40 +0000)]
As noticed by deraadt@, it goes without saying that text files
on a UNIX system use UNIX conventions, and UNIX tools working
on them expect that.
ok jmc@
Ingo Schwarze [Mon, 24 Jan 2011 23:41:55 +0000 (23:41 +0000)]
Skip carriage return before newline, if any.
As pointed out by Joerg Sonnenberger, this is useful
because we use mmap(3) and look for '\n' by hand.
"check it in" kristaps@
Ingo Schwarze [Sat, 22 Jan 2011 14:00:52 +0000 (14:00 +0000)]
Check argument count validation for all in_line() macros.
Most empty in_line() macros are already removed by the parser,
so there is no need to check again in mdoc_validate.c.
This also downgrades almost all remaining argument count issues
from ERROR to WARNING.
ok kristaps@
Ingo Schwarze [Sat, 22 Jan 2011 13:16:02 +0000 (13:16 +0000)]
When finding the roff .it request (line trap),
make it clear that you cannot use mandoc to format that page (yet).
Triggered by a report from brad@, ok kristaps@.
Ingo Schwarze [Mon, 17 Jan 2011 00:21:29 +0000 (00:21 +0000)]
Refrain from throwing fatal errors for
* .br .sp .nf .fi .na with arguments - just skip the arguments
* .TH lacking arguments - use empty strings instead like groff
* .TH with excessive arguments - skip those
Reminded by joerg@, ok kristaps@.
Ingo Schwarze [Sun, 16 Jan 2011 20:12:45 +0000 (20:12 +0000)]
When processing a blank text line, do not break out of text processing
into macro processing code. Fixing a regression introduced in 1.95,
found because it caused segfaults in my regression suite.
OK kristaps@
Ingo Schwarze [Sun, 16 Jan 2011 04:00:34 +0000 (04:00 +0000)]
Implement the roff .rm request (remove macro).
Using the new roff_getname() function, this is really simple.
Breaks mandoc of the habit of reporting an error in each pod2man(1) preamble.
Reminded by a report from brad@; ok kristaps@.
Change how -Thtml behaves with tables: use multiple rows, with widths
set by COL, until an external macro is encountered. At this point in
time, close out the table and process the macro. When the first table
row is again re-encountered, re-start the table. This requires a bit of
tracking added to "struct html", but the change is very small and
follows the logic of meta-fonts. This all follows a bug-report by
joerg@.
Downgrade -man message of ignored empty paragraph to MANDOC_IGNPAR. The
change in man_macro.c was from an assertion caused by a subtle problem:
(1) macro is removed, causing m->last to be m->last->parent; (2) by jumping
to the m->last->parent after post-validation, the original
m->last->parent is skipped; (3) the rewinder climbs to the root of the
tree and aborts.
The original issue recorded in the TODO by schwarze@, reminded by Brad
Smith.
Make -man -Tascii not break within literal lines, e.g.,
.nf
.B hello world
.fi
Also, clean up the print_man_node() function a little bit. This problem
has long since been in the TODO and was recently noted again by Brad
Smith. The -T[x]html fix will follow...
Add support for "^" vertical spanners. Unlike GNU tbl, raise
error-class messages when data is being ignored by specifying it in "^"
cells (either as-is or in blocks).
Also note again that horizontal spanners aren't really supported...
Ingo Schwarze [Tue, 11 Jan 2011 00:11:45 +0000 (00:11 +0000)]
Refactoring in preparation for .rm support:
Unify parsing of names given as roff request arguments into a new
function roff_getname(), which is rather different from the parsing
function for normal arguments, mandoc_getarg(), because names cannot
be quoted and cannot contain whitespace or escaped characters.
The new function now throws an ERROR when finding escaped characters
in a name.
"I'm fine with this." kristaps@
When a row of data is being parsed and it's a line or double-line
(instead of data), re-use the last "layout" pointer instead of advancing
to the next one.
Fixes: T} can be followed by a delimiter then more data. Make this
work and add documentation for it.
Also make tbl_term() not puke if the number of data cells is less than
the number of layout cells (which happens from time to time). This
still needs work because we should pad out empty cells so that the
borders all work out.