From fbc87aa03d8f797ab884fc9f06443bd748a82ca1 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 10 Aug 2018 04:41:25 +0000 Subject: Implement the roff(7) .nop (no operation) request. Examples of manual pages (ab)using it include groff(7), chem(1), groff_mom(7), and groff_hdtbl(7). --- TODO | 5 +---- roff.7 | 15 +++++++++------ roff.c | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 6df63ea3..ef213c6a 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.258 2018/08/06 14:16:30 schwarze Exp $ +* $Id: TODO,v 1.259 2018/08/10 04:41:25 schwarze Exp $ ************************************************************************ Many issues are annotated for difficulty as follows: @@ -38,9 +38,6 @@ are mere guesses, and some may be wrong. --- missing roff features ---------------------------------------------- -- .nop prints its arguments as text, - see groff(7) for an example - - .ft CB selects constant-width bold font see groff_out(7) for examples diff --git a/roff.7 b/roff.7 index 8cb922c7..f079c28c 100644 --- a/roff.7 +++ b/roff.7 @@ -1,4 +1,4 @@ -.\" $Id: roff.7,v 1.96 2018/04/10 00:52:30 schwarze Exp $ +.\" $Id: roff.7,v 1.97 2018/08/10 04:41:25 schwarze Exp $ .\" .\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons .\" Copyright (c) 2010-2018 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: April 10 2018 $ +.Dd $Mdocdate: August 10 2018 $ .Dt ROFF 7 .Os .Sh NAME @@ -206,7 +206,7 @@ Unescaped trailing spaces are stripped from text line input unless in a literal context. In general, trailing whitespace on any input line is discouraged for reasons of portability. -In the rare case that a blank character is needed at the end of an +In the rare case that a space character is needed at the end of an input line, it may be forced by .Sq \e\ \e& . .Pp @@ -665,7 +665,7 @@ produces .Pp in the input stream, and thus in the output: \fI\^XtFree\^\fP. Each occurrence of \e\e$* is replaced with all the arguments, -joined together with single blank characters. +joined together with single space characters. .Pp Since macros and user-defined strings share a common string table, defining a macro @@ -1346,8 +1346,11 @@ Currently unsupported. Temporarily turn off line numbering. Currently unsupported. .It Ic \&nop Ar body -Execute the rest of the input line as a request or macro line. -Currently unsupported. +Execute the rest of the input line as a request, macro, or text line, +skipping the +.Ic \&nop +request and any space characters immediately following it. +This is mostly used to indent text lines inside macro definitions. .It Ic \&nr Ar register Oo Cm + Ns | Ns Cm - Oc Ns Ar expression Op Ar stepsize Define or change a register. A register is an arbitrary string value that defines some sort of state, diff --git a/roff.c b/roff.c index 86e145e3..fe703f5a 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.329 2018/08/01 15:40:17 schwarze Exp $ */ +/* $Id: roff.c,v 1.330 2018/08/10 04:41:25 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze @@ -197,6 +197,7 @@ static enum rofferr roff_line_ignore(ROFF_ARGS); static void roff_man_alloc1(struct roff_man *); static void roff_man_free1(struct roff_man *); static enum rofferr roff_manyarg(ROFF_ARGS); +static enum rofferr roff_nop(ROFF_ARGS); static enum rofferr roff_nr(ROFF_ARGS); static enum rofferr roff_onearg(ROFF_ARGS); static enum roff_tok roff_parse(struct roff *, char *, int *, @@ -490,7 +491,7 @@ static struct roffmac roffs[TOKEN_NONE] = { { roff_line_ignore, NULL, NULL, 0 }, /* nhychar */ { roff_unsupp, NULL, NULL, 0 }, /* nm */ { roff_unsupp, NULL, NULL, 0 }, /* nn */ - { roff_unsupp, NULL, NULL, 0 }, /* nop */ + { roff_nop, NULL, NULL, 0 }, /* nop */ { roff_nr, NULL, NULL, 0 }, /* nr */ { roff_unsupp, NULL, NULL, 0 }, /* nrf */ { roff_line_ignore, NULL, NULL, 0 }, /* nroff */ @@ -3160,6 +3161,15 @@ roff_eo(ROFF_ARGS) return ROFF_IGN; } +static enum rofferr +roff_nop(ROFF_ARGS) +{ + while (buf->buf[pos] == ' ') + pos++; + *offs = pos; + return ROFF_RERUN; +} + static enum rofferr roff_tr(ROFF_ARGS) { -- cgit v1.2.3-56-ge451