summaryrefslogtreecommitdiffstats
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-05-07 17:31:45 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-05-07 17:31:45 +0000
commitdf7add94ac0e6037b421b622febfdbe3236dad5c (patch)
treed3549eb68d21b93b68a624099f590ddb686ecfd9 /roff.c
parent412e48b8cba6db0a6b8eae7f848cfa460e0a315d (diff)
downloadmandoc-df7add94ac0e6037b421b622febfdbe3236dad5c.tar.gz
Basic implementation of the roff(7) .ta (define tab stops) request.
This is the first feature made possible by the parser reorganization. Improves the formatting of the SYNOPSIS in many Xenocara GL manuals. Also important for ports, as reported by many, including naddy@.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/roff.c b/roff.c
index 1df5929e..6c387e5e 100644
--- a/roff.c
+++ b/roff.c
@@ -181,6 +181,7 @@ static enum rofferr roff_it(ROFF_ARGS);
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_nr(ROFF_ARGS);
static enum rofferr roff_onearg(ROFF_ARGS);
static enum roff_tok roff_parse(struct roff *, char *, int *,
@@ -212,7 +213,7 @@ static enum rofferr roff_userdef(ROFF_ARGS);
const char *__roff_name[MAN_MAX + 1] = {
"br", "ft", "ll", "sp",
- NULL,
+ "ta", NULL,
"ab", "ad", "af", "aln",
"als", "am", "am1", "ami",
"ami1", "as", "as1", "asciify",
@@ -262,7 +263,7 @@ const char *__roff_name[MAN_MAX + 1] = {
"shc", "shift", "sizes", "so",
"spacewidth", "special", "spreadwarn", "ss",
"sty", "substring", "sv", "sy",
- "T&", "ta", "tc", "TE",
+ "T&", "tc", "TE",
"TH", "ti", "tkf", "tl",
"tm", "tm1", "tmc", "tr",
"track", "transchar", "trf", "trimat",
@@ -322,6 +323,7 @@ static struct roffmac roffs[TOKEN_NONE] = {
{ roff_onearg, NULL, NULL, 0 }, /* ft */
{ roff_onearg, NULL, NULL, 0 }, /* ll */
{ roff_onearg, NULL, NULL, 0 }, /* sp */
+ { roff_manyarg, NULL, NULL, 0 }, /* ta */
{ NULL, NULL, NULL, 0 }, /* ROFF_MAX */
{ roff_unsupp, NULL, NULL, 0 }, /* ab */
{ roff_line_ignore, NULL, NULL, 0 }, /* ad */
@@ -520,7 +522,6 @@ static struct roffmac roffs[TOKEN_NONE] = {
{ roff_line_ignore, NULL, NULL, 0 }, /* sv */
{ roff_insec, NULL, NULL, 0 }, /* sy */
{ roff_T_, NULL, NULL, 0 }, /* T& */
- { roff_unsupp, NULL, NULL, 0 }, /* ta */
{ roff_unsupp, NULL, NULL, 0 }, /* tc */
{ roff_TE, NULL, NULL, 0 }, /* TE */
{ roff_TH, NULL, NULL, 0 }, /* TH */
@@ -2800,6 +2801,29 @@ roff_onearg(ROFF_ARGS)
}
static enum rofferr
+roff_manyarg(ROFF_ARGS)
+{
+ struct roff_node *n;
+ char *sp, *ep;
+
+ roff_elem_alloc(r->man, ln, ppos, tok);
+ n = r->man->last;
+
+ for (sp = ep = buf->buf + pos; *sp != '\0'; sp = ep) {
+ while (*ep != '\0' && *ep != ' ')
+ ep++;
+ while (*ep == ' ')
+ *ep++ = '\0';
+ roff_word_alloc(r->man, ln, sp - buf->buf, sp);
+ }
+
+ n->flags |= NODE_LINE | NODE_VALID | NODE_ENDED;
+ r->man->last = n;
+ r->man->next = ROFF_NEXT_SIBLING;
+ return ROFF_IGN;
+}
+
+static enum rofferr
roff_br(ROFF_ARGS)
{
roff_elem_alloc(r->man, ln, ppos, ROFF_br);