summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-22 23:03:15 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-22 23:03:15 +0000
commit88550d3ab5f0d432b6f5577342f5907c1ab4268b (patch)
tree877044f520faded71e2748f1a9ee93810fdda3ce
parent837cbf3ed654f4488939e0fac5c03c4ad9258c36 (diff)
downloadmandoc-88550d3ab5f0d432b6f5577342f5907c1ab4268b.tar.gz
Added `in' macro support for -man -Tascii. This is not yet supported in
-Thtml (I'm surprised to note that neither is LITERAL mode).
-rw-r--r--man.711
-rw-r--r--man.c1
-rw-r--r--man.h1
-rw-r--r--man_action.c1
-rw-r--r--man_html.c1
-rw-r--r--man_macro.c1
-rw-r--r--man_term.c43
-rw-r--r--man_validate.c9
-rw-r--r--out.c1
9 files changed, 65 insertions, 4 deletions
diff --git a/man.7 b/man.7
index 3dc62e26..bf69d0bf 100644
--- a/man.7
+++ b/man.7
@@ -427,6 +427,7 @@ The syntax is as follows:
.It Sx \&br Ta 0 Ta current Ta compat
.It Sx \&fi Ta 0 Ta current Ta compat
.It Sx \&i Ta n Ta current Ta compat
+.It Sx \&in Ta 1 Ta current Ta compat
.It Sx \&na Ta 0 Ta current Ta compat
.It Sx \&nf Ta 0 Ta current Ta compat
.It Sx \&r Ta 0 Ta current Ta compat
@@ -853,6 +854,16 @@ See also
.Sx \&b ,
and
.Sx \&r .
+.Ss \&in
+Indent relative to the current indentation:
+.Pp
+.D1 Pf \. Sx \&in Op Cm width
+.Pp
+If
+.Cm width
+is signed, the new offset is relative.
+Otherwise, it is absolute.
+This value is reset upon the next paragraph, section, or sub-section.
.Ss \&na
Don't align to the right margin.
.Ss \&nf
diff --git a/man.c b/man.c
index c11068b0..228ca0e0 100644
--- a/man.c
+++ b/man.c
@@ -41,6 +41,7 @@ const char *const __man_macronames[MAN_MAX] = {
"nf", "fi", "r", "RE",
"RS", "DT", "UC", "PD",
"Sp", "Vb", "Ve", "AT",
+ "in"
};
const char * const *man_macronames = __man_macronames;
diff --git a/man.h b/man.h
index d3c80b3a..729bf6ff 100644
--- a/man.h
+++ b/man.h
@@ -56,6 +56,7 @@ enum mant {
MAN_Vb,
MAN_Ve,
MAN_AT,
+ MAN_in,
MAN_MAX
};
diff --git a/man_action.c b/man_action.c
index b388e66f..4ca0d5a9 100644
--- a/man_action.c
+++ b/man_action.c
@@ -73,6 +73,7 @@ const struct actions man_actions[MAN_MAX] = {
{ post_nf }, /* Vb */
{ post_fi }, /* Ve */
{ post_AT }, /* AT */
+ { NULL }, /* in */
};
diff --git a/man_html.c b/man_html.c
index e31ef410..335e17ba 100644
--- a/man_html.c
+++ b/man_html.c
@@ -108,6 +108,7 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_ign_pre, NULL }, /* Vb */
{ NULL, NULL }, /* Ve */
{ man_ign_pre, NULL }, /* AT */
+ { man-in_pre, NULL }, /* in */
};
diff --git a/man_macro.c b/man_macro.c
index abac5f84..a4bb6837 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -83,6 +83,7 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* Vb */
{ in_line_eoln, 0 }, /* Ve */
{ in_line_eoln, 0 }, /* AT */
+ { in_line_eoln, 0 }, /* in */
};
const struct man_macro * const man_macros = __man_macros;
diff --git a/man_term.c b/man_term.c
index 2f122958..c7b92d8c 100644
--- a/man_term.c
+++ b/man_term.c
@@ -94,6 +94,7 @@ static int pre_SS(DECL_ARGS);
static int pre_TP(DECL_ARGS);
static int pre_fi(DECL_ARGS);
static int pre_ign(DECL_ARGS);
+static int pre_in(DECL_ARGS);
static int pre_nf(DECL_ARGS);
static int pre_sp(DECL_ARGS);
@@ -141,6 +142,7 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_nf, NULL, 0 }, /* Vb */
{ pre_fi, NULL, 0 }, /* Ve */
{ pre_ign, NULL, 0 }, /* AT */
+ { pre_in, NULL, MAN_NOTEXT }, /* in */
};
@@ -354,6 +356,47 @@ pre_B(DECL_ARGS)
/* ARGSUSED */
static int
+pre_in(DECL_ARGS)
+{
+ int len, less;
+ size_t v;
+ const char *cp;
+
+ term_newln(p);
+
+ if (NULL == n->child) {
+ p->offset = mt->offset;
+ return(0);
+ }
+
+ cp = n->child->string;
+ less = 0;
+
+ if ('-' == *cp)
+ less = -1;
+ else if ('+' == *cp)
+ less = 1;
+ else
+ cp--;
+
+ if ((len = a2width(p, ++cp)) < 0)
+ return(0);
+
+ v = (size_t)len;
+
+ if (less < 0)
+ p->offset -= p->offset > v ? v : p->offset;
+ else if (less > 0)
+ p->offset += v;
+ else
+ p->offset = v;
+
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
pre_sp(DECL_ARGS)
{
size_t i, len;
diff --git a/man_validate.c b/man_validate.c
index 0d96953c..bc5a8c73 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -83,9 +83,9 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* I */
{ NULL, NULL }, /* IR */
{ NULL, NULL }, /* RI */
- { NULL, posts_eq0 }, /* na */
+ { NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
{ NULL, NULL }, /* i */
- { NULL, posts_le1 }, /* sp */
+ { NULL, posts_le1 }, /* sp */ /* FIXME: should warn only. */
{ pres_bline, posts_eq0 }, /* nf */
{ pres_bline, posts_eq0 }, /* fi */
{ NULL, NULL }, /* r */
@@ -94,10 +94,11 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* DT */
{ NULL, NULL }, /* UC */
{ NULL, NULL }, /* PD */
- { NULL, posts_le1 }, /* Sp */
- { pres_bline, posts_le1 }, /* Vb */
+ { NULL, posts_le1 }, /* Sp */ /* FIXME: should warn only. */
+ { pres_bline, posts_le1 }, /* Vb */ /* FIXME: should warn only. */
{ pres_bline, posts_eq0 }, /* Ve */
{ NULL, NULL }, /* AT */
+ { NULL, NULL }, /* in */
};
diff --git a/out.c b/out.c
index 98436001..746d6020 100644
--- a/out.c
+++ b/out.c
@@ -116,6 +116,7 @@ a2roffsu(const char *src, struct roffsu *dst, enum roffscale def)
return(0);
}
+ /* FIXME: do this in the caller. */
if ((dst->scale = atof(buf)) < 0)
dst->scale = 0;
dst->unit = unit;