From fe05b565a018bd5034ccaf1b3ea0599e89302c20 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 2 Dec 2014 10:08:06 +0000 Subject: 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). --- TODO | 7 +------ html.c | 5 +++-- html.h | 3 ++- man_html.c | 15 ++++----------- man_term.c | 9 +++++---- mdoc_html.c | 5 +++-- mdoc_term.c | 5 +++-- roff.7 | 10 ++++++---- term.c | 6 +++--- term.h | 3 ++- 10 files changed, 32 insertions(+), 36 deletions(-) diff --git a/TODO b/TODO index 98cb687e..43d0a610 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.189 2014/11/26 21:40:17 schwarze Exp $ +* $Id: TODO,v 1.190 2014/12/02 10:08:06 schwarze Exp $ ************************************************************************ Many issues are annotated for difficulty as follows: @@ -83,11 +83,6 @@ are mere guesses, and some may be wrong. found by jca@ in ratpoison(1) Sun, 30 Jun 2013 12:01:09 +0200 loc * exist ** algo ** size ** imp ** -- \c (interrupted text) should prevent the line break - even inside .Bd literal; that occurs in chat(8) - also found in cclive(1) - DocBook output - loc ** exist *** algo ** size * imp * - - \h horizontal move found in cclive(1) DocBook output Anthony J. Bentley on discuss@ Sat, 21 Sep 2013 22:29:34 -0600 diff --git a/html.c b/html.c index 000d9c8a..fe16224e 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.182 2014/12/01 04:34:06 schwarze Exp $ */ +/* $Id: html.c,v 1.183 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -562,8 +562,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/html.h b/html.h index a7ce65dd..bbf6183c 100644 --- a/html.h +++ b/html.h @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.69 2014/12/01 08:05:52 schwarze Exp $ */ +/* $Id: html.h,v 1.70 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * @@ -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/man_html.c b/man_html.c index 78228d91..e9f93e73 100644 --- a/man_html.c +++ b/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.105 2014/12/01 08:05:52 schwarze Exp $ */ +/* $Id: man_html.c,v 1.106 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -212,21 +212,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/man_term.c b/man_term.c index 2531f816..5770c596 100644 --- a/man_term.c +++ b/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.156 2014/11/21 01:52:53 schwarze Exp $ */ +/* $Id: man_term.c,v 1.157 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1018,13 +1018,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/mdoc_html.c b/mdoc_html.c index 706b0560..ca51049e 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_html.c,v 1.215 2014/12/01 08:05:52 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.216 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -1201,7 +1201,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/mdoc_term.c b/mdoc_term.c index 5caa9717..7f57aed3 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.298 2014/11/30 05:29:00 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.299 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -1632,7 +1632,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/roff.7 b/roff.7 index 6e2e8dd9..6ee29321 100644 --- a/roff.7 +++ b/roff.7 @@ -1,4 +1,4 @@ -.\" $Id: roff.7,v 1.59 2014/11/19 01:20:25 schwarze Exp $ +.\" $Id: roff.7,v 1.60 2014/12/02 10:08:06 schwarze Exp $ .\" .\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons .\" Copyright (c) 2010, 2011, 2013, 2014 Ingo Schwarze @@ -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 @@ -1196,8 +1196,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/term.c b/term.c index 5b01aa68..33f8f900 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.236 2014/11/21 01:52:53 schwarze Exp $ */ +/* $Id: term.c,v 1.237 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -417,7 +417,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) { @@ -487,7 +487,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/term.h b/term.h index e9190a2d..62c6ffe8 100644 --- a/term.h +++ b/term.h @@ -1,4 +1,4 @@ -/* $Id: term.h,v 1.107 2014/12/01 08:05:52 schwarze Exp $ */ +/* $Id: term.h,v 1.108 2014/12/02 10:08:06 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -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. */ -- cgit v1.2.3-56-ge451