Ingo Schwarze [Fri, 27 Dec 2013 16:17:32 +0000 (16:17 +0000)]
Allow saving more than one mlink per mpage in the mlinks ohash.
We are still only using one of them for now.
Actually, we are now using a different one,
but the order the mlinks are found is random anyway.
Ingo Schwarze [Fri, 27 Dec 2013 14:29:28 +0000 (14:29 +0000)]
Another step on the way to clear naming, this time regarding mlinks:
* rename global ohash filenames to mlinks
* rename ofadd() to mlink_add()
* fold fileadd() and inoadd() into mlink_add()
* fold filecheck() into mpages_merge()
Still no functional change.
Ingo Schwarze [Fri, 27 Dec 2013 01:16:54 +0000 (01:16 +0000)]
Add an additional mlinks table to the database, redundant for now,
both because it contains nothing but a subset of the data of the
existing mpages table and because the relationship of mpage and mlink
entries is still 1:1. But all that will eventually change.
Ingo Schwarze [Thu, 26 Dec 2013 23:35:59 +0000 (23:35 +0000)]
Drop the mpages_list, use the existing mpages ohash for iteration.
No functional change except that the order of database entries changes,
which doesn't matter anyway.
Ingo Schwarze [Thu, 26 Dec 2013 22:12:46 +0000 (22:12 +0000)]
To better support MLINKS, we will have to split the "docs" database
table into two tables, on for actual files on disk, one for (often
multiple) directory entries pointing to them. That implies splitting
struct of into two structs, to be called "mpage" and "mlink",
respectively. As a preparation, globally rename "of" and "inos"
to "mpage". No functional change.
Ingo Schwarze [Thu, 26 Dec 2013 17:23:42 +0000 (17:23 +0000)]
Rework the documentation of Spaces, using the Ossanna/Kernighan/Ritter
Heirloom Nroff/Troff User's Manual at the authoritative reference.
Part of our text was outright wrong.
Also, refrain from advertising the paddable non-breaking space `\~'
in the DESCRIPTION, for three reasons: For nroff mode, -Tascii, and
fixed width fonts in general, it makes no difference, so keep the
discussion simple. Compared to `\ ', '\~' is of questionable portability.
And if you want to keep words together, it is also more usual that you
don't want padding to intervene either.
Finally, drop the `\c' escape sequence (interrupt text processing)
which is not a special character but an input processing instruction
akin to the \<newline> escape sequence.
Ingo Schwarze [Thu, 26 Dec 2013 02:55:28 +0000 (02:55 +0000)]
I have no idea how it happened that \B, \H, \h, \L, and \l got
mapped to ESCAPE_NUMBERED (which is for \N and only for \N), that
made no sense at all. Properly remap them to ESCAPE_IGNORE.
While here, move \B and \w from the group taking number arguments
to the group taking string arguments; right now, that doesn't imply
any functional change, but if we ever go ahead and implement a
parser for roff(7) numerical expressions, it will suddenly start
to matter, and cause confusion.
Ingo Schwarze [Thu, 26 Dec 2013 02:43:18 +0000 (02:43 +0000)]
The roff language really has two groups of basic building blocks:
Requests and escape sequences. Consequently, supplement the
REQUEST REFERENCE by an ESCAPE SEQUENCE REFERENCE, such that people
no longer need to guess or experiment what mandoc(1) implements,
what it parses and ignores, and what it doesn't handle at all.
Ingo Schwarze [Wed, 25 Dec 2013 21:24:12 +0000 (21:24 +0000)]
Oops, .Fa never breaks the output line in the middle of any of its
arguments, not even outside SYNOPSIS mode. Quite surprising as .Fn
does break the line in the middle of its arguments outside SYNOPSIS
mode, and only doesn't do that in SYNOPSIS mode. Wonders of groff...
Ingo Schwarze [Wed, 25 Dec 2013 14:40:34 +0000 (14:40 +0000)]
In the SYNOPSIS, implement hanging indentation for .Fo
and avoid output line breaks inside .Fa arguments.
This reduces groff-mandoc differences in OpenBSD base by more than 8%.
Patch from Franco Fichtner <franco at lastsummer dot de> (DragonFly).
Ingo Schwarze [Wed, 25 Dec 2013 14:09:32 +0000 (14:09 +0000)]
Support .St -xsh4.2, the System Interfaces part of the original Single
UNIX Specification. As this one appears to be used in the wild and we
already have -xpg4.2 and even -xsh5, it makes sense to add this one.
Note that calling the original SUS XPG4.2 appears to be more common
than calling it SUSv1, so it's ok that we don't have .St -susv1.
From Sascha Wildner <saw at online dot de> (DragonFly) via Franco Fichtner.
Ingo Schwarze [Wed, 25 Dec 2013 00:39:31 +0000 (00:39 +0000)]
Do not break output lines in .Fn function arguments in SYNOPSIS mode.
Following an idea from Franco Fichtner, but implemented more cleanly.
This reduces groff-mandoc-differences in OpenBSD base by a fantastic 7.5%.
Ingo Schwarze [Tue, 24 Dec 2013 19:11:45 +0000 (19:11 +0000)]
When deciding whether two consecutive macros are on the same input line,
we have to compare the line where the first one *ends* (not where it begins)
to the line where the second one starts.
This fixes the bug that .Bk allowed output line breaks right after block
macros spanning more than one input line, even when the next macro follows
on the same line.
Ingo Schwarze [Mon, 23 Dec 2013 02:20:09 +0000 (02:20 +0000)]
Implement a long-standing desideratum,
hanging indentation for .Fn in SYNOPSIS mode,
exploiting the new trailspace feature
by deliberately *NOT* using it.
Ingo Schwarze [Sun, 22 Dec 2013 23:34:13 +0000 (23:34 +0000)]
Polishing the worms in my favourite can, term_flushln().
The TERMP_TWOSPACE flag i introduced in August 2009 was idiosyncratic
and served only a very narrow purpose. Replace it by a more intuitive
and more general termp attribute "trailspace", to be used together
with TERMP_NOBREAK, to request a minimum amount of whitespace at
the end of the current column. Adapt all code to the new interface.
No functional change intended;
code reviews to confirm that are welcome *eg*.
Ingo Schwarze [Sun, 15 Dec 2013 23:56:42 +0000 (23:56 +0000)]
In quoted macro arguments, double quotes can be quoted by doubling them.
For a long time, we handle this in roff(7) and man(7) macros.
Now add correct handling for the mdoc(7) case, too.
Closely based on a patch by Tsugutomo dot ENAMI at jp dot sony dot com,
see http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=48438
received via Thomas Klausner (wiz@), slightly tweaked by me.
Ingo Schwarze [Sun, 15 Dec 2013 21:23:52 +0000 (21:23 +0000)]
The "value" argument to the roff(7) .nr requests ends right before
the first non-digit character. While here, implement and document
an optional sign, requesting increment or decrement, as documented
in the Ossanna/Kernighan/Ritter troff manual and supported by groff.
Ingo Schwarze [Thu, 21 Nov 2013 01:49:18 +0000 (01:49 +0000)]
My audit of mandoc revealed one missing (unsigned char) cast
in an isspace() argument containing arbitrary char data.
Thanks to deraadt@ for triggering the audit.
Ingo Schwarze [Mon, 11 Nov 2013 00:37:55 +0000 (00:37 +0000)]
In the parser, when closing an explicit block that is not open,
close below-subsection implicit scopes that may still be open.
In the formatter, make sure indentation is reset when leaving a scope,
not only when entering the next one.
Improves the formatting of gpg(1); issue reported by jca on ports.
Ingo Schwarze [Sun, 10 Nov 2013 21:34:04 +0000 (21:34 +0000)]
Support the alternative syntax \C'uXXXX' for Unicode characters.
It is already documented in the Heirloom troff manual,
and groff handles it as well.
Bug reported by Bjarni Ingi Gislason <bjarniig at rhi dot hi dot is>
on <bug-groff at gnu dot org>. Well, admittedly, that bug was reported
against groff, but mandoc was even more broken than groff with respect
to this syntax...
Ingo Schwarze [Sat, 2 Nov 2013 20:39:49 +0000 (20:39 +0000)]
While answering a question asked by espie@, i noticed that .Fd is not
completely obsolete, but still somewhat useful for listing preprocessor
directives, in particular in the SYNOPSIS.
Ingo Schwarze [Sun, 27 Oct 2013 17:01:18 +0000 (17:01 +0000)]
The man(7) language has no syntax to specify architectures, but it
can still be used to write architecture-specific manuals, of course.
So just derive the architecture a man(7) manual belongs to from the
directory where it is located and refrain from warning about each and
every architecture-specific man(7) manual found.
While here, delete some trailing whitespace in the neighbourhood.
Ingo Schwarze [Sun, 27 Oct 2013 16:41:31 +0000 (16:41 +0000)]
The code in ofmerge() only tried the source parsers if at least one
of the path (/man1/ .. /man9/) or the file name suffix (*.1 .. *.9)
indicated a source manual. That missed source manuals with unusual
names in unusual locations.
Instead, as the existing comment right above already suggests, try
the source parsers unless both the path and the file name suffix
unambiguously indicate a preformatted manual (/cat*/*.0).
This change is not expensive in practice because no real-world
system will have large numbers of preformatted pages outside
/cat*/*.0. The only way to make information loss even less probable
would be to try the source parsers on all files, even /cat*/*.0,
which wouldn't buy us much because no real-world system will call
source manuals /cat*/*.0, but it will be expensive in practice,
because many real-world systems have large numbers of preformatted
pages called /cat*/*.0.
Ingo Schwarze [Tue, 22 Oct 2013 20:38:00 +0000 (20:38 +0000)]
Parse and ignore .hw (hyphenation points in words); this is safe because
we don't do hyphenation anyway, so there is no point in throwing an ERROR
when encountering .hw.
Real-world usage of the request found by naddy@ in sysutils/dwdiff(1).
Ingo Schwarze [Mon, 21 Oct 2013 23:47:58 +0000 (23:47 +0000)]
There are three kinds of input lines: text lines, macros taking
positional arguments (like Dt Fn Xr) and macros taking text as
arguments (like Nd Sh Em %T An). In the past, even the latter put
each word of their arguments into its own MDOC_TEXT node; instead,
concatenate arguments unless delimiters, keeps or spacing mode
prevent that. Regarding mandoc(1), this is internal refactoring,
no output change intended.
Regarding mandocdb(8), this fixes yet another regression introduced
when switching from DB to SQLite: The ability to search for strings
crossing word boundaries was lost and is hereby restored. At the
same time, database sizes and build times are both reduced by a bit
more than 5% each.
Ingo Schwarze [Thu, 17 Oct 2013 20:54:58 +0000 (20:54 +0000)]
Implement the .UR/.UE block (uniform resource identifier) introduced in the
man-ext macros by Eric S. Raymond, enabled by default in groff_man(7).
Usual disclaimer: You don't write new man(7) code, so you are not going
to use these, either.
Improves e.g. the bzr(1) and etherape(1) manuals.
Thanks to naddy@ for bringing these to my attention.
Ingo Schwarze [Mon, 14 Oct 2013 01:43:14 +0000 (01:43 +0000)]
Parse and ignore the .fam (font family) request.
Fixes irunner(1) in devel/ipython and uim-xim(1) in inputmethods/uim.
Thanks to naddy@ for bringing these to my attention.
Ingo Schwarze [Sun, 13 Oct 2013 14:45:56 +0000 (14:45 +0000)]
add libefi and simplify some names
from FreeBSD ports SVN rev. 293734, Ulrich Spoerlein March 24, 2012
in case of conflicts with NetBSD, i keep the simpler NetBSD names
Ingo Schwarze [Sun, 13 Oct 2013 03:07:34 +0000 (03:07 +0000)]
sync SUSv2/SUSv3 entries with groff
reduces groff-mandoc-differences for several pthread_*(3) manuals
noticed by Franco Fichtner <franco at lastsummer dot de>
dragonfly.git/commitdiff/370c546b87777b40b5fc862491555ef71b4ee130
Ingo Schwarze [Sun, 6 Oct 2013 23:20:39 +0000 (23:20 +0000)]
Put VERSION into config.h.
This makes life easier for downstream maintainers having more than one
Makefile, for example DragonFly and FreeBSD.
Suggested by Franco Fichtner <franco at lastsummer dot de>.
Ingo Schwarze [Sun, 6 Oct 2013 22:46:15 +0000 (22:46 +0000)]
We don't do hyphenation, but we allow breaking the line at hyphens that are
already there in the middle of words. So far, we only allowed this on text
lines. Now it turns out some macros allow this for their arguments, too,
in particular .Nd and most of the .%? citation macros.
Issue found by Franco Fichtner <franco at lastsummer dot de> while doing
systematic groff-mandoc comparisons in the DragonFly base system, THANKS!
While here, garbage collect two empty prevalidator function pointer lists
and sort a couple of function declarations.
Ingo Schwarze [Sun, 6 Oct 2013 17:01:52 +0000 (17:01 +0000)]
The .Lb arguments wants a "lib" prefix;
from Sascha Wildner via Franco Fichtner (DragonFly);
also fixing the same in the mdoc(7) example while i'm about it.
Ingo Schwarze [Sun, 6 Oct 2013 13:32:46 +0000 (13:32 +0000)]
If there is random stuff inside a .Bl block body before the first .It,
do not throw a FATAL error and do not die, but just throw a WARNING
and move the stuff out of the .Bl block.
This bug felt completely 2008-ish; meanwhile, such bugs from the
Kristaps-doesnt-like-syntax-errors-so-lets-just-give-up--Era
are becoming rare, but this was one of the last survivors.
Thanks to bentley@ for reminding me to finally fix this.
Ingo Schwarze [Sat, 5 Oct 2013 22:25:12 +0000 (22:25 +0000)]
Support simple numerical conditions.
Original code from Christos Zoulas, NetBSD rev. 1.11-1.13, April 3, 2013.
I tweaked the code as follows:
* In roff_getnum(), don't skip a minus that isn't followed by a digit.
* In roff_getop(), do not handle "!=", groff doesn't support it either.
* In roff_evalcond(), treat negative numbers as false, like groff.
Besides, make the interfaces of roff_getnum() and roff_getop() more
similar to each other and simplify parts of the code a bit.
Ingo Schwarze [Sat, 5 Oct 2013 22:21:20 +0000 (22:21 +0000)]
ROFFRULE_ALLOW = 0, ROFFRULE_DENY = 1 was confusing,
so exchange the two entries in enum roffrule; no functional change;
from Christos Zoulas, NetBSD rev. 1.11, April 4, 2013.
Ingo Schwarze [Sat, 5 Oct 2013 22:19:10 +0000 (22:19 +0000)]
Avoid code duplication in roff_parseln() as suggested by
Christos Zoulas in NetBSD rev. 1.11;
i'm even going a step further and making this yet a bit shorter.
No functional change.
Ingo Schwarze [Sat, 5 Oct 2013 22:15:03 +0000 (22:15 +0000)]
Expand references to number registers in exactly the same way as
references to user-defined strings. While here, make number registers
signed int, like in groff.
Inspired by NetBSD roff.c rev. 1.8 and read.c rev. 1.7
written by Christos Zoulas on March 21, 2013, but implemented
in a completely different way, without hacking into read.c,
where this functionality really doesn't belong.
Ingo Schwarze [Sat, 5 Oct 2013 22:08:12 +0000 (22:08 +0000)]
Support setting arbitrary roff(7) number registers,
preserving read support for the ".nr nS" SYNOPSIS state register.
Inspired by NetBSD roff.c rev. 1.18 (Christos Zoulas, March 21, 2013),
but implemented differently. I don't want to have yet another different
implementation of a hash table in mandoc - it would be the second one
in roff.c alone and the fifth one in mandoc grand total.
Instead, i designed and implemented roff_setreg() and roff_getreg()
to be similar to roff_setstrn() and roff_getstrn().
Once we feel the need to optimize, we can introduce one common
hash table implementation for everything in mandoc.
Ingo Schwarze [Sat, 5 Oct 2013 20:30:05 +0000 (20:30 +0000)]
Cleanup suggested by gcc-4.8.1, following hints by Christos Zoulas:
- avoid bad qualifier casting in roff.c, roff_parsetext()
by changing the mandoc_escape arguments to "const char const **"
- avoid bad qualifier casting in mandocdb.c, index_merge()
- do not complain about unused variables in test-*.c
- garbage collect a few unused variables elsewhere
Ingo Schwarze [Wed, 2 Oct 2013 06:45:43 +0000 (06:45 +0000)]
Merge from branch VERSION_1_12:
- mention that groff is GPL version 3
- link the new tbl.3.html
- list FreeBSD base version of mandoc
- document downstream versions
- copy the version 1.12.2 News
Ingo Schwarze [Wed, 2 Oct 2013 06:44:55 +0000 (06:44 +0000)]
Merge from branch VERSION_1_12:
- add the new SCRS files NEWS and gmdiff
- add tbl.3 to SRCS, INDEX_MANS, and install
- bring back the SCRS files apropos.{c,1} that somehow got lost
- bring back the INDEX_MANS apropos.1.html that also got lost
- update VERSION, VDATE, and OSNAME
- improve comment regarding STATIC
Throwing FATAL MANDOCERR_SYNTCHILD on non-.It children of .Bl
feels so 2008-ish, one of the last remnants of the
Kristaps-doesnt-like-syntax-errors-so-lets-just-give-up--Era.
One of the WARNING messages has to use the word "section" twice in two
different meanings, that cannot be helped. But we can make this less
confusing by stating that the second instance refers to stuff like (2),
(3), and (9), and by adding the sections header the first instance
refers to, for example ERRORS or RETURN VALUES.
Source for confusion noticed by Jan Stary <hans at stare dot cz>,
better wording suggested by jmc@, tweaked by me.
Use normal line macro recognition, do not attempt to roll your own.
This fixes horizontal spacing when an Ns macro follows a block-closing
macro and the corresponding block-opening macro is not on the same line.
Block closing macros do not allocate a new node but finish an existing
one, so they miss the clearing of MDOC_NEWLINE in mdoc.c, node_alloc().
Consequently, MDOC_NEWLINE must be cleared before processing the next
macro on the same line.
This fixes horizontal spacing for input lines beginning like .Oc Ns ...
Issue found by Franco Fichtner <franco at lastsummer dot de>
while working on DragonFly mandoc integration.
For some mdoc(7) macros, it is (unfortunately) semantically significant
whether they are the first macro on the line or called by another macro.
To help debugging, indicate this property "first macro on a new input line"
by prefixing an asterisk to the line number in -Ttree output.
Ingo Schwarze [Wed, 21 Aug 2013 21:20:40 +0000 (21:20 +0000)]
Move the last column-counting members of struct termp (col and maxcols)
from int to size_t, to match some existing ones (offset, *rmargin, viscol).
Move some related local variables from int to size_t as well.
Needed as a preparation to make a generalized adjbuf() function available
beyond the file term.c, i.e. in mandoc.c.
Also saves a couple of ugly casts.
Ingo Schwarze [Wed, 14 Aug 2013 15:08:31 +0000 (15:08 +0000)]
Use text production macros to document themselves.
Part of the patch was sent in by Jan Stary <hans at stare dot cz>,
another part was added by jmc@, the rest was added by myself;
ok jmc@.
Ingo Schwarze [Thu, 8 Aug 2013 20:07:47 +0000 (20:07 +0000)]
Implement the roff(7) font-escape sequence \f(BI "bold+italic".
This improves the formatting of about 40 base manuals
and reduces groff-mandoc formatting differences in base by about 5%.
Ingo Schwarze [Mon, 5 Aug 2013 23:36:42 +0000 (23:36 +0000)]
After a leading blank on an output line, the first word was counted twice
against vend, causing a premature line break. Fix that bug by reverting
revision 1.93 which Kristaps committed four years ago. Kristaps patch is no
longer needed because the code below /* Write out the [remaining] word. */
now handles leading blanks correctly, probably already for a long time.
This avoids premature line breaks in about a dozen base system manuals,
for example as(1) and gdb(1), and alignment issues in another twenty,
for example mount(2), ip6(4), pfctl(8), and crypto(9).