summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/Makefile4
-rw-r--r--regress/usr.bin/mandoc/man/IP/Makefile6
-rw-r--r--regress/usr.bin/mandoc/man/IP/literal.in26
-rw-r--r--regress/usr.bin/mandoc/man/IP/literal.out_ascii25
-rw-r--r--regress/usr.bin/mandoc/man/IP/manyargs.in45
-rw-r--r--regress/usr.bin/mandoc/man/IP/manyargs.out_ascii39
-rw-r--r--regress/usr.bin/mandoc/man/IP/width.in53
-rw-r--r--regress/usr.bin/mandoc/man/IP/width.out_ascii50
-rw-r--r--regress/usr.bin/mandoc/man/Makefile7
-rw-r--r--regress/usr.bin/mandoc/man/Makefile.inc3
-rw-r--r--regress/usr.bin/mandoc/man/nf/Makefile6
-rw-r--r--regress/usr.bin/mandoc/man/nf/indent.in17
-rw-r--r--regress/usr.bin/mandoc/man/nf/indent.out_ascii20
-rw-r--r--usr.bin/mandoc/man_html.c32
-rw-r--r--usr.bin/mandoc/man_term.c42
15 files changed, 334 insertions, 41 deletions
diff --git a/regress/usr.bin/mandoc/Makefile b/regress/usr.bin/mandoc/Makefile
index ac1a1af100b..335a639eda1 100644
--- a/regress/usr.bin/mandoc/Makefile
+++ b/regress/usr.bin/mandoc/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.4 2010/06/27 19:56:11 phessler Exp $
+# $OpenBSD: Makefile,v 1.5 2011/01/04 01:15:39 schwarze Exp $
-SUBDIR+= mdoc char roff
+SUBDIR+= roff char mdoc man
groff groff-clean: _SUBDIRUSE
depend: groff
diff --git a/regress/usr.bin/mandoc/man/IP/Makefile b/regress/usr.bin/mandoc/man/IP/Makefile
new file mode 100644
index 00000000000..1388679c2fd
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.2 2011/01/04 01:15:39 schwarze Exp $
+
+REGRESS_TARGETS=literal width manyargs
+GROFF_TARGETS=literal width manyargs
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/IP/literal.in b/regress/usr.bin/mandoc/man/IP/literal.in
new file mode 100644
index 00000000000..1774c7098eb
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/literal.in
@@ -0,0 +1,26 @@
+.TH TP-LITERAL 1
+.SH NAME
+TP-literal \- indented paragraphs in literal context
+.SH DESCRIPTION
+regular
+text
+.TP 10n
+tag
+indented
+text
+.PP
+regular
+text
+.nf
+literal
+text
+.TP 10n
+tag
+indented
+text
+.PP
+literal
+text
+.fi
+regular
+text
diff --git a/regress/usr.bin/mandoc/man/IP/literal.out_ascii b/regress/usr.bin/mandoc/man/IP/literal.out_ascii
new file mode 100644
index 00000000000..29c09bf0d51
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/literal.out_ascii
@@ -0,0 +1,25 @@
+TP-LITERAL(1) TP-LITERAL(1)
+
+
+
+NNAAMMEE
+ TP-literal - indented paragraphs in literal context
+
+DDEESSCCRRIIPPTTIIOONN
+ regular text
+
+ tag indented text
+
+ regular text
+ literal
+ text
+
+ tag indented
+ text
+
+ literal
+ text
+ regular text
+
+
+
diff --git a/regress/usr.bin/mandoc/man/IP/manyargs.in b/regress/usr.bin/mandoc/man/IP/manyargs.in
new file mode 100644
index 00000000000..6b6055c97f8
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/manyargs.in
@@ -0,0 +1,45 @@
+.TH TP-MANYARGS 1
+.SH NAME
+TP-manyargs \- too many header args for indented blocks
+.SH DESCRIPTION
+regular
+text
+.TP 10n
+tag1
+indented
+text
+.PP
+regular
+text
+.TP 10n tag1
+tag2
+indented
+text
+.PP
+regular
+text
+.TP 10n tag2 tag1
+tag3
+indented
+text
+.nf
+literal
+text
+.TP 10n
+tag1
+indented
+text
+.PP
+literal
+text
+.TP 10n tag1
+tag2
+indented
+text
+.PP
+literal
+text
+.TP 10n tag2 tag1
+tag3
+indented
+text
diff --git a/regress/usr.bin/mandoc/man/IP/manyargs.out_ascii b/regress/usr.bin/mandoc/man/IP/manyargs.out_ascii
new file mode 100644
index 00000000000..658f29340b4
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/manyargs.out_ascii
@@ -0,0 +1,39 @@
+TP-MANYARGS(1) TP-MANYARGS(1)
+
+
+
+NNAAMMEE
+ TP-manyargs - too many header args for indented blocks
+
+DDEESSCCRRIIPPTTIIOONN
+ regular text
+
+ tag1 indented text
+
+ regular text
+
+ tag2 indented text
+
+ regular text
+
+ tag3 indented text
+ literal
+ text
+
+ tag1 indented
+ text
+
+ literal
+ text
+
+ tag2 indented
+ text
+
+ literal
+ text
+
+ tag3 indented
+ text
+
+
+
diff --git a/regress/usr.bin/mandoc/man/IP/width.in b/regress/usr.bin/mandoc/man/IP/width.in
new file mode 100644
index 00000000000..47683a351d5
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/width.in
@@ -0,0 +1,53 @@
+.TH TP-WIDTH 1
+.SH NAME
+TP-width \- indentation width of indented paragraphs
+.SH DESCRIPTION
+Regular mode:
+.TP 1n
+tag
+indented
+.br
+text
+.TP 2n
+tag
+indented
+.br
+text
+.TP 3n
+tag
+indented
+.br
+text
+.TP 4n
+tag
+indented
+.br
+text
+.TP 5n
+tag
+indented
+.br
+text
+.PP
+Literal mode:
+.nf
+.TP 1n
+tag
+indented
+text
+.TP 2n
+tag
+indented
+text
+.TP 3n
+tag
+indented
+text
+.TP 4n
+tag
+indented
+text
+.TP 5n
+tag
+indented
+text
diff --git a/regress/usr.bin/mandoc/man/IP/width.out_ascii b/regress/usr.bin/mandoc/man/IP/width.out_ascii
new file mode 100644
index 00000000000..1b611d2866d
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/width.out_ascii
@@ -0,0 +1,50 @@
+TP-WIDTH(1) TP-WIDTH(1)
+
+
+
+NNAAMMEE
+ TP-width - indentation width of indented paragraphs
+
+DDEESSCCRRIIPPTTIIOONN
+ Regular mode:
+
+ tag
+ indented
+ text
+
+ tag
+ indented
+ text
+
+ tag
+ indented
+ text
+
+ tag indented
+ text
+
+ tag indented
+ text
+
+ Literal mode:
+
+ tag
+ indented
+ text
+
+ tag
+ indented
+ text
+
+ tag
+ indented
+ text
+
+ tag indented
+ text
+
+ tag indented
+ text
+
+
+
diff --git a/regress/usr.bin/mandoc/man/Makefile b/regress/usr.bin/mandoc/man/Makefile
new file mode 100644
index 00000000000..c4588c6b5bf
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/Makefile
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile,v 1.1 2011/01/04 01:15:39 schwarze Exp $
+
+SUBDIR= nf IP TP
+
+groff groff-clean: _SUBDIRUSE
+
+.include <bsd.subdir.mk>
diff --git a/regress/usr.bin/mandoc/man/Makefile.inc b/regress/usr.bin/mandoc/man/Makefile.inc
new file mode 100644
index 00000000000..cdd21ca1743
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/Makefile.inc
@@ -0,0 +1,3 @@
+# $OpenBSD: Makefile.inc,v 1.1 2011/01/04 01:15:39 schwarze Exp $
+
+.include "../Makefile.inc"
diff --git a/regress/usr.bin/mandoc/man/nf/Makefile b/regress/usr.bin/mandoc/man/nf/Makefile
new file mode 100644
index 00000000000..225c2b7b5dc
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/nf/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2011/01/04 01:15:39 schwarze Exp $
+
+REGRESS_TARGETS=indent
+GROFF_TARGETS=indent
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/nf/indent.in b/regress/usr.bin/mandoc/man/nf/indent.in
new file mode 100644
index 00000000000..885b391dece
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/nf/indent.in
@@ -0,0 +1,17 @@
+.TH NF-INDENT 1
+.SH NAME
+nf-indent \- indentation of literal blocks
+.SH DESCRIPTION
+Here comes
+an indented block:
+.nf
+oneword
+two words
+and three words
+This is a very long line; because it is indented, it is a bit too long to fit.
+blank line:
+
+end of literal
+.fi
+He is some more
+regular text.
diff --git a/regress/usr.bin/mandoc/man/nf/indent.out_ascii b/regress/usr.bin/mandoc/man/nf/indent.out_ascii
new file mode 100644
index 00000000000..72c05c72758
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/nf/indent.out_ascii
@@ -0,0 +1,20 @@
+NF-INDENT(1) NF-INDENT(1)
+
+
+
+NNAAMMEE
+ nf-indent - indentation of literal blocks
+
+DDEESSCCRRIIPPTTIIOONN
+ Here comes an indented block:
+ oneword
+ two words
+ and three words
+ This is a very long line; because it is indented, it is a bit too long to fit.
+ blank line:
+
+ end of literal
+ He is some more regular text.
+
+
+
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index 345217649e2..919bda0d2a4 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.27 2010/12/25 13:23:03 schwarze Exp $ */
+/* $Id: man_html.c,v 1.28 2011/01/04 01:15:39 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -522,14 +522,11 @@ man_IP_pre(MAN_ARGS)
SCALE_HS_INIT(&su, INDENT);
width = 0;
- /* Width is the last token. */
+ /* Width is the second token. */
if (MAN_IP == n->tok && NULL != nn)
- if (NULL != (nn = nn->next)) {
- for ( ; nn->next; nn = nn->next)
- /* Do nothing. */ ;
+ if (NULL != (nn = nn->next))
width = a2width(nn, &su);
- }
/* Width is the first token. */
@@ -555,26 +552,17 @@ man_IP_pre(MAN_ARGS)
print_otag(h, TAG_TD, 0, NULL);
- /*
- * Without a length string, we can print all of our children.
- */
+ /* For IP, only print the first header element. */
- if ( ! width)
- return(1);
+ if (MAN_IP == n->tok && n->child)
+ print_man_node(m, n->child, mh, h);
- /*
- * When a length has been specified, we need to carefully print
- * our child context: IP gets all children printed but the last
- * (the width), while TP gets all children printed but the first
- * (the width).
- */
+ /* For TP, only print next-line header elements. */
- if (MAN_IP == n->tok)
- for (nn = n->child; nn->next; nn = nn->next)
- print_man_node(m, nn, mh, h);
if (MAN_TP == n->tok)
- for (nn = n->child->next; nn; nn = nn->next)
- print_man_node(m, nn, mh, h);
+ for (nn = n->child; nn; nn = nn->next)
+ if (nn->line > n->line)
+ print_man_node(m, nn, mh, h);
return(0);
}
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 195ca7a3320..49bac5b5943 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,7 +1,7 @@
-/* $Id: man_term.c,v 1.56 2010/12/19 07:53:12 schwarze Exp $ */
+/* $Id: man_term.c,v 1.57 2011/01/04 01:15:39 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -514,7 +514,7 @@ pre_IP(DECL_ARGS)
{
const struct man_node *nn;
size_t len;
- int ival;
+ int savelit, ival;
switch (n->type) {
case (MAN_BODY):
@@ -534,15 +534,11 @@ pre_IP(DECL_ARGS)
len = mt->lmargin;
ival = -1;
- /* Calculate offset. */
-
+ /* Calculate the offset from the optional second argument. */
if (NULL != (nn = n->parent->head->child))
- if (NULL != (nn = nn->next)) {
- for ( ; nn->next; nn = nn->next)
- /* Do nothing. */ ;
+ if (NULL != (nn = nn->next))
if ((ival = a2width(p, nn->string)) >= 0)
len = (size_t)ival;
- }
switch (n->type) {
case (MAN_HEAD):
@@ -558,9 +554,15 @@ pre_IP(DECL_ARGS)
/* Set the saved left-margin. */
mt->lmargin = (size_t)ival;
- /* Don't print the length value. */
- for (nn = n->child; nn->next; nn = nn->next)
- print_man_node(p, mt, nn, m);
+ savelit = MANT_LITERAL & mt->fl;
+ mt->fl &= ~MANT_LITERAL;
+
+ if (n->child)
+ print_man_node(p, mt, n->child, m);
+
+ if (savelit)
+ mt->fl |= MANT_LITERAL;
+
return(0);
case (MAN_BODY):
p->offset = mt->offset + len;
@@ -586,7 +588,7 @@ post_IP(DECL_ARGS)
p->rmargin = p->maxrmargin;
break;
case (MAN_BODY):
- term_flushln(p);
+ term_newln(p);
p->flags &= ~TERMP_NOLPAD;
break;
default:
@@ -601,12 +603,11 @@ pre_TP(DECL_ARGS)
{
const struct man_node *nn;
size_t len;
- int ival;
+ int savelit, ival;
switch (n->type) {
case (MAN_HEAD):
p->flags |= TERMP_NOBREAK;
- p->flags |= TERMP_TWOSPACE;
break;
case (MAN_BODY):
p->flags |= TERMP_NOLPAD;
@@ -641,11 +642,17 @@ pre_TP(DECL_ARGS)
p->offset = mt->offset;
p->rmargin = mt->offset + len;
+ savelit = MANT_LITERAL & mt->fl;
+ mt->fl &= ~MANT_LITERAL;
+
/* Don't print same-line elements. */
- for (nn = n->child; nn; nn = nn->next)
+ for (nn = n->child; nn; nn = nn->next)
if (nn->line > n->line)
print_man_node(p, mt, nn, m);
+ if (savelit)
+ mt->fl |= MANT_LITERAL;
+
if (ival >= 0)
mt->lmargin = (size_t)ival;
@@ -675,7 +682,7 @@ post_TP(DECL_ARGS)
p->rmargin = p->maxrmargin;
break;
case (MAN_BODY):
- term_flushln(p);
+ term_newln(p);
p->flags &= ~TERMP_NOLPAD;
break;
default:
@@ -877,6 +884,7 @@ print_man_node(DECL_ARGS)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
term_flushln(p);
+ p->flags &= ~TERMP_NOLPAD;
p->rmargin = rm;
p->maxrmargin = rmax;
}