summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-14 22:50:38 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-14 22:50:38 +0000
commit73f02f010c9859d465642793bb2c4dd4a9434c74 (patch)
treed749250337bc32186ade95c1d09c295cb60c90f3 /usr.bin
parent99d9184da54adc1a9f54367e817f1f6f59928e50 (diff)
Naive implementation of the roff(7) .po (page offset) request.
This clearly works when .po is called on the top level, but might not be sophisticated enough if people call .po inside indentation-changing contexts, but i haven't seen that in manual pages (yet :).
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mdoc_man.c3
-rw-r--r--usr.bin/mandoc/roff.c10
-rw-r--r--usr.bin/mandoc/roff.h4
-rw-r--r--usr.bin/mandoc/roff_html.c3
-rw-r--r--usr.bin/mandoc/roff_term.c26
-rw-r--r--usr.bin/mandoc/roff_validate.c3
6 files changed, 38 insertions, 11 deletions
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 61ca0219d5c..d89a4d65f9d 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.119 2017/06/14 13:00:13 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.120 2017/06/14 22:50:37 schwarze Exp $ */
/*
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -128,6 +128,7 @@ static const void_fp roff_manacts[ROFF_MAX] = {
pre_ft, /* ft */
pre_onearg, /* ll */
pre_onearg, /* mc */
+ pre_onearg, /* po */
pre_onearg, /* rj */
pre_sp, /* sp */
pre_ta, /* ta */
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 950d0c1435c..7193bdba615 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.183 2017/06/14 19:39:05 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.184 2017/06/14 22:50:37 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -221,8 +221,8 @@ static enum rofferr roff_userdef(ROFF_ARGS);
const char *__roff_name[MAN_MAX + 1] = {
"br", "ce", "ft", "ll",
- "mc", "rj", "sp", "ta",
- "ti", NULL,
+ "mc", "po", "rj", "sp",
+ "ta", "ti", NULL,
"ab", "ad", "af", "aln",
"als", "am", "am1", "ami",
"ami1", "as", "as1", "asciify",
@@ -263,7 +263,7 @@ const char *__roff_name[MAN_MAX + 1] = {
"open", "opena", "os", "output",
"padj", "papersize", "pc", "pev",
"pi", "PI", "pl", "pm",
- "pn", "pnr", "po", "ps",
+ "pn", "pnr", "ps",
"psbb", "pshape", "pso", "ptr",
"pvs", "rchar", "rd", "recursionlimit",
"return", "rfschar", "rhang",
@@ -333,6 +333,7 @@ static struct roffmac roffs[TOKEN_NONE] = {
{ roff_onearg, NULL, NULL, 0 }, /* ft */
{ roff_onearg, NULL, NULL, 0 }, /* ll */
{ roff_onearg, NULL, NULL, 0 }, /* mc */
+ { roff_onearg, NULL, NULL, 0 }, /* po */
{ roff_onearg, NULL, NULL, 0 }, /* rj */
{ roff_onearg, NULL, NULL, 0 }, /* sp */
{ roff_manyarg, NULL, NULL, 0 }, /* ta */
@@ -498,7 +499,6 @@ static struct roffmac roffs[TOKEN_NONE] = {
{ roff_line_ignore, NULL, NULL, 0 }, /* pm */
{ roff_line_ignore, NULL, NULL, 0 }, /* pn */
{ roff_line_ignore, NULL, NULL, 0 }, /* pnr */
- { roff_line_ignore, NULL, NULL, 0 }, /* po */
{ roff_line_ignore, NULL, NULL, 0 }, /* ps */
{ roff_unsupp, NULL, NULL, 0 }, /* psbb */
{ roff_unsupp, NULL, NULL, 0 }, /* pshape */
diff --git a/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h
index c81bec340ed..ae8b99755e4 100644
--- a/usr.bin/mandoc/roff.h
+++ b/usr.bin/mandoc/roff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.h,v 1.35 2017/06/14 13:00:13 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.36 2017/06/14 22:50:37 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,6 +77,7 @@ enum roff_tok {
ROFF_ft,
ROFF_ll,
ROFF_mc,
+ ROFF_po,
ROFF_rj,
ROFF_sp,
ROFF_ta,
@@ -245,7 +246,6 @@ enum roff_tok {
ROFF_pm,
ROFF_pn,
ROFF_pnr,
- ROFF_po,
ROFF_ps,
ROFF_psbb,
ROFF_pshape,
diff --git a/usr.bin/mandoc/roff_html.c b/usr.bin/mandoc/roff_html.c
index 91de5fc58ba..9674ba9f6cf 100644
--- a/usr.bin/mandoc/roff_html.c
+++ b/usr.bin/mandoc/roff_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_html.c,v 1.9 2017/06/14 13:00:13 schwarze Exp $ */
+/* $OpenBSD: roff_html.c,v 1.10 2017/06/14 22:50:37 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -38,6 +38,7 @@ static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
NULL, /* ft */
NULL, /* ll */
NULL, /* mc */
+ NULL, /* po */
roff_html_pre_ce, /* rj */
roff_html_pre_sp, /* sp */
NULL, /* ta */
diff --git a/usr.bin/mandoc/roff_term.c b/usr.bin/mandoc/roff_term.c
index e561b43b57c..a3d9418201b 100644
--- a/usr.bin/mandoc/roff_term.c
+++ b/usr.bin/mandoc/roff_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_term.c,v 1.12 2017/06/14 17:50:43 schwarze Exp $ */
+/* $OpenBSD: roff_term.c,v 1.13 2017/06/14 22:50:37 schwarze Exp $ */
/*
* Copyright (c) 2010, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -32,6 +32,7 @@ static void roff_term_pre_ce(ROFF_TERM_ARGS);
static void roff_term_pre_ft(ROFF_TERM_ARGS);
static void roff_term_pre_ll(ROFF_TERM_ARGS);
static void roff_term_pre_mc(ROFF_TERM_ARGS);
+static void roff_term_pre_po(ROFF_TERM_ARGS);
static void roff_term_pre_sp(ROFF_TERM_ARGS);
static void roff_term_pre_ta(ROFF_TERM_ARGS);
static void roff_term_pre_ti(ROFF_TERM_ARGS);
@@ -42,6 +43,7 @@ static const roff_term_pre_fp roff_term_pre_acts[ROFF_MAX] = {
roff_term_pre_ft, /* ft */
roff_term_pre_ll, /* ll */
roff_term_pre_mc, /* mc */
+ roff_term_pre_po, /* po */
roff_term_pre_ce, /* rj */
roff_term_pre_sp, /* sp */
roff_term_pre_ta, /* ta */
@@ -153,6 +155,28 @@ roff_term_pre_mc(ROFF_TERM_ARGS)
}
static void
+roff_term_pre_po(ROFF_TERM_ARGS)
+{
+ struct roffsu su;
+ static int po, polast;
+ int ponew;
+
+ if (n->child != NULL &&
+ a2roffsu(n->child->string, &su, SCALE_EM) != NULL) {
+ ponew = term_hen(p, &su);
+ if (*n->child->string == '+' ||
+ *n->child->string == '-')
+ ponew += po;
+ } else
+ ponew = polast;
+ polast = po;
+ po = ponew;
+
+ ponew = po - polast + (int)p->tcol->offset;
+ p->tcol->offset = ponew > 0 ? ponew : 0;
+}
+
+static void
roff_term_pre_sp(ROFF_TERM_ARGS)
{
struct roffsu su;
diff --git a/usr.bin/mandoc/roff_validate.c b/usr.bin/mandoc/roff_validate.c
index 4f1af9b3695..8a4f5ae6efc 100644
--- a/usr.bin/mandoc/roff_validate.c
+++ b/usr.bin/mandoc/roff_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_validate.c,v 1.8 2017/06/14 13:00:13 schwarze Exp $ */
+/* $OpenBSD: roff_validate.c,v 1.9 2017/06/14 22:50:37 schwarze Exp $ */
/*
* Copyright (c) 2010, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -36,6 +36,7 @@ static const roff_valid_fp roff_valids[ROFF_MAX] = {
roff_valid_ft, /* ft */
NULL, /* ll */
NULL, /* mc */
+ NULL, /* po */
NULL, /* rj */
NULL, /* sp */
NULL, /* ta */