summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-12-02 10:07:17 +0000
committerschwarze <schwarze@openbsd.org>2014-12-02 10:07:17 +0000
commit64c3401c9d7b678fca49a2777f3b21e6ef0c011c (patch)
treeec9c83f9c5154d0697d3c72c87996fcf8bf076f4
parentmacro cleanup; kaspars at bankovskis dot net (diff)
downloadwireguard-openbsd-64c3401c9d7b678fca49a2777f3b21e6ef0c011c.tar.xz
wireguard-openbsd-64c3401c9d7b678fca49a2777f3b21e6ef0c011c.zip
Fix the implementation and documentation of \c (continue text input line).
In particular, make it work in no-fill mode, too. Reminded by Carsten dot Kunze at arcor dot de (Heirloom roff).
-rw-r--r--regress/usr.bin/mandoc/roff/esc/Makefile6
-rw-r--r--regress/usr.bin/mandoc/roff/esc/c.in6
-rw-r--r--regress/usr.bin/mandoc/roff/esc/c.out_ascii4
-rw-r--r--regress/usr.bin/mandoc/roff/esc/c_man.in12
-rw-r--r--regress/usr.bin/mandoc/roff/esc/c_man.out_ascii15
-rw-r--r--share/man/man7/roff.710
-rw-r--r--usr.bin/mandoc/html.c5
-rw-r--r--usr.bin/mandoc/html.h3
-rw-r--r--usr.bin/mandoc/man_html.c15
-rw-r--r--usr.bin/mandoc/man_term.c9
-rw-r--r--usr.bin/mandoc/mdoc_html.c5
-rw-r--r--usr.bin/mandoc/mdoc_term.c5
-rw-r--r--usr.bin/mandoc/term.c6
-rw-r--r--usr.bin/mandoc/term.h3
14 files changed, 69 insertions, 35 deletions
diff --git a/regress/usr.bin/mandoc/roff/esc/Makefile b/regress/usr.bin/mandoc/roff/esc/Makefile
index ca934316948..1d63a92f488 100644
--- a/regress/usr.bin/mandoc/roff/esc/Makefile
+++ b/regress/usr.bin/mandoc/roff/esc/Makefile
@@ -1,10 +1,10 @@
-# $OpenBSD: Makefile,v 1.6 2014/08/14 01:58:51 schwarze Exp $
+# $OpenBSD: Makefile,v 1.7 2014/12/02 10:07:17 schwarze Exp $
-REGRESS_TARGETS = one two multi B c f h w z ignore
+REGRESS_TARGETS = one two multi B c c_man f h w z ignore
LINT_TARGETS = B h w
# Postprocessing to remove "character backspace" sequences
-# unless they are foolowed by the same character again.
+# unless they are followed by the same character again.
# This removes underlining as well, so we mustn't use it.
# Cannot use /g because matches progress backwards.
diff --git a/regress/usr.bin/mandoc/roff/esc/c.in b/regress/usr.bin/mandoc/roff/esc/c.in
index be95f2bcd03..c3b7a912c51 100644
--- a/regress/usr.bin/mandoc/roff/esc/c.in
+++ b/regress/usr.bin/mandoc/roff/esc/c.in
@@ -1,4 +1,4 @@
-.Dd May 28, 2012
+.Dd December 2, 2014
.Dt ESC-C 1
.Os OpenBSD
.Sh NAME
@@ -11,3 +11,7 @@ and
.Dq word :
one\c
word
+.Bd -literal
+one\c
+word
+.Ed
diff --git a/regress/usr.bin/mandoc/roff/esc/c.out_ascii b/regress/usr.bin/mandoc/roff/esc/c.out_ascii
index c686cf32cab..5ddc8443235 100644
--- a/regress/usr.bin/mandoc/roff/esc/c.out_ascii
+++ b/regress/usr.bin/mandoc/roff/esc/c.out_ascii
@@ -6,4 +6,6 @@ NNAAMMEE
DDEESSCCRRIIPPTTIIOONN
No space between ``one'' and ``word'': oneword
-OpenBSD May 28, 2012 OpenBSD
+ oneword
+
+OpenBSD December 2, 2014 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/esc/c_man.in b/regress/usr.bin/mandoc/roff/esc/c_man.in
new file mode 100644
index 00000000000..c18fad10c99
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/esc/c_man.in
@@ -0,0 +1,12 @@
+.TH ESC-C_MAN 1 "December 2, 2014" OpenBSD
+.SH NAME
+esc-c_man \- the roff escape c sequence: remove trailing space
+.SH DESCRIPTION
+No space between "one" and "word":
+one\c
+word
+.nf
+one\c
+word
+.fi
+final text
diff --git a/regress/usr.bin/mandoc/roff/esc/c_man.out_ascii b/regress/usr.bin/mandoc/roff/esc/c_man.out_ascii
new file mode 100644
index 00000000000..d00b1b48d21
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/esc/c_man.out_ascii
@@ -0,0 +1,15 @@
+ESC-C_MAN(1) General Commands Manual ESC-C_MAN(1)
+
+
+
+NNAAMMEE
+ esc-c_man - the roff escape c sequence: remove trailing space
+
+DDEESSCCRRIIPPTTIIOONN
+ No space between "one" and "word": oneword
+ oneword
+ final text
+
+
+
+OpenBSD December 2, 2014 ESC-C_MAN(1)
diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7
index 6d62b085cec..9222fe4bddb 100644
--- a/share/man/man7/roff.7
+++ b/share/man/man7/roff.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: roff.7,v 1.38 2014/11/19 01:20:18 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.39 2014/12/02 10:07:17 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 19 2014 $
+.Dd $Mdocdate: December 2 2014 $
.Dt ROFF 7
.Os
.Sh NAME
@@ -1194,8 +1194,10 @@ Bracket building function; ignored by
.Sx Special Characters
with names of arbitrary length.
.Ss \ec
-Interrupt text processing to insert requests or macros; ignored by
-.Xr mandoc 1 .
+When encountered at the end of an input text line,
+the next input text line is considered to continue that line,
+even if there are request or macro lines in between.
+No whitespace is inserted.
.Ss \eD\(aq Ns Ar string Ns \(aq
Draw graphics function; ignored by
.Xr mandoc 1 .
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index 14ead7751e9..a4202939bc0 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.52 2014/12/01 04:32:34 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.53 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -560,8 +560,9 @@ print_text(struct html *h, const char *word)
if ( ! print_encode(h, word, 0)) {
if ( ! (h->flags & HTML_NONOSPACE))
h->flags &= ~HTML_NOSPACE;
+ h->flags &= ~HTML_NONEWLINE;
} else
- h->flags |= HTML_NOSPACE;
+ h->flags |= HTML_NOSPACE | HTML_NONEWLINE;
if (h->metaf) {
print_tagq(h, h->metaf);
diff --git a/usr.bin/mandoc/html.h b/usr.bin/mandoc/html.h
index 90a9da18de3..3a340fb805f 100644
--- a/usr.bin/mandoc/html.h
+++ b/usr.bin/mandoc/html.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.h,v 1.31 2014/12/01 08:05:02 schwarze Exp $ */
+/* $OpenBSD: html.h,v 1.32 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -126,6 +126,7 @@ struct html {
#define HTML_SKIPCHAR (1 << 6) /* skip the next character */
#define HTML_NOSPLIT (1 << 7) /* do not break line before .An */
#define HTML_SPLIT (1 << 8) /* break line before .An */
+#define HTML_NONEWLINE (1 << 9) /* No line break in nofill mode. */
struct tagq tags; /* stack of open tags */
struct rofftbl tbl; /* current table */
struct tag *tblt; /* current open table scope */
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index bba6f68ebc4..cde34a999c3 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_html.c,v 1.58 2014/12/01 08:05:02 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.59 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -210,21 +210,14 @@ print_man_node(MAN_ARGS)
man_root_pre(man, n, mh, h);
break;
case MAN_TEXT:
- /*
- * If we have a blank line, output a vertical space.
- * If we have a space as the first character, break
- * before printing the line's data.
- */
if ('\0' == *n->string) {
print_paragraph(h);
return;
}
-
- if (' ' == *n->string && MAN_LINE & n->flags)
+ if (n->flags & MAN_LINE && (*n->string == ' ' ||
+ (n->prev != NULL && mh->fl & MANH_LITERAL &&
+ ! (h->flags & HTML_NONEWLINE))))
print_otag(h, TAG_BR, 0, NULL);
- else if (MANH_LITERAL & mh->fl && n->prev)
- print_otag(h, TAG_BR, 0, NULL);
-
print_text(h, n->string);
return;
case MAN_EQN:
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 19f17b975c1..8b7ea97cb1d 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.109 2014/11/21 01:52:44 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.110 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1016,13 +1016,14 @@ out:
* -man doesn't have nested macros, we don't need to be
* more specific than this.
*/
- if (MANT_LITERAL & mt->fl && ! (TERMP_NOBREAK & p->flags) &&
- (NULL == n->next || MAN_LINE & n->next->flags)) {
+ if (mt->fl & MANT_LITERAL &&
+ ! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) &&
+ (n->next == NULL || n->next->flags & MAN_LINE)) {
rm = p->rmargin;
rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
- if (NULL != n->string && '\0' != *n->string)
+ if (n->string != NULL && *n->string != '\0')
term_flushln(p);
else
term_newln(p);
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 037c01d0f69..1b95dc47e92 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_html.c,v 1.90 2014/12/01 08:05:02 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.91 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1199,7 +1199,8 @@ mdoc_bd_pre(MDOC_ARGS)
default:
break;
}
- if (nn->next && nn->next->line == nn->line)
+ if (h->flags & HTML_NONEWLINE ||
+ (nn->next && ! (nn->next->flags & MDOC_LINE)))
continue;
else if (nn->next)
print_text(h, "\n");
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 57ac0f5522f..29f604d89f5 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.197 2014/11/30 05:28:00 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.198 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1630,7 +1630,8 @@ termp_bd_pre(DECL_ARGS)
default:
break;
}
- if (nn->next && nn->next->line == nn->line)
+ if (p->flags & TERMP_NONEWLINE ||
+ (nn->next && ! (nn->next->flags & MDOC_LINE)))
continue;
term_flushln(p);
p->flags |= TERMP_NOSPACE;
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 39d5e8ebd62..5172d4b84ca 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.96 2014/11/21 01:52:45 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.97 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -415,7 +415,7 @@ term_word(struct termp *p, const char *word)
else
p->flags |= TERMP_NOSPACE;
- p->flags &= ~TERMP_SENTENCE;
+ p->flags &= ~(TERMP_SENTENCE | TERMP_NONEWLINE);
while ('\0' != *word) {
if ('\\' != *word) {
@@ -485,7 +485,7 @@ term_word(struct termp *p, const char *word)
if (TERMP_SKIPCHAR & p->flags)
p->flags &= ~TERMP_SKIPCHAR;
else if ('\0' == *word)
- p->flags |= TERMP_NOSPACE;
+ p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE);
continue;
case ESCAPE_SKIPCHAR:
p->flags |= TERMP_SKIPCHAR;
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index add887697c3..3c09886acbe 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.h,v 1.51 2014/12/01 08:05:02 schwarze Exp $ */
+/* $OpenBSD: term.h,v 1.52 2014/12/02 10:07:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -79,6 +79,7 @@ struct termp {
#define TERMP_HANG (1 << 11) /* See term_flushln(). */
#define TERMP_NOSPLIT (1 << 12) /* Do not break line before .An. */
#define TERMP_SPLIT (1 << 13) /* Break line before .An. */
+#define TERMP_NONEWLINE (1 << 14) /* No line break in nofill mode. */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
const struct mchars *symtab; /* Character table. */