summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2012-02-26 19:41:28 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2012-02-26 19:41:28 +0000
commit4dae6e2e86f0631c3b64f8065b8086ae7ad57b3e (patch)
tree74e69628fd115e3c80a215ec12c44a29b9bbbadb /usr.bin/mandoc
parent2915e4524b95e8bcabd96301c15030f4dc67bd24 (diff)
Support .OP, one of the extended man macros; from kristaps@.
Do not use this GNU extension, we take it for compatibility only.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/man.c4
-rw-r--r--usr.bin/mandoc/man.h3
-rw-r--r--usr.bin/mandoc/man_html.c53
-rw-r--r--usr.bin/mandoc/man_macro.c3
-rw-r--r--usr.bin/mandoc/man_term.c31
-rw-r--r--usr.bin/mandoc/man_validate.c10
6 files changed, 83 insertions, 21 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 42d44a0911e..8635e7b79e7 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.64 2011/11/16 17:21:15 schwarze Exp $ */
+/* $Id: man.c,v 1.65 2012/02/26 19:41:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -36,7 +36,7 @@ const char *const __man_macronames[MAN_MAX] = {
"RI", "na", "sp", "nf",
"fi", "RE", "RS", "DT",
"UC", "PD", "AT", "in",
- "ft"
+ "ft", "OP"
};
const char * const *man_macronames = __man_macronames;
diff --git a/usr.bin/mandoc/man.h b/usr.bin/mandoc/man.h
index 4a077935406..c67ef8d3134 100644
--- a/usr.bin/mandoc/man.h
+++ b/usr.bin/mandoc/man.h
@@ -1,4 +1,4 @@
-/* $Id: man.h,v 1.38 2011/10/09 17:59:56 schwarze Exp $ */
+/* $Id: man.h,v 1.39 2012/02/26 19:41:27 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -51,6 +51,7 @@ enum mant {
MAN_AT,
MAN_in,
MAN_ft,
+ MAN_OP,
MAN_MAX
};
diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c
index bef778b3cbf..b799ed4c785 100644
--- a/usr.bin/mandoc/man_html.c
+++ b/usr.bin/mandoc/man_html.c
@@ -1,4 +1,4 @@
-/* $Id: man_html.c,v 1.45 2011/12/04 00:44:18 schwarze Exp $ */
+/* $Id: man_html.c,v 1.46 2012/02/26 19:41:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -54,26 +54,25 @@ static void print_man(MAN_ARGS);
static void print_man_head(MAN_ARGS);
static void print_man_nodelist(MAN_ARGS);
static void print_man_node(MAN_ARGS);
-
static int a2width(const struct man_node *,
struct roffsu *);
-
-static int man_alt_pre(MAN_ARGS);
-static int man_br_pre(MAN_ARGS);
-static int man_ign_pre(MAN_ARGS);
-static int man_in_pre(MAN_ARGS);
-static int man_literal_pre(MAN_ARGS);
-static void man_root_post(MAN_ARGS);
-static void man_root_pre(MAN_ARGS);
static int man_B_pre(MAN_ARGS);
static int man_HP_pre(MAN_ARGS);
-static int man_I_pre(MAN_ARGS);
static int man_IP_pre(MAN_ARGS);
+static int man_I_pre(MAN_ARGS);
+static int man_OP_pre(MAN_ARGS);
static int man_PP_pre(MAN_ARGS);
static int man_RS_pre(MAN_ARGS);
static int man_SH_pre(MAN_ARGS);
static int man_SM_pre(MAN_ARGS);
static int man_SS_pre(MAN_ARGS);
+static int man_alt_pre(MAN_ARGS);
+static int man_br_pre(MAN_ARGS);
+static int man_ign_pre(MAN_ARGS);
+static int man_in_pre(MAN_ARGS);
+static int man_literal_pre(MAN_ARGS);
+static void man_root_post(MAN_ARGS);
+static void man_root_pre(MAN_ARGS);
static const struct htmlman mans[MAN_MAX] = {
{ man_br_pre, NULL }, /* br */
@@ -109,6 +108,7 @@ static const struct htmlman mans[MAN_MAX] = {
{ man_ign_pre, NULL }, /* AT */
{ man_in_pre, NULL }, /* in */
{ man_ign_pre, NULL }, /* ft */
+ { man_OP_pre, NULL }, /* OP */
};
/*
@@ -582,6 +582,37 @@ man_HP_pre(MAN_ARGS)
/* ARGSUSED */
static int
+man_OP_pre(MAN_ARGS)
+{
+ struct tag *tt;
+ struct htmlpair tag;
+
+ print_text(h, "[");
+ h->flags |= HTML_NOSPACE;
+ PAIR_CLASS_INIT(&tag, "opt");
+ tt = print_otag(h, TAG_SPAN, 1, &tag);
+
+ if (NULL != (n = n->child)) {
+ print_otag(h, TAG_B, 0, NULL);
+ print_text(h, n->string);
+ }
+
+ print_stagq(h, tt);
+
+ if (NULL != n && NULL != n->next) {
+ print_otag(h, TAG_I, 0, NULL);
+ print_text(h, n->next->string);
+ }
+
+ print_stagq(h, tt);
+ h->flags |= HTML_NOSPACE;
+ print_text(h, "]");
+ return(0);
+}
+
+
+/* ARGSUSED */
+static int
man_B_pre(MAN_ARGS)
{
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c
index f4a28bcc310..5a7ed353fe0 100644
--- a/usr.bin/mandoc/man_macro.c
+++ b/usr.bin/mandoc/man_macro.c
@@ -1,4 +1,4 @@
-/* $Id: man_macro.c,v 1.33 2011/12/04 00:44:18 schwarze Exp $ */
+/* $Id: man_macro.c,v 1.34 2012/02/26 19:41:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -80,6 +80,7 @@ const struct man_macro __man_macros[MAN_MAX] = {
{ in_line_eoln, 0 }, /* AT */
{ in_line_eoln, 0 }, /* in */
{ in_line_eoln, 0 }, /* ft */
+ { in_line_eoln, 0 }, /* OP */
};
const struct man_macro * const man_macros = __man_macros;
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 7ff3c0d730d..7660ae8ef47 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.81 2011/12/05 00:28:12 schwarze Exp $ */
+/* $Id: man_term.c,v 1.82 2012/02/26 19:41:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -64,21 +64,22 @@ static void print_man_foot(struct termp *, const void *);
static void print_bvspace(struct termp *,
const struct man_node *);
-static int pre_alternate(DECL_ARGS);
static int pre_B(DECL_ARGS);
static int pre_HP(DECL_ARGS);
static int pre_I(DECL_ARGS);
static int pre_IP(DECL_ARGS);
+static int pre_OP(DECL_ARGS);
static int pre_PP(DECL_ARGS);
static int pre_RS(DECL_ARGS);
static int pre_SH(DECL_ARGS);
static int pre_SS(DECL_ARGS);
static int pre_TP(DECL_ARGS);
+static int pre_alternate(DECL_ARGS);
+static int pre_ft(DECL_ARGS);
static int pre_ign(DECL_ARGS);
static int pre_in(DECL_ARGS);
static int pre_literal(DECL_ARGS);
static int pre_sp(DECL_ARGS);
-static int pre_ft(DECL_ARGS);
static void post_IP(DECL_ARGS);
static void post_HP(DECL_ARGS);
@@ -121,6 +122,7 @@ static const struct termact termacts[MAN_MAX] = {
{ pre_ign, NULL, 0 }, /* AT */
{ pre_in, NULL, MAN_NOTEXT }, /* in */
{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
+ { pre_OP, NULL, 0 }, /* OP */
};
@@ -320,6 +322,29 @@ pre_B(DECL_ARGS)
/* ARGSUSED */
static int
+pre_OP(DECL_ARGS)
+{
+
+ term_word(p, "[");
+ p->flags |= TERMP_NOSPACE;
+
+ if (NULL != (n = n->child)) {
+ term_fontrepl(p, TERMFONT_BOLD);
+ term_word(p, n->string);
+ }
+ if (NULL != n && NULL != n->next) {
+ term_fontrepl(p, TERMFONT_UNDER);
+ term_word(p, n->next->string);
+ }
+
+ term_fontrepl(p, TERMFONT_NONE);
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, "]");
+ return(0);
+}
+
+/* ARGSUSED */
+static int
pre_ft(DECL_ARGS)
{
const char *cp;
diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c
index 136e9cf110c..9f898e9ecf3 100644
--- a/usr.bin/mandoc/man_validate.c
+++ b/usr.bin/mandoc/man_validate.c
@@ -1,4 +1,4 @@
-/* $Id: man_validate.c,v 1.51 2011/12/02 01:45:43 schwarze Exp $ */
+/* $Id: man_validate.c,v 1.52 2012/02/26 19:41:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -41,6 +41,7 @@ struct man_valid {
};
static int check_eq0(CHKARGS);
+static int check_eq2(CHKARGS);
static int check_le1(CHKARGS);
static int check_ge2(CHKARGS);
static int check_le5(CHKARGS);
@@ -62,6 +63,7 @@ static int pre_sec(CHKARGS);
static v_check posts_at[] = { post_AT, NULL };
static v_check posts_br[] = { post_vs, check_eq0, NULL };
static v_check posts_eq0[] = { check_eq0, NULL };
+static v_check posts_eq2[] = { check_eq2, NULL };
static v_check posts_fi[] = { check_eq0, post_fi, NULL };
static v_check posts_ft[] = { post_ft, NULL };
static v_check posts_nf[] = { check_eq0, post_nf, NULL };
@@ -95,8 +97,8 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, NULL }, /* I */
{ NULL, NULL }, /* IR */
{ NULL, NULL }, /* RI */
- { NULL, posts_eq0 }, /* na */ /* FIXME: should warn only. */
- { NULL, posts_sp }, /* sp */ /* FIXME: should warn only. */
+ { NULL, posts_eq0 }, /* na */
+ { NULL, posts_sp }, /* sp */
{ NULL, posts_nf }, /* nf */
{ NULL, posts_fi }, /* fi */
{ NULL, NULL }, /* RE */
@@ -107,6 +109,7 @@ static const struct man_valid man_valids[MAN_MAX] = {
{ NULL, posts_at }, /* AT */
{ NULL, NULL }, /* in */
{ NULL, posts_ft }, /* ft */
+ { NULL, posts_eq2 }, /* OP */
};
@@ -228,6 +231,7 @@ check_##name(CHKARGS) \
}
INEQ_DEFINE(0, ==, eq0)
+INEQ_DEFINE(2, ==, eq2)
INEQ_DEFINE(1, <=, le1)
INEQ_DEFINE(2, >=, ge2)
INEQ_DEFINE(5, <=, le5)