summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-14 14:47:45 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2010-05-14 14:47:45 +0000
commit2a9434bade54d5d9efd10e8989a4c84f6ef92516 (patch)
treeedebb9790c629b6e19e8339e208573abb6863821 /usr.bin
parent413a8a72894bb15e60e53d10cdaa71dfa96bbf7a (diff)
Merge 1.9.25, keeping local patches;
this does not merge kristaps' end-of-sentences handling yet, i will check that separately. This one includes: * handle \*(Ba as a delimiter * introduce ARGS_PEND for .Bl -column .It end-of-line special casing * section ordering: expect EXIT STATUS at the right place * line break fixes in SYNOPSIS * allow literal contexts to have arbitrary line lengths * the input file column number can not be used to identify the beginning of a line because white space is allowed after the initial '.' * proper leading spaces in -man -Tascii mode * do not let Lb break lines in -mdoc -Thtml LIBRARY
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/Makefile4
-rw-r--r--usr.bin/mandoc/libmdoc.h14
-rw-r--r--usr.bin/mandoc/man.7229
-rw-r--r--usr.bin/mandoc/man_term.c28
-rw-r--r--usr.bin/mandoc/mdoc.7359
-rw-r--r--usr.bin/mandoc/mdoc.c16
-rw-r--r--usr.bin/mandoc/mdoc.h34
-rw-r--r--usr.bin/mandoc/mdoc_action.c4
-rw-r--r--usr.bin/mandoc/mdoc_argv.c17
-rw-r--r--usr.bin/mandoc/mdoc_html.c15
-rw-r--r--usr.bin/mandoc/mdoc_macro.c94
-rw-r--r--usr.bin/mandoc/mdoc_strings.c80
-rw-r--r--usr.bin/mandoc/mdoc_term.c97
-rw-r--r--usr.bin/mandoc/mdoc_validate.c13
-rw-r--r--usr.bin/mandoc/term.h4
15 files changed, 600 insertions, 408 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index eb11454f98d..9cf3f33af00 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile,v 1.35 2010/05/14 01:54:37 schwarze Exp $
+# $OpenBSD: Makefile,v 1.36 2010/05/14 14:47:44 schwarze Exp $
.include <bsd.own.mk>
-VERSION=1.9.24
+VERSION=1.9.25
CFLAGS+=-DVERSION=\"${VERSION}\"
CFLAGS+=-W -Wall -Wstrict-prototypes
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index 902a9e06988..d8175f8267a 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.29 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.30 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -28,9 +28,10 @@ struct mdoc {
void *data;
struct mdoc_cb cb;
int flags;
-#define MDOC_HALT (1 << 0) /* Error in parse. Halt. */
-#define MDOC_LITERAL (1 << 1) /* In a literal scope. */
-#define MDOC_PBODY (1 << 2) /* In the document body. */
+#define MDOC_HALT (1 << 0) /* error in parse: halt */
+#define MDOC_LITERAL (1 << 1) /* in a literal scope */
+#define MDOC_PBODY (1 << 2) /* in the document body */
+#define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
int pflags;
enum mdoc_next next;
struct mdoc_node *last;
@@ -118,7 +119,8 @@ enum margserr {
ARGS_PUNCT,
ARGS_QWORD,
ARGS_PHRASE,
- ARGS_PPHRASE
+ ARGS_PPHRASE,
+ ARGS_PEND
};
enum margverr {
@@ -161,7 +163,7 @@ enum mdoct mdoc_hash_find(const char *);
int mdoc_iscdelim(char);
int mdoc_isdelim(const char *);
size_t mdoc_isescape(const char *);
-enum mdoc_sec mdoc_atosec(const char *);
+enum mdoc_sec mdoc_str2sec(const char *);
time_t mdoc_atotime(const char *);
size_t mdoc_macro2len(enum mdoct);
const char *mdoc_a2att(const char *);
diff --git a/usr.bin/mandoc/man.7 b/usr.bin/mandoc/man.7
index 75b242e29b7..cd0f096f5e3 100644
--- a/usr.bin/mandoc/man.7
+++ b/usr.bin/mandoc/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.21 2010/05/14 01:54:37 schwarze Exp $
+.\" $Id: man.7,v 1.22 2010/05/14 14:47:44 schwarze Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -25,8 +25,8 @@ The
.Nm man
language was historically used to format
.Ux
-manuals. This reference document describes its syntax, structure, and
-usage.
+manuals.
+This reference document describes its syntax, structure, and usage.
.Pp
.Bf -emphasis
Do not use
@@ -42,7 +42,8 @@ An
document follows simple rules: lines beginning with the control
character
.Sq \&.
-are parsed for macros. Other lines are interpreted within the scope of
+are parsed for macros.
+Other lines are interpreted within the scope of
prior macros:
.Bd -literal -offset indent
\&.SH Macro lines change control state.
@@ -51,7 +52,8 @@ Other lines are interpreted within the current state.
.Sh INPUT ENCODING
.Nm
documents may contain only graphable 7-bit ASCII characters, the
-space character, and the tabs character. All manuals must have
+space character, and the tabs character.
+All manuals must have
.Ux
line termination.
.Pp
@@ -61,10 +63,12 @@ vertical space.
Text following a
.Sq \e\*" ,
whether in a macro or free-form text line, is ignored to the end of
-line. A macro line with only a control character and comment escape,
+line.
+A macro line with only a control character and comment escape,
.Sq \&.\e" ,
-is also ignored. Macro lines with only a control character and
-optionally whitespace are stripped from input.
+is also ignored.
+Macro lines with only a control character and optionally whitespace are
+stripped from input.
.Ss Special Characters
Special characters may occur in both macro and free-form lines.
Sequences begin with the escape character
@@ -75,9 +79,11 @@ for two-character sequences; an open-bracket
.Sq \&[
for n-character sequences (terminated at a close-bracket
.Sq \&] ) ;
-or a single one-character sequence. See
+or a single one-character sequence.
+See
.Xr mandoc_char 7
-for a complete list. Examples include
+for a complete list.
+Examples include
.Sq \e(em
.Pq em-dash
and
@@ -92,9 +98,10 @@ escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
.D1 \efBbold\efR \efIitalic\efP
.Pp
A numerical representation 3, 2, or 1 (bold, italic, and Roman,
-respectively) may be used instead. A text decoration is only valid, if
-specified in free-form text, until the next macro invocation; if
-specified within a macro, it's only valid until the macro closes scope.
+respectively) may be used instead.
+A text decoration is only valid, if specified in free-form text, until
+the next macro invocation; if specified within a macro, it's only valid
+until the macro closes scope.
Note that macros like
.Sx \&BR
open and close a font scope with each argument.
@@ -132,14 +139,15 @@ trailing spaces are stripped from input (unless in a literal context).
Blank free-form lines, which may include spaces, are permitted and
rendered as an empty line.
.Pp
-In macro lines, whitespace delimits arguments and is discarded. If
-arguments are quoted, whitespace within the quotes is retained.
+In macro lines, whitespace delimits arguments and is discarded.
+If arguments are quoted, whitespace within the quotes is retained.
.Ss Dates
The
.Sx \&TH
macro is the only
.Nm
-macro that requires a date. The form for this date is the ISO-8601
+macro that requires a date.
+The form for this date is the ISO-8601
standard
.Cm YYYY-MM-DD .
.Ss Scaling Widths
@@ -152,8 +160,8 @@ stipulating a two-inch paragraph indentation with the following:
The syntax for scaled widths is
.Sq Li [+-]?[0-9]*.[0-9]*[:unit:]? ,
where a decimal must be preceded or proceeded by at least one digit.
-Negative numbers, while accepted, are truncated to zero. The following
-scaling units are accepted:
+Negative numbers, while accepted, are truncated to zero.
+The following scaling units are accepted:
.Pp
.Bl -tag -width Ds -offset indent -compact
.It c
@@ -209,14 +217,14 @@ Each
.Nm
document must contain contains at least the
.Sx \&TH
-macro describing the document's section and title. It may occur
-anywhere in the document, although conventionally, it appears as the
-first macro.
+macro describing the document's section and title.
+It may occur anywhere in the document, although conventionally, it
+appears as the first macro.
.Pp
Beyond
.Sx \&TH ,
-at least one macro or text node must appear in the document. Documents
-are generally structured as follows:
+at least one macro or text node must appear in the document.
+Documents are generally structured as follows:
.Bd -literal -offset indent
\&.TH FOO 1 2009-10-10
\&.
@@ -232,13 +240,13 @@ are generally structured as follows:
The \efBfoo\efR utility processes files...
\&.
\&.\e\*q .SH IMPLEMENTATION NOTES
-\&.\e\*q The next is for sections 1 & 8 only.
-\&.\e\*q .SH EXIT STATUS
\&.\e\*q The next is for sections 2, 3, & 9 only.
\&.\e\*q .SH RETURN VALUES
\&.\e\*q The next is for sections 1, 6, 7, & 8 only.
\&.\e\*q .SH ENVIRONMENT
\&.\e\*q .SH FILES
+\&.\e\*q The next is for sections 1 & 8 only.
+\&.\e\*q .SH EXIT STATUS
\&.\e\*q .SH EXAMPLES
\&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
\&.\e\*q .SH DIAGNOSTICS
@@ -256,18 +264,18 @@ The \efBfoo\efR utility processes files...
.Pp
The sections in a
.Nm
-document are conventionally ordered as they appear above. Sections
-should be composed as follows:
+document are conventionally ordered as they appear above.
+Sections should be composed as follows:
.Bl -ohang -offset indent
.It Em NAME
-The name(s) and a short description of the documented material. The
-syntax for this is generally as follows:
+The name(s) and a short description of the documented material.
+The syntax for this is generally as follows:
.Pp
.D1 \efBname\efR \e(en description
.It Em LIBRARY
The name of the library containing the documented material, which is
-assumed to be a function in a section 2 or 3 manual. For functions in
-the C library, this may be as follows:
+assumed to be a function in a section 2 or 3 manual.
+For functions in the C library, this may be as follows:
.Pp
.D1 Standard C Library (libc, -lc)
.It Em SYNOPSIS
@@ -295,34 +303,37 @@ This expands upon the brief, one-line description in
It usually contains a break-down of the options (if documenting a
command).
.It Em IMPLEMENTATION NOTES
-Implementation-specific notes should be kept here. This is useful when
-implementing standard functions that may have side effects or notable
-algorithmic implications.
-.It Em EXIT STATUS
-Command exit status for section 1, 6, and 8 manuals. This section is
-the dual of
-.Em RETURN VALUES ,
-which is used for functions. Historically, this information was
-described in
-.Em DIAGNOSTICS ,
-a practise that is now discouraged.
+Implementation-specific notes should be kept here.
+This is useful when implementing standard functions that may have side
+effects or notable algorithmic implications.
.It Em RETURN VALUES
This section is the dual of
.Em EXIT STATUS ,
-which is used for commands. It documents the return values of functions
-in sections 2, 3, and 9.
+which is used for commands.
+It documents the return values of functions in sections 2, 3, and 9.
.It Em ENVIRONMENT
Documents any usages of environment variables, e.g.,
.Xr environ 7 .
.It Em FILES
-Documents files used. It's helpful to document both the file and a
-short description of how the file is used (created, modified, etc.).
+Documents files used.
+It's helpful to document both the file and a short description of how
+the file is used (created, modified, etc.).
+.It Em EXIT STATUS
+Command exit status for section 1, 6, and 8 manuals.
+This section is the dual of
+.Em RETURN VALUES ,
+which is used for functions.
+Historically, this information was described in
+.Em DIAGNOSTICS ,
+a practise that is now discouraged.
.It Em EXAMPLES
-Example usages. This often contains snippets of well-formed,
-well-tested invocations. Make doubly sure that your examples work
-properly!
+Example usages.
+This often contains snippets of well-formed,
+well-tested invocations.
+Make doubly sure that your examples work properly!
.It Em DIAGNOSTICS
-Documents error conditions. This is most useful in section 4 manuals.
+Documents error conditions.
+This is most useful in section 4 manuals.
Historically, this section was used in place of
.Em EXIT STATUS
for manuals in sections 1, 6, and 8; however, this practise is
@@ -330,8 +341,8 @@ discouraged.
.It Em ERRORS
Documents error handling in sections 2, 3, and 9.
.It Em SEE ALSO
-References other manuals with related topics. This section should exist
-for most manuals.
+References other manuals with related topics.
+This section should exist for most manuals.
.Pp
.D1 \&.BR bar \&( 1 \&),
.Pp
@@ -364,11 +375,13 @@ Documents any security precautions that operators should consider.
Macros are one to three three characters in length and begin with a
control character ,
.Sq \&. ,
-at the beginning of the line. The
+at the beginning of the line.
+The
.Sq \(aq
-macro control character is also accepted. An arbitrary amount of
-whitespace (spaces or tabs) may sit between the control character and
-the macro name. Thus, the following are equivalent:
+macro control character is also accepted.
+An arbitrary amount of whitespace (spaces or tabs) may sit between the
+control character and the macro name.
+Thus, the following are equivalent:
.Bd -literal -offset indent
\&.PP
\&.\ \ \ PP
@@ -376,15 +389,17 @@ the macro name. Thus, the following are equivalent:
.Pp
The
.Nm
-macros are classified by scope: line scope or block scope. Line
-macros are only scoped to the current line (and, in some situations,
-the subsequent line). Block macros are scoped to the current line and
-subsequent lines until closed by another block macro.
+macros are classified by scope: line scope or block scope.
+Line macros are only scoped to the current line (and, in some
+situations, the subsequent line).
+Block macros are scoped to the current line and subsequent lines until
+closed by another block macro.
.Ss Line Macros
Line macros are generally scoped to the current line, with the body
-consisting of zero or more arguments. If a macro is scoped to the next
-line and the line arguments are empty, the next line, which must be
-text, is used instead. Thus:
+consisting of zero or more arguments.
+If a macro is scoped to the next line and the line arguments are empty,
+the next line, which must be text, is used instead.
+Thus:
.Bd -literal -offset indent
\&.I
foo
@@ -438,14 +453,14 @@ The syntax is as follows:
Macros marked as
.Qq compat
are included for compatibility with the significant corpus of existing
-manuals that mix dialects of roff. These macros should not be used for
-portable
+manuals that mix dialects of roff.
+These macros should not be used for portable
.Nm
manuals.
.Ss Block Macros
-Block macros are comprised of a head and body. Like for in-line macros,
-the head is scoped to the current line and, in one circumstance, the
-next line (the next-line stipulations as in
+Block macros are comprised of a head and body.
+Like for in-line macros, the head is scoped to the current line and, in
+one circumstance, the next line (the next-line stipulations as in
.Sx Line Macros
apply here as well).
.Pp
@@ -500,7 +515,8 @@ If a block macro is next-line scoped, it may only be followed by in-line
macros for decorating text.
.Sh REFERENCE
This section is a canonical reference to all macros, arranged
-alphabetically. For the scoping of individual macros, see
+alphabetically.
+For the scoping of individual macros, see
.Sx MACRO SYNTAX .
.Ss \&B
Text is rendered in bold face.
@@ -513,7 +529,8 @@ See also
and
.Sx \&r .
.Ss \&BI
-Text is rendered alternately in bold face and italic. Thus,
+Text is rendered alternately in bold face and italic.
+Thus,
.Sq .BI this word and that
causes
.Sq this
@@ -523,7 +540,8 @@ to render in bold face, while
.Sq word
and
.Sq that
-render in italics. Whitespace between arguments is omitted in output.
+render in italics.
+Whitespace between arguments is omitted in output.
.Pp
Examples:
.Pp
@@ -558,7 +576,8 @@ See also
and
.Sx \&IR .
.Ss \&DT
-Has no effect. Included for compatibility.
+Has no effect.
+Included for compatibility.
.Ss \&HP
Begin a paragraph whose initial output line is left-justified, but
subsequent output lines are indented, with the following syntax:
@@ -622,8 +641,8 @@ default width is used.
.Pp
The
.Cm head
-argument is used as a leading term, flushed to the left margin. This is
-useful for bulleted paragraphs and so on.
+argument is used as a leading term, flushed to the left margin.
+This is useful for bulleted paragraphs and so on.
.Pp
See also
.Sx \&HP ,
@@ -648,9 +667,10 @@ See also
and
.Sx \&RI .
.Ss \&LP
-Begin an undecorated paragraph. The scope of a paragraph is closed by a
-subsequent paragraph, sub-section, section, or end of file. The saved
-paragraph left-margin width is re-set to the default.
+Begin an undecorated paragraph.
+The scope of a paragraph is closed by a subsequent paragraph,
+sub-section, section, or end of file.
+The saved paragraph left-margin width is re-set to the default.
.Pp
See also
.Sx \&HP ,
@@ -725,9 +745,9 @@ See also
and
.Sx \&IR .
.Ss \&RS
-Begin a part setting the left margin. The left margin controls the
-offset, following an initial indentation, to un-indented text such as
-that of
+Begin a part setting the left margin.
+The left margin controls the offset, following an initial indentation,
+to un-indented text such as that of
.Sx \&PP .
This has the following syntax:
.Bd -filled -offset indent
@@ -744,16 +764,18 @@ If not specified, the saved or default width is used.
Text is rendered in small size (one point smaller than the default font)
bold face.
.Ss \&SH
-Begin a section. The scope of a section is only closed by another
-section or the end of file. The paragraph left-margin width is re-set
-to the default.
+Begin a section.
+The scope of a section is only closed by another section or the end of
+file.
+The paragraph left-margin width is re-set to the default.
.Ss \&SM
Text is rendered in small size (one point smaller than the default
font).
.Ss \&SS
-Begin a sub-section. The scope of a sub-section is closed by a
-subsequent sub-section, section, or end of file. The paragraph
-left-margin width is re-set to the default.
+Begin a sub-section.
+The scope of a sub-section is closed by a subsequent sub-section,
+section, or end of file.
+The paragraph left-margin width is re-set to the default.
.Ss \&TH
Sets the title of the manual page with the following syntax:
.Bd -filled -offset indent
@@ -766,13 +788,16 @@ At least the upper-case document title
.Cm title
and numeric manual section
.Cm section
-arguments must be provided. The
+arguments must be provided.
+The
.Cm date
argument should be formatted as described in
.Sx Dates :
-if it does not conform, the current date is used instead. The
+if it does not conform, the current date is used instead.
+The
.Cm source
-string specifies the organisation providing the utility. The
+string specifies the organisation providing the utility.
+The
.Cm volume
string replaces the default rendered volume, which is dictated by the
manual section.
@@ -783,7 +808,8 @@ Examples:
.Ss \&TP
Begin a paragraph where the head, if exceeding the indentation width, is
followed by a newline; if not, the body follows on the same line after a
-buffer to the indentation width. Subsequent output lines are indented.
+buffer to the indentation width.
+Subsequent output lines are indented.
The syntax is as follows:
.Bd -filled -offset indent
.Pf \. Sx \&TP
@@ -813,7 +839,8 @@ and
.\" .Ss \&UC
.\" Has no effect. Included for compatibility.
.Ss \&br
-Breaks the current line. Consecutive invocations have no further effect.
+Breaks the current line.
+Consecutive invocations have no further effect.
.Pp
See also
.Sx \&sp .
@@ -821,7 +848,8 @@ See also
End literal mode begun by
.Sx \&nf .
.Ss \&i
-Italicise arguments. Synonym for
+Italicise arguments.
+Synonym for
.Sx \&I .
.Pp
See also
@@ -835,7 +863,8 @@ and
Don't align to the right margin.
.Ss \&nf
Begin literal mode: all subsequent free-form lines have their end of
-line boundaries preserved. May be ended by
+line boundaries preserved.
+May be ended by
.Sx \&fi .
.Ss \&r
Fonts and styles (bold face, italics) reset to roman (default font).
@@ -860,7 +889,8 @@ spaces, which must conform to
.Sx Scaling Widths .
If 0, this is equivalent to the
.Sx \&br
-macro. Defaults to 1, if unspecified.
+macro.
+Defaults to 1, if unspecified.
.Pp
See also
.Sx \&br .
@@ -888,13 +918,13 @@ language.
.Bl -dash -compact
.It
In quoted literals, GNU troff allowed pair-wise double-quotes to produce
-a standalone double-quote in formatted output. It is not known whether
-this behaviour is exhibited by other formatters.
+a standalone double-quote in formatted output.
+It is not known whether this behaviour is exhibited by other formatters.
.It
The
.Sx \&sp
-macro does not accept negative values in mandoc. In GNU troff, this
-would result in strange behaviour.
+macro does not accept negative values in mandoc.
+In GNU troff, this would result in strange behaviour.
.It
The
.Sq \(aq
@@ -912,6 +942,7 @@ The
reference was written by
.An Kristaps Dzonsons Aq kristaps@bsd.lv .
.Sh CAVEATS
-Do not use this language. Use
+Do not use this language.
+Use
.Xr mdoc 7 ,
instead.
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index af977b4df70..9ffd7f75e59 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.28 2010/04/25 16:32:19 schwarze Exp $ */
+/* $Id: man_term.c,v 1.29 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -259,7 +259,6 @@ static int
pre_fi(DECL_ARGS)
{
- p->rmargin = p->maxrmargin = 65;
mt->fl &= ~MANT_LITERAL;
return(1);
}
@@ -270,10 +269,7 @@ static int
pre_nf(DECL_ARGS)
{
- p->rmargin = p->maxrmargin = 78;
- term_newln(p);
mt->fl |= MANT_LITERAL;
-
return(MAN_Vb != n->tok);
}
@@ -372,7 +368,7 @@ pre_sp(DECL_ARGS)
if (0 == len)
term_newln(p);
- for (i = 0; i < len; i++)
+ for (i = 0; i <= len; i++)
term_vspace(p);
return(0);
@@ -713,6 +709,9 @@ pre_SH(DECL_ARGS)
if (n->prev && MAN_SH == n->prev->tok)
if (NULL == n->prev->body->child)
break;
+ /* If the first macro, no vspae. */
+ if (NULL == n->prev)
+ break;
term_vspace(p);
break;
case (MAN_HEAD):
@@ -819,8 +818,10 @@ print_man_node(DECL_ARGS)
/* FIXME: this means that macro lines are munged! */
if (MANT_LITERAL & mt->fl) {
+ p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
term_flushln(p);
+ p->rmargin = p->maxrmargin = 65;
}
break;
default:
@@ -891,6 +892,12 @@ print_man_head(struct termp *p, const struct man_meta *m)
char buf[BUFSIZ], title[BUFSIZ];
size_t buflen, titlen;
+ /*
+ * Note that old groff would spit out some spaces before the
+ * header. We discontinue this strange behaviour, but at one
+ * point we did so here.
+ */
+
p->rmargin = p->maxrmargin;
p->offset = 0;
@@ -932,4 +939,13 @@ print_man_head(struct termp *p, const struct man_meta *m)
p->rmargin = p->maxrmargin;
p->offset = 0;
p->flags &= ~TERMP_NOSPACE;
+
+ /*
+ * Groff likes to have some leading spaces before content. Well
+ * that's fine by me.
+ */
+
+ term_vspace(p);
+ term_vspace(p);
+ term_vspace(p);
}
diff --git a/usr.bin/mandoc/mdoc.7 b/usr.bin/mandoc/mdoc.7
index bdf763a4a62..b7084c5c6f3 100644
--- a/usr.bin/mandoc/mdoc.7
+++ b/usr.bin/mandoc/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.26 2010/05/14 01:54:37 schwarze Exp $
+.\" $Id: mdoc.7,v 1.27 2010/05/14 14:47:44 schwarze Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -101,9 +101,11 @@ for two-character sequences; an open-bracket
.Sq \&[
for n-character sequences (terminated at a close-bracket
.Sq \&] ) ;
-or a single one-character sequence. See
+or a single one-character sequence.
+See
.Xr mandoc_char 7
-for a complete list. Examples include
+for a complete list.
+Examples include
.Sq \e(em
.Pq em-dash
and
@@ -118,14 +120,16 @@ escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
.D1 \efBbold\efR \efIitalic\efP
.Pp
A numerical representation 3, 2, or 1 (bold, italic, and Roman,
-respectively) may be used instead. A text decoration is valid within
+respectively) may be used instead.
+A text decoration is valid within
the current font scope only: if a macro opens a font scope alongside
its own scope, such as
.Sx \&Bf
.Cm \&Sy ,
in-scope invocations of
.Sq \ef
-are only valid within the font scope of the macro. If
+are only valid within the font scope of the macro.
+If
.Sq \ef
is specified outside of any font scope, such as in unenclosed, free-form
text, it will affect the remainder of the document.
@@ -174,7 +178,8 @@ and N-character
.Sq \e*[N] .
See
.Xr mandoc_char 7
-for a complete list. Examples include
+for a complete list.
+Examples include
.Sq \e*(Am
.Pq ampersand
and
@@ -187,14 +192,14 @@ trailing spaces are stripped from input (unless in a literal context).
Blank free-form lines, which may include whitespace, are only permitted
within literal contexts.
.Pp
-In macro lines, whitespace delimits arguments and is discarded. If
-arguments are quoted, whitespace within the quotes is retained.
+In macro lines, whitespace delimits arguments and is discarded.
+If arguments are quoted, whitespace within the quotes is retained.
.Ss Quotation
Macro arguments may be quoted with a double-quote to group
-space-delimited terms or to retain blocks of whitespace. A quoted
-argument begins with a double-quote preceded by whitespace. The next
-double-quote not pair-wise adjacent to another double-quote terminates
-the literal, regardless of surrounding whitespace.
+space-delimited terms or to retain blocks of whitespace.
+A quoted argument begins with a double-quote preceded by whitespace.
+The next double-quote not pair-wise adjacent to another double-quote
+terminates the literal, regardless of surrounding whitespace.
.Pp
This produces tokens
.Sq a" ,
@@ -203,7 +208,8 @@ This produces tokens
and
.Sq fg" .
Note that any quoted term, be it argument or macro, is indiscriminately
-considered literal text. Thus, the following produces
+considered literal text.
+Thus, the following produces
.Sq \&Em a :
.Bd -literal -offset indent
\&.Em "Em a"
@@ -213,16 +219,18 @@ In free-form mode, quotes are regarded as opaque text.
.Ss Dates
There are several macros in
.Nm
-that require a date argument. The canonical form for dates is the
-American format:
+that require a date argument.
+The canonical form for dates is the American format:
.Pp
.D1 Cm Month Day , Year
.Pp
The
.Cm Day
-value is an optionally zero-padded numeral. The
+value is an optionally zero-padded numeral.
+The
.Cm Month
-value is the full month name. The
+value is the full month name.
+The
.Cm Year
value is the full four-digit year.
.Pp
@@ -246,8 +254,8 @@ stipulating a two-inch list indentation with the following:
The syntax for scaled widths is
.Sq Li [+-]?[0-9]*.[0-9]*[:unit:] ,
where a decimal must be preceded or proceeded by at least one digit.
-Negative numbers, while accepted, are truncated to zero. The following
-scaling units are accepted:
+Negative numbers, while accepted, are truncated to zero.
+The following scaling units are accepted:
.Pp
.Bl -tag -width Ds -offset indent -compact
.It c
@@ -285,7 +293,8 @@ Using anything other than
.Sq u ,
or
.Sq v
-is necessarily non-portable across output media. See
+is necessarily non-portable across output media.
+See
.Sx COMPATIBILITY .
.Sh MANUAL STRUCTURE
A well-formed
@@ -334,13 +343,13 @@ The
\&.Nm
utility processes files ...
\&.\e\*q .Sh IMPLEMENTATION NOTES
-\&.\e\*q The next is for sections 1 & 8 only.
-\&.\e\*q .Sh EXIT STATUS
\&.\e\*q The next is for sections 2, 3, & 9 only.
\&.\e\*q .Sh RETURN VALUES
\&.\e\*q The next is for sections 1, 6, 7, & 8 only.
\&.\e\*q .Sh ENVIRONMENT
\&.\e\*q .Sh FILES
+\&.\e\*q The next is for sections 1 & 8 only.
+\&.\e\*q .Sh EXIT STATUS
\&.\e\*q .Sh EXAMPLES
\&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
\&.\e\*q .Sh DIAGNOSTICS
@@ -358,12 +367,12 @@ utility processes files ...
.Pp
The sections in a
.Nm
-document are conventionally ordered as they appear above. Sections
-should be composed as follows:
+document are conventionally ordered as they appear above.
+Sections should be composed as follows:
.Bl -ohang -offset Ds
.It Em NAME
-The name(s) and a short description of the documented material. The
-syntax for this as follows:
+The name(s) and a short description of the documented material.
+The syntax for this as follows:
.Bd -literal -offset indent
\&.Nm name0
\&.Nm name1
@@ -383,8 +392,8 @@ and
.Sx \&Nd .
.It Em LIBRARY
The name of the library containing the documented material, which is
-assumed to be a function in a section 2 or 3 manual. The syntax for
-this is as follows:
+assumed to be a function in a section 2 or 3 manual.
+The syntax for this is as follows:
.Bd -literal -offset indent
\&.Lb libarm
.Ed
@@ -449,25 +458,14 @@ Print verbose information.
.Pp
Manuals not documenting a command won't include the above fragment.
.It Em IMPLEMENTATION NOTES
-Implementation-specific notes should be kept here. This is useful when
-implementing standard functions that may have side effects or notable
-algorithmic implications.
-.It Em EXIT STATUS
-Command exit status for section 1, 6, and 8 manuals. This section is
-the dual of
-.Em RETURN VALUES ,
-which is used for functions. Historically, this information was
-described in
-.Em DIAGNOSTICS ,
-a practise that is now discouraged.
-.Pp
-See
-.Sx \&Ex .
+Implementation-specific notes should be kept here.
+This is useful when implementing standard functions that may have side
+effects or notable algorithmic implications.
.It Em RETURN VALUES
This section is the dual of
.Em EXIT STATUS ,
-which is used for commands. It documents the return values of functions
-in sections 2, 3, and 9.
+which is used for commands.
+It documents the return values of functions in sections 2, 3, and 9.
.Pp
See
.Sx \&Rv .
@@ -478,17 +476,30 @@ Documents any usages of environment variables, e.g.,
See
.Sx \&Ev .
.It Em FILES
-Documents files used. It's helpful to document both the file and a
-short description of how the file is used (created, modified, etc.).
+Documents files used.
+It's helpful to document both the file and a short description of how
+the file is used (created, modified, etc.).
.Pp
See
.Sx \&Pa .
+.It Em EXIT STATUS
+Command exit status for section 1, 6, and 8 manuals.
+This section is the dual of
+.Em RETURN VALUES ,
+which is used for functions.
+Historically, this information was described in
+.Em DIAGNOSTICS ,
+a practise that is now discouraged.
+.Pp
+See
+.Sx \&Ex .
.It Em EXAMPLES
-Example usages. This often contains snippets of well-formed,
-well-tested invocations. Make doubly sure that your examples work
-properly!
+Example usages.
+This often contains snippets of well-formed, well-tested invocations.
+Make doubly sure that your examples work properly!
.It Em DIAGNOSTICS
-Documents error conditions. This is most useful in section 4 manuals.
+Documents error conditions.
+This is most useful in section 4 manuals.
Historically, this section was used in place of
.Em EXIT STATUS
for manuals in sections 1, 6, and 8; however, this practise is
@@ -503,15 +514,16 @@ Documents error handling in sections 2, 3, and 9.
See
.Sx \&Er .
.It Em SEE ALSO
-References other manuals with related topics. This section should exist
-for most manuals. Cross-references should conventionally be ordered
-first by section, then alphabetically.
+References other manuals with related topics.
+This section should exist for most manuals.
+Cross-references should conventionally be ordered first by section, then
+alphabetically.
.Pp
See
.Sx \&Xr .
.It Em STANDARDS
-References any standards implemented or used. If not adhering to any
-standards, the
+References any standards implemented or used.
+If not adhering to any standards, the
.Em HISTORY
section should be used instead.
.Pp
@@ -539,15 +551,17 @@ Documents any security precautions that operators should consider.
Macros are one to three three characters in length and begin with a
control character ,
.Sq \&. ,
-at the beginning of the line. An arbitrary amount of whitespace may
-sit between the control character and the macro name. Thus, the
-following are equivalent:
+at the beginning of the line.
+An arbitrary amount of whitespace may sit between the control character
+and the macro name.
+Thus, the following are equivalent:
.Bd -literal -offset indent
\&.Pp
\&.\ \ \ \&Pp
.Ed
.Pp
-The syntax of a macro depends on its classification. In this section,
+The syntax of a macro depends on its classification.
+In this section,
.Sq \-arg
refers to macro arguments, which may be followed by zero or more
.Sq parm
@@ -560,8 +574,9 @@ closes it out.
The
.Em Callable
column indicates that the macro may be called subsequent to the initial
-line-macro. If a macro is not callable, then its invocation after the
-initial line macro is interpreted as opaque text, such that
+line-macro.
+If a macro is not callable, then its invocation after the initial line
+macro is interpreted as opaque text, such that
.Sq \&.Fl \&Sh
produces
.Sq Fl \&Sh .
@@ -569,15 +584,16 @@ produces
The
.Em Parsable
column indicates whether the macro may be followed by further
-(ostensibly callable) macros. If a macro is not parsable, subsequent
-macro invocations on the line will be interpreted as opaque text.
+(ostensibly callable) macros.
+If a macro is not parsable, subsequent macro invocations on the line
+will be interpreted as opaque text.
.Pp
The
.Em Scope
column, if applicable, describes closure rules.
.Ss Block full-explicit
-Multi-line scope closed by an explicit closing macro. All macros
-contains bodies; only
+Multi-line scope closed by an explicit closing macro.
+All macros contains bodies; only
.Sx \&Bf
contains a head.
.Bd -literal -offset indent
@@ -625,8 +641,8 @@ has multiple heads.
.It Sx \&Ss Ta \&No Ta \&No Ta closed by Sx \&Sh , Sx \&Ss
.El
.Ss Block partial-explicit
-Like block full-explicit, but also with single-line scope. Each
-has at least a body and, in limited circumstances, a head
+Like block full-explicit, but also with single-line scope.
+Each has at least a body and, in limited circumstances, a head
.Po
.Sx \&Fo ,
.Sx \&Eo
@@ -703,9 +719,9 @@ in a SYNOPSIS section line, else it is
.Ss In-line
Closed by
.Sx Reserved Characters ,
-end of line, fixed argument lengths, and/or subsequent macros. In-line
-macros have only text children. If a number (or inequality) of
-arguments is
+end of line, fixed argument lengths, and/or subsequent macros.
+In-line macros have only text children.
+If a number (or inequality) of arguments is
.Pq n ,
then the macro accepts an arbitrary number of arguments.
.Bd -literal -offset indent
@@ -795,7 +811,8 @@ then the macro accepts an arbitrary number of arguments.
.El
.Sh REFERENCE
This section is a canonical reference of all macros, arranged
-alphabetically. For the scoping of individual macros, see
+alphabetically.
+For the scoping of individual macros, see
.Sx MACRO SYNTAX .
.Ss \&%A
Author name of an
@@ -876,8 +893,9 @@ Examples:
.D1 \&.Ad [0,$]
.D1 \&.Ad 0x00000000
.Ss \&An
-Author name. This macro may alternatively accepts the following
-arguments, although these may not be specified along with a parameter:
+Author name.
+This macro may alternatively accepts the following arguments, although
+these may not be specified along with a parameter:
.Bl -tag -width 12n -offset indent
.It Fl split
Renders a line break before each author listing.
@@ -888,10 +906,11 @@ The opposite of
.Pp
In the AUTHORS section, the default is not to split the first author
listing, but all subsequent author listings, whether or not they're
-interspersed by other macros or text, are split. Thus, specifying
+interspersed by other macros or text, are split.
+Thus, specifying
.Fl split
-will cause the first listing also to be split. If not in the AUTHORS
-section, the default is not to split.
+will cause the first listing also to be split.
+If not in the AUTHORS section, the default is not to split.
.Pp
Examples:
.D1 \&.An -nosplit
@@ -907,8 +926,8 @@ are re-set when entering the AUTHORS section, so if one specifies
in the general document body, it must be re-specified in the AUTHORS
section.
.Ss \&Ao
-Begins a block enclosed by angled brackets. Does not have any head
-arguments.
+Begins a block enclosed by angled brackets.
+Does not have any head arguments.
.Pp
Examples:
.D1 \&.Fl -key= \&Ns \&Ao \&Ar val \&Ac
@@ -916,9 +935,9 @@ Examples:
See also
.Sx \&Aq .
.Ss \&Ap
-Inserts an apostrophe without any surrounding white-space. This is
-generally used as a grammatic device when referring to the verb form of
-a function:
+Inserts an apostrophe without any surrounding white-space.
+This is generally used as a grammatic device when referring to the verb
+form of a function:
.Bd -literal -offset indent
\&.Fn execve Ap d
.Ed
@@ -941,7 +960,8 @@ statements, which should use
See also
.Sx \&Ao .
.Ss \&Ar
-Command arguments. If an argument is not provided, the string
+Command arguments.
+If an argument is not provided, the string
.Dq file ...
is used as a default.
.Pp
@@ -950,7 +970,8 @@ Examples:
.D1 \&.Ar
.D1 \&.Ar arg1 , arg2 .
.Ss \&At
-Formats an AT&T version. Accepts at most one parameter:
+Formats an AT&T version.
+Accepts at most one parameter:
.Bl -tag -width 12n -offset indent
.It Cm v[1-7] | 32v
A version of
@@ -980,10 +1001,11 @@ Closes a
.Sx \&Bo
block. Does not have any tail arguments.
.Ss \&Bd
-Begins a display block. A display is collection of macros or text which
-may be collectively offset or justified in a manner different from that
-of the enclosing context. By default, the block is preceded by a
-vertical space.
+Begins a display block.
+A display is collection of macros or text which may be collectively
+offset or justified in a manner different from that
+of the enclosing context.
+By default, the block is preceded by a vertical space.
.Pp
Each display is associated with a type, which must be one of the
following arguments:
@@ -1001,7 +1023,8 @@ Alias for
Centre-justify each line.
.El
.Pp
-The type must be provided first. Secondary arguments are as follows:
+The type must be provided first.
+Secondary arguments are as follows:
.Bl -tag -width 12n -offset indent
.It Fl offset Ar width
Offset by the value of
@@ -1022,8 +1045,8 @@ which justifies to the right margin; and
.Ar center ,
which aligns around an imagined centre axis.
.It
-As a precalculated width for a named macro. The most popular is the
-imaginary macro
+As a precalculated width for a named macro.
+The most popular is the imaginary macro
.Ar \&Ds ,
which resolves to
.Ar 6n .
@@ -1115,8 +1138,8 @@ and
.\" More...
.\" .
.Ss \&Bo
-Begins a block enclosed by square brackets. Does not have any head
-arguments.
+Begins a block enclosed by square brackets.
+Does not have any head arguments.
.Pp
Examples:
.Bd -literal -offset indent
@@ -1147,8 +1170,8 @@ Closes a
.Sx \&Bro
block. Does not have any tail arguments.
.Ss \&Bro
-Begins a block enclosed by curly braces. Does not have any head
-arguments.
+Begins a block enclosed by curly braces.
+Does not have any head arguments.
.Pp
Examples:
.Bd -literal -offset indent
@@ -1204,7 +1227,8 @@ See also
and
.Sx \&Ux .
.Ss \&Cd
-Configuration declaration. This denotes strings accepted by
+Configuration declaration.
+This denotes strings accepted by
.Xr config 8 .
.Pp
Examples:
@@ -1214,10 +1238,11 @@ Examples:
this macro is commonly abused by using quoted literals to retain
white-space and align consecutive
.Sx \&Cd
-declarations. This practise is discouraged.
+declarations.
+This practise is discouraged.
.Ss \&Cm
-Command modifiers. Useful when specifying configuration options or
-keys.
+Command modifiers.
+Useful when specifying configuration options or keys.
.Pp
Examples:
.D1 \&.Cm ControlPath
@@ -1226,8 +1251,10 @@ Examples:
See also
.Sx \&Fl .
.Ss \&D1
-One-line indented display. This is formatted by the default rules and
-is useful for simple indented statements. It is followed by a newline.
+One-line indented display.
+This is formatted by the default rules and is useful for simple indented
+statements.
+It is followed by a newline.
.Pp
Examples:
.D1 \&.D1 \&Fl abcdefgh
@@ -1242,9 +1269,11 @@ Closes a
.Sx \&Do
block. Does not have any tail arguments.
.Ss \&Dd
-Document date. This is the mandatory first macro of any
+Document date.
+This is the mandatory first macro of any
.Nm
-manual. Its calling syntax is as follows:
+manual.
+Its calling syntax is as follows:
.Pp
.D1 \. Ns Sx \&Dd Cm date
.Pp
@@ -1268,8 +1297,10 @@ See also
and
.Sx \&Os .
.Ss \&Dl
-One-line intended display. This is formatted as literal text and is
-useful for commands and invocations. It is followed by a newline.
+One-line intended display.
+This is formatted as literal text and is useful for commands and
+invocations.
+It is followed by a newline.
.Pp
Examples:
.D1 \&.Dl % mandoc mdoc.7 | less
@@ -1299,19 +1330,22 @@ Examples:
See also
.Sx \&Do .
.Ss \&Dt
-Document title. This is the mandatory second macro of any
+Document title.
+This is the mandatory second macro of any
.Nm
-file. Its calling syntax is as follows:
+file.
+Its calling syntax is as follows:
.Pp
.D1 \. Ns Sx \&Dt Cm title section Op Cm volume | arch
.Pp
Its arguments are as follows:
.Bl -tag -width Ds -offset Ds
.It Cm title
-The document's title (name). This should be capitalised and is
-required.
+The document's title (name).
+This should be capitalised and is required.
.It Cm section
-The manual section. This may be one of
+The manual section.
+This may be one of
.Ar 1
.Pq utilities ,
.Ar 2
@@ -1377,10 +1411,13 @@ or
.Ar CON
.Pq contributed manuals .
.It Cm arch
-This specifies a specific relevant architecture. If
+This specifies a specific relevant architecture.
+If
.Cm volume
is not provided, it may be used in its place, else it may be used
-subsequent that. It, too, is optional. It must be one of
+subsequent that.
+It, too, is optional.
+It must be one of
.Ar alpha ,
.Ar amd64 ,
.Ar amiga ,
@@ -1453,9 +1490,9 @@ and
.Ss \&Ek
.Ss \&El
.Ss \&Em
-Denotes text that should be emphasised. Note that this is a
-presentation term and should not be used for stylistically decorating
-technical terms.
+Denotes text that should be emphasised.
+Note that this is a presentation term and should not be used for
+stylistically decorating technical terms.
.Pp
Examples:
.D1 \&.Em Warnings!
@@ -1480,8 +1517,8 @@ Examples:
.D1 \&.Ev DISPLAY
.D1 \&.Ev PATH
.Ss \&Ex
-Inserts text regarding a utility's exit values. This macro must have
-first the
+Inserts text regarding a utility's exit values.
+This macro must have first the
.Fl std
argument specified, then an optional
.Ar utility .
@@ -1494,12 +1531,14 @@ is provided.
.Ss \&Fc
.Ss \&Fd
.Ss \&Fl
-Command-line flag. Used when listing arguments to command-line
-utilities. Prints a fixed-width hyphen
+Command-line flag.
+Used when listing arguments to command-line utilities.
+Prints a fixed-width hyphen
.Sq \-
-directly followed by each argument. If no arguments are provided, a hyphen is
-printed followed by a space. If the argument is a macro, a hyphen is
-prefixed to the subsequent macro output.
+directly followed by each argument.
+If no arguments are provided, a hyphen is printed followed by a space.
+If the argument is a macro, a hyphen is prefixed to the subsequent macro
+output.
.Pp
Examples:
.D1 \&.Fl a b c
@@ -1537,7 +1576,8 @@ and
.Ss \&Lb
.Ss \&Li
.Ss \&Lk
-Format a hyperlink. The calling syntax is as follows:
+Format a hyperlink.
+The calling syntax is as follows:
.Pp
.D1 \. Ns Sx \&Lk Cm uri Op Cm name
.Pp
@@ -1575,7 +1615,8 @@ and
.Ss \&Oo
.Ss \&Op
.Ss \&Os
-Document operating system version. This is the mandatory third macro of
+Document operating system version.
+This is the mandatory third macro of
any
.Nm
file. Its calling syntax is as follows:
@@ -1584,9 +1625,9 @@ file. Its calling syntax is as follows:
.Pp
The optional
.Cm system
-parameter specifies the relevant operating system or environment. Left
-unspecified, it defaults to the local operating system version. This is
-the suggested form.
+parameter specifies the relevant operating system or environment.
+Left unspecified, it defaults to the local operating system version.
+This is the suggested form.
.Pp
Examples:
.D1 \&.Os
@@ -1632,12 +1673,14 @@ and
.Ss \&Re
Closes a
.Sx \&Rs
-block. Does not have any tail arguments.
+block.
+Does not have any tail arguments.
.Ss \&Rs
Begins a bibliographic
.Pq Dq reference
-block. Does not have any head arguments. The block macro may only
-contain
+block.
+Does not have any head arguments.
+The block macro may only contain
.Sx \&%A ,
.Sx \&%B ,
.Sx \&%C ,
@@ -1684,7 +1727,8 @@ line.
.Ss \&Tn
.Ss \&Ud
.Ss \&Ux
-Format the UNIX name. Accepts no argument.
+Format the UNIX name.
+Accepts no argument.
.Pp
Examples:
.D1 \&.Ux
@@ -1700,9 +1744,10 @@ and
.Sx \&Ox .
.Ss \&Va
.Ss \&Vt
-A variable type. This is also used for indicating global variables in the
-SYNOPSIS section, in which case a variable name is also specified. Note that
-it accepts
+A variable type.
+This is also used for indicating global variables in the SYNOPSIS
+section, in which case a variable name is also specified.
+Note that it accepts
.Sx Block partial-implicit
syntax when invoked as the first macro in the SYNOPSIS section, else it
accepts ordinary
@@ -1725,9 +1770,9 @@ and
Close a scope opened by
.Sx \&Xo .
.Ss \&Xo
-Open an extension scope. This macro originally existed to extend the
-9-argument limit of troff; since this limit has been lifted, the macro
-has been deprecated.
+Open an extension scope.
+This macro originally existed to extend the 9-argument limit of troff;
+since this limit has been lifted, the macro has been deprecated.
.Ss \&Xr
Link to another manual
.Pq Qq cross-reference .
@@ -1739,12 +1784,13 @@ The
.Cm name
and
.Cm section
-are the name and section of the linked manual. If
+are the name and section of the linked manual.
+If
.Cm section
is followed by non-punctuation, an
.Sx \&Ns
-is inserted into the token stream. This behaviour is for compatibility
-with
+is inserted into the token stream.
+This behaviour is for compatibility with
.Xr groff 1 .
.Pp
Examples:
@@ -1776,25 +1822,29 @@ is no longer accepted.
In groff, the
.Sx \&Pa
macro does not format its arguments when used in the FILES section under
-certain list types. mandoc does.
+certain list types.
+mandoc does.
.It
Historic groff does not print a dash for empty
.Sx \&Fl
-arguments. mandoc and newer groff implementations do.
+arguments.
+mandoc and newer groff implementations do.
.It
groff behaves irregularly when specifying
.Sq \ef
.Sx Text Decoration
-within line-macro scopes. mandoc follows a consistent system.
+within line-macro scopes.
+mandoc follows a consistent system.
.It
In mandoc, negative scaling units are truncated to zero; groff would
-move to prior lines. Furthermore, the
+move to prior lines.
+Furthermore, the
.Sq f
scaling unit, while accepted, is rendered as the default unit.
.It
In quoted literals, groff allowed pair-wise double-quotes to produce a
-standalone double-quote in formatted output. This idiosyncratic
-behaviour is not applicable in mandoc.
+standalone double-quote in formatted output.
+This idiosyncratic behaviour is not applicable in mandoc.
.It
Display types
.Sx \&Bd
@@ -1805,8 +1855,8 @@ are aliases for
.Fl left
in manodc. Furthermore, the
.Fl file Ar file
-argument is ignored. Lastly, since text is not right-justified in
-mandoc (or even groff),
+argument is ignored.
+Lastly, since text is not right-justified in mandoc (or even groff),
.Fl ragged
and
.Fl filled
@@ -1815,8 +1865,8 @@ are aliases, as are
and
.Fl unfilled .
.It
-Historic groff has many un-callable macros. Most of these (excluding
-some block-level macros) are now callable.
+Historic groff has many un-callable macros.
+Most of these (excluding some block-level macros) are now callable.
.It
The vertical bar
.Sq \(ba
@@ -1833,20 +1883,21 @@ lists will restart the sequence only for the sub-list.
Some manuals use
.Sx \&Li
incorrectly by following it with a reserved character and expecting the
-delimiter to render. This is not supported in mandoc.
+delimiter to render.
+This is not supported in mandoc.
.It
In groff, the
.Sx \&Fo
-macro only produces the first parameter. This is not the case in
-mandoc.
+macro only produces the first parameter.
+This is not the case in mandoc.
.It
In groff, the
.Sx \&Cd ,
.Sx \&Er ,
and
.Sx \&Ex
-macros were stipulated only to occur in certain manual sections. mandoc
-does not have these restrictions.
+macros were stipulated only to occur in certain manual sections.
+mandoc does not have these restrictions.
.El
.Sh SEE ALSO
.Xr mandoc 1 ,
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index 3005fe85738..a19720547b1 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.46 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.47 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -285,7 +285,9 @@ mdoc_parseln(struct mdoc *m, int ln, char *buf)
if (MDOC_HALT & m->flags)
return(0);
- return('.' == *buf ? mdoc_pmacro(m, ln, buf) :
+ m->flags |= MDOC_NEWLINE;
+ return('.' == *buf ?
+ mdoc_pmacro(m, ln, buf) :
mdoc_ptext(m, ln, buf));
}
@@ -449,7 +451,9 @@ node_alloc(struct mdoc *m, int line, int pos,
p->pos = pos;
p->tok = tok;
p->type = type;
-
+ if (MDOC_NEWLINE & m->flags)
+ p->flags |= MDOC_LINE;
+ m->flags &= ~MDOC_NEWLINE;
return(p);
}
@@ -721,7 +725,7 @@ int
mdoc_pmacro(struct mdoc *m, int ln, char *buf)
{
enum mdoct tok;
- int i, j;
+ int i, j, sv;
char mac[5];
struct mdoc_node *n;
char *t;
@@ -743,6 +747,8 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf)
return(1);
}
+ sv = i;
+
/* Copy the first word into a nil-terminated buffer. */
for (j = 0; j < 4; j++, i++) {
@@ -790,7 +796,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf)
* Begin recursive parse sequence. Since we're at the start of
* the line, we don't need to do callable/parseable checks.
*/
- if ( ! mdoc_macro(m, tok, ln, 1, &i, buf))
+ if ( ! mdoc_macro(m, tok, ln, sv, &i, buf))
goto err;
/*
diff --git a/usr.bin/mandoc/mdoc.h b/usr.bin/mandoc/mdoc.h
index a9c003b661e..42fc45bf333 100644
--- a/usr.bin/mandoc/mdoc.h
+++ b/usr.bin/mandoc/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.20 2010/05/13 20:34:29 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.21 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -203,10 +203,10 @@ enum mdoc_sec {
SEC_SYNOPSIS,
SEC_DESCRIPTION,
SEC_IMPLEMENTATION,
- SEC_EXIT_STATUS,
SEC_RETURN_VALUES,
SEC_ENVIRONMENT,
SEC_FILES,
+ SEC_EXIT_STATUS,
SEC_EXAMPLES,
SEC_DIAGNOSTICS,
SEC_COMPATIBILITY,
@@ -218,7 +218,8 @@ enum mdoc_sec {
SEC_CAVEATS,
SEC_BUGS,
SEC_SECURITY,
- SEC_CUSTOM /* User-defined. */
+ SEC_CUSTOM, /* User-defined. */
+ SEC__MAX
};
/* Information from prologue. */
@@ -249,20 +250,21 @@ struct mdoc_arg {
/* Node in AST. */
struct mdoc_node {
- struct mdoc_node *parent;
- struct mdoc_node *child;
- struct mdoc_node *next;
- struct mdoc_node *prev;
- int nchild;
- int line;
- int pos;
- enum mdoct tok;
+ struct mdoc_node *parent; /* parent AST node */
+ struct mdoc_node *child; /* first child AST node */
+ struct mdoc_node *next; /* sibling AST node */
+ struct mdoc_node *prev; /* prior sibling AST node */
+ int nchild; /* number children */
+ int line; /* parse line */
+ int pos; /* parse column */
+ enum mdoct tok; /* tok or MDOC__MAX if none */
int flags;
-#define MDOC_VALID (1 << 0)
-#define MDOC_ACTED (1 << 1)
- enum mdoc_type type;
- enum mdoc_sec sec;
-
+#define MDOC_VALID (1 << 0) /* has been validated */
+#define MDOC_ACTED (1 << 1) /* has been acted upon */
+#define MDOC_EOS (1 << 2) /* at sentence boundary */
+#define MDOC_LINE (1 << 3) /* first macro/text on line */
+ enum mdoc_type type; /* AST node type */
+ enum mdoc_sec sec; /* current named section */
struct mdoc_arg *args; /* BLOCK/ELEM */
struct mdoc_node *pending; /* BLOCK */
struct mdoc_node *head; /* BLOCK */
diff --git a/usr.bin/mandoc/mdoc_action.c b/usr.bin/mandoc/mdoc_action.c
index 8c0b356d28a..0af3d507b49 100644
--- a/usr.bin/mandoc/mdoc_action.c
+++ b/usr.bin/mandoc/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.31 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: mdoc_action.c,v 1.32 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -416,7 +416,7 @@ post_sh(POST_ARGS)
if ( ! concat(m, buf, n->child, BUFSIZ))
return(0);
- sec = mdoc_atosec(buf);
+ sec = mdoc_str2sec(buf);
/*
* The first section should always make us move into a non-new
* state.
diff --git a/usr.bin/mandoc/mdoc_argv.c b/usr.bin/mandoc/mdoc_argv.c
index 19877837017..632717cc1e0 100644
--- a/usr.bin/mandoc/mdoc_argv.c
+++ b/usr.bin/mandoc/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.24 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: mdoc_argv.c,v 1.25 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -399,9 +399,10 @@ args(struct mdoc *m, int line, int *pos,
return(ARGS_EOLN);
/*
- * If the first character is a delimiter and we're to look for
- * delimited strings, then pass down the buffer seeing if it
- * follows the pattern of [[::delim::][ ]+]+.
+ * If the first character is a closing delimiter and we're to
+ * look for delimited strings, then pass down the buffer seeing
+ * if it follows the pattern of [[::delim::][ ]+]+. Note that
+ * we ONLY care about closing delimiters.
*/
if ((fl & ARGS_DELIM) && mdoc_iscdelim(buf[*pos]) > 1) {
@@ -409,14 +410,14 @@ args(struct mdoc *m, int line, int *pos,
if ( mdoc_iscdelim(buf[i]) < 2)
break;
i++;
- if (0 == buf[i] || ' ' != buf[i])
+ if ('\0' == buf[i] || ' ' != buf[i])
break;
i++;
while (buf[i] && ' ' == buf[i])
i++;
}
- if (0 == buf[i]) {
+ if ('\0' == buf[i]) {
*v = &buf[*pos];
if (' ' != buf[i - 1])
return(ARGS_PUNCT);
@@ -468,8 +469,10 @@ args(struct mdoc *m, int line, int *pos,
} else if (pp && ! p) {
p = pp;
*pos += 2;
- } else
+ } else {
+ rc = ARGS_PEND;
p = strchr(*v, 0);
+ }
/* Whitespace check for eoln case... */
if (0 == *p && ' ' == *(p - 1) && ! (ARGS_NOWARN & fl))
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 24f1b4c00c4..f44fcaa7162 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.12 2010/05/08 02:10:09 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.13 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -726,7 +726,8 @@ mdoc_nm_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (SEC_SYNOPSIS == n->sec && n->prev) {
+ if (SEC_SYNOPSIS == n->sec &&
+ n->prev && MDOC_LINE & n->flags) {
bufcat_style(h, "clear", "both");
PAIR_STYLE_INIT(&tag, h);
print_otag(h, TAG_BR, 1, &tag);
@@ -1554,7 +1555,7 @@ mdoc_fd_pre(MDOC_ARGS)
struct htmlpair tag;
struct roffsu su;
- if (SEC_SYNOPSIS == n->sec) {
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
if (n->next && MDOC_Fd != n->next->tok) {
SCALE_VS_INIT(&su, 1);
bufcat_su(h, "margin-bottom", &su);
@@ -1602,7 +1603,7 @@ mdoc_ft_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
print_otag(h, TAG_DIV, 0, NULL);
PAIR_CLASS_INIT(&tag, "ftype");
@@ -1623,7 +1624,7 @@ mdoc_fn_pre(MDOC_ARGS)
int sz, i;
struct roffsu su;
- if (SEC_SYNOPSIS == n->sec) {
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
SCALE_HS_INIT(&su, INDENT);
bufcat_su(h, "margin-left", &su);
su.scale = -su.scale;
@@ -1864,7 +1865,7 @@ mdoc_in_pre(MDOC_ARGS)
int i;
struct roffsu su;
- if (SEC_SYNOPSIS == n->sec) {
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
if (n->next && MDOC_In != n->next->tok) {
SCALE_VS_INIT(&su, 1);
bufcat_su(h, "margin-bottom", &su);
@@ -2169,7 +2170,7 @@ mdoc_lb_pre(MDOC_ARGS)
{
struct htmlpair tag;
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
print_otag(h, TAG_DIV, 0, NULL);
PAIR_CLASS_INIT(&tag, "lib");
print_otag(h, TAG_SPAN, 1, &tag);
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index db2081c0e20..71de1d92f7a 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.36 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.37 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -43,7 +43,8 @@ static int append_delims(struct mdoc *,
int, int *, char *);
static enum mdoct lookup(enum mdoct, const char *);
static enum mdoct lookup_raw(const char *);
-static int phrase(struct mdoc *, int, int, char *);
+static int phrase(struct mdoc *, int, int,
+ char *, enum margserr, int);
static enum mdoct rew_alt(enum mdoct);
static int rew_dobreak(enum mdoct,
const struct mdoc_node *);
@@ -646,11 +647,13 @@ append_delims(struct mdoc *mdoc, int line, int *pos, char *buf)
static int
blk_exp_close(MACRO_PROT_ARGS)
{
- int j, lastarg, maxargs, flushed;
+ int j, lastarg, maxargs, flushed, nl;
enum margserr ac;
enum mdoct ntok;
char *p;
+ nl = MDOC_NEWLINE & m->flags;
+
switch (tok) {
case (MDOC_Ec):
maxargs = 1;
@@ -716,7 +719,7 @@ blk_exp_close(MACRO_PROT_ARGS)
if ( ! flushed && ! rew_sub(MDOC_BLOCK, m, tok, line, ppos))
return(0);
- if (ppos > 1)
+ if ( ! nl)
return(1);
return(append_delims(m, line, pos, buf));
}
@@ -725,13 +728,15 @@ blk_exp_close(MACRO_PROT_ARGS)
static int
in_line(MACRO_PROT_ARGS)
{
- int la, lastpunct, cnt, d, nc;
+ int la, lastpunct, cnt, d, nc, nl;
enum margverr av;
enum mdoct ntok;
enum margserr ac;
struct mdoc_arg *arg;
char *p;
+ nl = MDOC_NEWLINE & m->flags;
+
/*
* Whether we allow ignored elements (those without content,
* usually because of reserved words) to squeak by.
@@ -808,7 +813,7 @@ in_line(MACRO_PROT_ARGS)
}
if ( ! mdoc_macro(m, ntok, line, la, pos, buf))
return(0);
- if (ppos > 1)
+ if ( ! nl)
return(1);
return(append_delims(m, line, pos, buf));
}
@@ -868,7 +873,7 @@ in_line(MACRO_PROT_ARGS)
return(0);
}
- if (ppos > 1)
+ if ( ! nl)
return(1);
return(append_delims(m, line, pos, buf));
}
@@ -877,13 +882,13 @@ in_line(MACRO_PROT_ARGS)
static int
blk_full(MACRO_PROT_ARGS)
{
- int la;
+ int la, pcnt;
struct mdoc_arg *arg;
struct mdoc_node *head; /* save of head macro */
struct mdoc_node *body; /* save of body macro */
struct mdoc_node *n;
enum mdoct ntok;
- enum margserr ac;
+ enum margserr ac, lac;
enum margverr av;
char *p;
@@ -944,8 +949,11 @@ blk_full(MACRO_PROT_ARGS)
body = m->last;
}
- for (;;) {
+ ac = ARGS_ERROR;
+
+ for (pcnt = 0; ; ) {
la = *pos;
+ lac = ac;
ac = mdoc_args(m, line, pos, buf, tok, &p);
if (ARGS_ERROR == ac)
@@ -960,8 +968,10 @@ blk_full(MACRO_PROT_ARGS)
#if 0
/* Don't emit leading punct. for phrases. */
- if (NULL == head && ARGS_PHRASE != ac &&
+ if (NULL == head &&
+ ARGS_PHRASE != ac &&
ARGS_PPHRASE != ac &&
+ ARGS_PEND != ac &&
ARGS_QWORD != ac &&
1 == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
@@ -972,15 +982,30 @@ blk_full(MACRO_PROT_ARGS)
/* Always re-open head for phrases. */
- if (NULL == head || ARGS_PHRASE == ac ||
+ if (NULL == head ||
+ ARGS_PHRASE == ac ||
+ ARGS_PEND == ac ||
ARGS_PPHRASE == ac) {
if ( ! mdoc_head_alloc(m, line, ppos, tok))
return(0);
head = m->last;
}
- if (ARGS_PHRASE == ac || ARGS_PPHRASE == ac) {
- if ( ! phrase(m, line, la, buf))
+ if (ARGS_PHRASE == ac ||
+ ARGS_PEND == ac ||
+ ARGS_PPHRASE == ac) {
+ /*
+ * Special treatment for the last phrase. A
+ * prior ARGS_PHRASE gets is handled as a
+ * regular ARGS_PHRASE, but a prior ARGS_PPHRASE
+ * has special handling.
+ */
+ if (ARGS_PEND == ac && ARGS_ERROR == lac)
+ ac = ARGS_PHRASE;
+ else if (ARGS_PEND == ac && ARGS_PHRASE == lac)
+ ac = ARGS_PHRASE;
+
+ if ( ! phrase(m, line, la, buf, ac, pcnt++))
return(0);
if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos))
return(0);
@@ -1160,13 +1185,15 @@ blk_part_imp(MACRO_PROT_ARGS)
static int
blk_part_exp(MACRO_PROT_ARGS)
{
- int la;
+ int la, nl;
enum margserr ac;
struct mdoc_node *head; /* keep track of head */
struct mdoc_node *body; /* keep track of body */
char *p;
enum mdoct ntok;
+ nl = MDOC_NEWLINE & m->flags;
+
/*
* The opening of an explicit macro having zero or more leading
* punctuation nodes; a head with optional single element (the
@@ -1265,23 +1292,25 @@ blk_part_exp(MACRO_PROT_ARGS)
/* Standard appending of delimiters. */
- if (ppos > 1)
+ if ( ! nl)
return(1);
-
return(append_delims(m, line, pos, buf));
}
+/* ARGSUSED */
static int
in_line_argn(MACRO_PROT_ARGS)
{
- int la, flushed, j, maxargs;
+ int la, flushed, j, maxargs, nl;
enum margserr ac;
enum margverr av;
struct mdoc_arg *arg;
char *p;
enum mdoct ntok;
+ nl = MDOC_NEWLINE & m->flags;
+
/*
* A line macro that has a fixed number of arguments (maxargs).
* Only open the scope once the first non-leading-punctuation is
@@ -1405,8 +1434,7 @@ in_line_argn(MACRO_PROT_ARGS)
if ( ! flushed && ! rew_elem(m, tok))
return(0);
-
- if (ppos > 1)
+ if ( ! nl)
return(1);
return(append_delims(m, line, pos, buf));
}
@@ -1482,13 +1510,16 @@ in_line_eoln(MACRO_PROT_ARGS)
static int
ctx_synopsis(MACRO_PROT_ARGS)
{
+ int nl;
+
+ nl = MDOC_NEWLINE & m->flags;
/* If we're not in the SYNOPSIS, go straight to in-line. */
if (SEC_SYNOPSIS != m->lastsec)
return(in_line(m, tok, line, ppos, pos, buf));
/* If we're a nested call, same place. */
- if (ppos > 1)
+ if ( ! nl)
return(in_line(m, tok, line, ppos, pos, buf));
/*
@@ -1516,25 +1547,34 @@ obsolete(MACRO_PROT_ARGS)
* macro is encountered.
*/
static int
-phrase(struct mdoc *m, int line, int ppos, char *buf)
+phrase(struct mdoc *m, int line, int ppos, char *buf,
+ enum margserr ac, int count)
{
int la, pos;
- enum margserr ac;
+ enum margserr aac;
enum mdoct ntok;
char *p;
+ assert(ARGS_PHRASE == ac ||
+ ARGS_PEND == ac ||
+ ARGS_PPHRASE == ac);
+
+ if (count && ARGS_PPHRASE == ac)
+ return(mdoc_word_alloc(m, line, ppos, &buf[ppos]));
+
for (pos = ppos; ; ) {
la = pos;
/* Note: no calling context! */
- ac = mdoc_zargs(m, line, &pos, buf, 0, &p);
+ aac = mdoc_zargs(m, line, &pos, buf, 0, &p);
- if (ARGS_ERROR == ac)
+ if (ARGS_ERROR == aac)
return(0);
- if (ARGS_EOLN == ac)
+ if (ARGS_EOLN == aac)
break;
- ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p);
+ ntok = ARGS_QWORD == aac || ARGS_PEND == ac ?
+ MDOC_MAX : lookup_raw(p);
if (MDOC_MAX == ntok) {
if ( ! mdoc_word_alloc(m, line, la, p))
diff --git a/usr.bin/mandoc/mdoc_strings.c b/usr.bin/mandoc/mdoc_strings.c
index 0110cc440ee..193e865bfa4 100644
--- a/usr.bin/mandoc/mdoc_strings.c
+++ b/usr.bin/mandoc/mdoc_strings.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_strings.c,v 1.14 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: mdoc_strings.c,v 1.15 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -24,39 +24,31 @@
#include "libmdoc.h"
-/* FIXME: this file is poorly named. */
-
-struct mdoc_secname {
- const char *name; /* Name of section. */
- enum mdoc_sec sec; /* Corresponding section. */
-};
-
-#define SECNAME_MAX (20)
-
-static const struct mdoc_secname secnames[SECNAME_MAX] = {
- { "NAME", SEC_NAME },
- { "LIBRARY", SEC_LIBRARY },
- { "SYNOPSIS", SEC_SYNOPSIS },
- { "DESCRIPTION", SEC_DESCRIPTION },
- { "IMPLEMENTATION NOTES", SEC_IMPLEMENTATION },
- { "EXIT STATUS", SEC_EXIT_STATUS },
- { "RETURN VALUES", SEC_RETURN_VALUES },
- { "ENVIRONMENT", SEC_ENVIRONMENT },
- { "FILES", SEC_FILES },
- { "EXAMPLES", SEC_EXAMPLES },
- { "DIAGNOSTICS", SEC_DIAGNOSTICS },
- { "COMPATIBILITY", SEC_COMPATIBILITY },
- { "ERRORS", SEC_ERRORS },
- { "SEE ALSO", SEC_SEE_ALSO },
- { "STANDARDS", SEC_STANDARDS },
- { "HISTORY", SEC_HISTORY },
- { "AUTHORS", SEC_AUTHORS },
- { "CAVEATS", SEC_CAVEATS },
- { "BUGS", SEC_BUGS },
- { "SECURITY CONSIDERATIONS", SEC_SECURITY }
+static const char * const secnames[SEC__MAX] = {
+ NULL,
+ "NAME",
+ "LIBRARY",
+ "SYNOPSIS",
+ "DESCRIPTION",
+ "IMPLEMENTATION NOTES",
+ "RETURN VALUES",
+ "ENVIRONMENT",
+ "FILES",
+ "EXIT STATUS",
+ "EXAMPLES",
+ "DIAGNOSTICS",
+ "COMPATIBILITY",
+ "ERRORS",
+ "SEE ALSO",
+ "STANDARDS",
+ "HISTORY",
+ "AUTHORS",
+ "CAVEATS",
+ "BUGS",
+ "SECURITY CONSIDERATIONS",
+ NULL
};
-
/*
* FIXME: this is repeated in print_text() (html.c) and term_word()
* (term.c).
@@ -66,7 +58,7 @@ mdoc_iscdelim(char p)
{
switch (p) {
- case('|'): /* FIXME! */
+ case('|'):
/* FALLTHROUGH */
case('('):
/* FALLTHROUGH */
@@ -100,22 +92,28 @@ int
mdoc_isdelim(const char *p)
{
- if (0 == *p)
- return(0);
- if (0 != *(p + 1))
+ if ('\0' == p[0])
return(0);
- return(mdoc_iscdelim(*p));
+ if ('\0' == p[1])
+ return(mdoc_iscdelim(p[0]));
+
+ /*
+ * XXX; account for groff bubu where the \*(Ba reserved string
+ * is treated in exactly the same way as the vertical bar. This
+ * is the only function that checks for this.
+ */
+ return(0 == strcmp(p, "\\*(Ba"));
}
enum mdoc_sec
-mdoc_atosec(const char *p)
+mdoc_str2sec(const char *p)
{
int i;
- for (i = 0; i < SECNAME_MAX; i++)
- if (0 == strcmp(p, secnames[i].name))
- return(secnames[i].sec);
+ for (i = 0; i < (int)SEC__MAX; i++)
+ if (secnames[i] && 0 == strcmp(p, secnames[i]))
+ return((enum mdoc_sec)i);
return(SEC_CUSTOM);
}
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 2047066b6a8..13d603f5f9f 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.76 2010/05/08 02:10:09 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.77 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -18,6 +18,7 @@
#include <assert.h>
#include <ctype.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -54,6 +55,7 @@ static int arg_hasattr(int, const struct mdoc_node *);
static int arg_getattrs(const int *, int *, size_t,
const struct mdoc_node *);
static int arg_getattr(int, const struct mdoc_node *);
+static int arg_disptype(const struct mdoc_node *);
static int arg_listtype(const struct mdoc_node *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
@@ -477,6 +479,35 @@ a2width(const struct mdoc_argv *arg, int pos)
static int
+arg_disptype(const struct mdoc_node *n)
+{
+ int i, len;
+
+ assert(MDOC_BLOCK == n->type);
+
+ len = (int)(n->args ? n->args->argc : 0);
+
+ for (i = 0; i < len; i++)
+ switch (n->args->argv[i].arg) {
+ case (MDOC_Centred):
+ /* FALLTHROUGH */
+ case (MDOC_Ragged):
+ /* FALLTHROUGH */
+ case (MDOC_Filled):
+ /* FALLTHROUGH */
+ case (MDOC_Unfilled):
+ /* FALLTHROUGH */
+ case (MDOC_Literal):
+ return(n->args->argv[i].arg);
+ default:
+ break;
+ }
+
+ return(-1);
+}
+
+
+static int
arg_listtype(const struct mdoc_node *n)
{
int i, len;
@@ -1050,7 +1081,7 @@ static int
termp_nm_pre(DECL_ARGS)
{
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
term_newln(p);
term_fontpush(p, TERMFONT_BOLD);
@@ -1125,7 +1156,7 @@ termp_an_post(DECL_ARGS)
return;
}
- if (arg_getattr(MDOC_Split, n) > -1) {
+ if (arg_hasattr(MDOC_Split, n)) {
p->flags &= ~TERMP_NOSPLIT;
p->flags |= TERMP_SPLIT;
} else {
@@ -1349,7 +1380,7 @@ static void
termp_fd_post(DECL_ARGS)
{
- if (n->sec != SEC_SYNOPSIS)
+ if (n->sec != SEC_SYNOPSIS || ! (MDOC_LINE & n->flags))
return;
term_newln(p);
@@ -1436,7 +1467,7 @@ static void
termp_lb_post(DECL_ARGS)
{
- if (SEC_LIBRARY == n->sec)
+ if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags)
term_newln(p);
}
@@ -1505,7 +1536,7 @@ static int
termp_ft_pre(DECL_ARGS)
{
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
if (n->prev && MDOC_Fo == n->prev->tok)
term_vspace(p);
@@ -1519,7 +1550,7 @@ static void
termp_ft_post(DECL_ARGS)
{
- if (SEC_SYNOPSIS == n->sec)
+ if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags)
term_newln(p);
}
@@ -1560,7 +1591,7 @@ static void
termp_fn_post(DECL_ARGS)
{
- if (n->sec == SEC_SYNOPSIS && n->next)
+ if (n->sec == SEC_SYNOPSIS && n->next && MDOC_LINE & n->flags)
term_vspace(p);
}
@@ -1598,6 +1629,7 @@ termp_bd_pre(DECL_ARGS)
{
size_t tabwidth;
int i, type;
+ size_t rm, rmax;
const struct mdoc_node *nn;
if (MDOC_BLOCK == n->type) {
@@ -1608,26 +1640,11 @@ termp_bd_pre(DECL_ARGS)
nn = n->parent;
- for (type = -1, i = 0; i < (int)nn->args->argc; i++) {
- switch (nn->args->argv[i].arg) {
- case (MDOC_Centred):
- /* FALLTHROUGH */
- case (MDOC_Ragged):
- /* FALLTHROUGH */
- case (MDOC_Filled):
- /* FALLTHROUGH */
- case (MDOC_Unfilled):
- /* FALLTHROUGH */
- case (MDOC_Literal):
- type = nn->args->argv[i].arg;
- break;
- case (MDOC_Offset):
- p->offset += a2offs(&nn->args->argv[i]);
- break;
- default:
- break;
- }
- }
+ type = arg_disptype(nn);
+ assert(-1 != type);
+
+ if (-1 != (i = arg_getattr(MDOC_Offset, nn)))
+ p->offset += a2offs(&nn->args->argv[i]);
/*
* If -ragged or -filled are specified, the block does nothing
@@ -1637,12 +1654,15 @@ termp_bd_pre(DECL_ARGS)
* lines are allowed.
*/
- assert(type > -1);
if (MDOC_Literal != type && MDOC_Unfilled != type)
return(1);
tabwidth = p->tabwidth;
p->tabwidth = 8;
+ rm = p->rmargin;
+ rmax = p->maxrmargin;
+ p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
+
for (nn = n->child; nn; nn = nn->next) {
p->flags |= TERMP_NOSPACE;
print_mdoc_node(p, pair, m, nn);
@@ -1653,6 +1673,8 @@ termp_bd_pre(DECL_ARGS)
}
p->tabwidth = tabwidth;
+ p->rmargin = rm;
+ p->maxrmargin = rmax;
return(0);
}
@@ -1661,11 +1683,26 @@ termp_bd_pre(DECL_ARGS)
static void
termp_bd_post(DECL_ARGS)
{
+ int type;
+ size_t rm, rmax;
if (MDOC_BODY != n->type)
return;
+
+ type = arg_disptype(n->parent);
+ assert(-1 != type);
+
+ rm = p->rmargin;
+ rmax = p->maxrmargin;
+
+ if (MDOC_Literal == type || MDOC_Unfilled == type)
+ p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
+
p->flags |= TERMP_NOSPACE;
term_newln(p);
+
+ p->rmargin = rm;
+ p->maxrmargin = rmax;
}
@@ -1855,7 +1892,7 @@ termp_in_post(DECL_ARGS)
term_word(p, ">");
term_fontpop(p);
- if (SEC_SYNOPSIS != n->sec)
+ if (SEC_SYNOPSIS != n->sec && ! (MDOC_LINE & n->flags))
return;
term_newln(p);
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 2ac6cc82fff..4426ffb3839 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.50 2010/05/14 01:54:37 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.51 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1284,21 +1284,24 @@ post_sh_head(POST_ARGS)
return(mdoc_nerr(mdoc, n, ETOOLONG));
}
- sec = mdoc_atosec(buf);
+ sec = mdoc_str2sec(buf);
/*
* Check: NAME should always be first, CUSTOM has no roles,
* non-CUSTOM has a conventional order to be followed.
*/
- if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed &&
- ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME))
- return(0);
+ if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed)
+ if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECNAME))
+ return(0);
+
if (SEC_CUSTOM == sec)
return(1);
+
if (sec == mdoc->lastnamed)
if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECREP))
return(0);
+
if (sec < mdoc->lastnamed)
if ( ! mdoc_nwarn(mdoc, mdoc->last, ESECOOO))
return(0);
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index 2df9218a163..f9eff2c0b6b 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.16 2010/04/23 00:23:47 schwarze Exp $ */
+/* $Id: term.h,v 1.17 2010/05/14 14:47:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -29,6 +29,8 @@ enum termfont {
TERMFONT_UNDER
};
+#define TERM_MAXMARGIN 100000 /* FIXME */
+
struct termp {
size_t rmargin; /* Current right margin. */
size_t maxrmargin; /* Max right margin. */