summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-01-30 18:28:03 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-01-30 18:28:03 +0000
commit340c410ef076d48fcc0797a5e5ab628d1b43f7fe (patch)
tree60777c31193e210df1d4919729a8fb67167c194e /usr.bin/mandoc
parent038f0c90a72f721a19b941a520c5a8b45535f64e (diff)
Make .Bx accept not more than two arguments.
Convert the first character of the second argument to uppercase. Append the second argument with a hyphen. Improves chpass(1), column(1), fstat(1), ... from kristaps@
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/mdoc_html.c22
-rw-r--r--usr.bin/mandoc/mdoc_macro.c6
-rw-r--r--usr.bin/mandoc/mdoc_term.c28
-rw-r--r--usr.bin/mandoc/mdoc_validate.c24
4 files changed, 62 insertions, 18 deletions
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index a9447138e43..320298b928f 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.48 2011/01/16 19:41:16 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.49 2011/01/30 18:28:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -828,19 +828,27 @@ mdoc_xx_pre(MDOC_ARGS)
static int
mdoc_bx_pre(MDOC_ARGS)
{
- const struct mdoc_node *nn;
- struct htmlpair tag;
+ struct htmlpair tag;
PAIR_CLASS_INIT(&tag, "unix");
print_otag(h, TAG_SPAN, 1, &tag);
- for (nn = n->child; nn; nn = nn->next)
- print_mdoc_node(m, nn, h);
+ if (NULL != (n = n->child)) {
+ print_text(h, n->string);
+ h->flags |= HTML_NOSPACE;
+ print_text(h, "BSD");
+ } else {
+ print_text(h, "BSD");
+ return(0);
+ }
- if (n->child)
+ if (NULL != (n = n->next)) {
h->flags |= HTML_NOSPACE;
+ print_text(h, "-");
+ h->flags |= HTML_NOSPACE;
+ print_text(h, n->string);
+ }
- print_text(h, "BSD");
return(0);
}
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index a638ed9445c..23616ab1486 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,6 +1,6 @@
-/* $Id: mdoc_macro.c,v 1.63 2011/01/16 19:27:25 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.64 2011/01/30 18:28:01 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -1457,6 +1457,8 @@ in_line_argn(MACRO_PROT_ARGS)
case (MDOC_Ux):
maxargs = 0;
break;
+ case (MDOC_Bx):
+ /* FALLTHROUGH */
case (MDOC_Xr):
maxargs = 2;
break;
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 5506013497e..5fc657f2070 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.125 2011/01/30 17:41:59 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.126 2011/01/30 18:28:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -69,7 +69,6 @@ static void termp_an_post(DECL_ARGS);
static void termp_bd_post(DECL_ARGS);
static void termp_bk_post(DECL_ARGS);
static void termp_bl_post(DECL_ARGS);
-static void termp_bx_post(DECL_ARGS);
static void termp_d1_post(DECL_ARGS);
static void termp_fo_post(DECL_ARGS);
static void termp_in_post(DECL_ARGS);
@@ -91,6 +90,7 @@ static int termp_bk_pre(DECL_ARGS);
static int termp_bl_pre(DECL_ARGS);
static int termp_bold_pre(DECL_ARGS);
static int termp_bt_pre(DECL_ARGS);
+static int termp_bx_pre(DECL_ARGS);
static int termp_cd_pre(DECL_ARGS);
static int termp_d1_pre(DECL_ARGS);
static int termp_ex_pre(DECL_ARGS);
@@ -183,7 +183,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_quote_pre, termp_quote_post }, /* Bo */
{ termp_quote_pre, termp_quote_post }, /* Bq */
{ termp_xx_pre, NULL }, /* Bsx */
- { NULL, termp_bx_post }, /* Bx */
+ { termp_bx_pre, NULL }, /* Bx */
{ NULL, NULL }, /* Db */
{ NULL, NULL }, /* Dc */
{ termp_quote_pre, termp_quote_post }, /* Do */
@@ -1670,13 +1670,27 @@ termp_bd_post(DECL_ARGS)
/* ARGSUSED */
-static void
-termp_bx_post(DECL_ARGS)
+static int
+termp_bx_pre(DECL_ARGS)
{
- if (n->child)
+ if (NULL != (n = n->child)) {
+ term_word(p, n->string);
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, "BSD");
+ } else {
+ term_word(p, "BSD");
+ return(0);
+ }
+
+ if (NULL != (n = n->next)) {
p->flags |= TERMP_NOSPACE;
- term_word(p, "BSD");
+ term_word(p, "-");
+ p->flags |= TERMP_NOSPACE;
+ term_word(p, n->string);
+ }
+
+ return(0);
}
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 0e7f7703b6e..7c7a0d046b8 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.86 2011/01/30 17:41:59 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.87 2011/01/30 18:28:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -90,6 +90,7 @@ static int post_bl_block(POST_ARGS);
static int post_bl_block_width(POST_ARGS);
static int post_bl_block_tag(POST_ARGS);
static int post_bl_head(POST_ARGS);
+static int post_bx(POST_ARGS);
static int post_dd(POST_ARGS);
static int post_dt(POST_ARGS);
static int post_defaults(POST_ARGS);
@@ -129,6 +130,7 @@ static v_post posts_bd[] = { post_literal, hwarn_eq0, bwarn_ge1, NULL };
static v_post posts_bf[] = { hwarn_le1, post_bf, NULL };
static v_post posts_bk[] = { hwarn_eq0, bwarn_ge1, NULL };
static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
+static v_post posts_bx[] = { post_bx, NULL };
static v_post posts_bool[] = { ebool, NULL };
static v_post posts_eoln[] = { post_eoln, NULL };
static v_post posts_defaults[] = { post_defaults, NULL };
@@ -230,7 +232,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Bo */
{ NULL, NULL }, /* Bq */
{ NULL, NULL }, /* Bsx */
- { NULL, NULL }, /* Bx */
+ { NULL, posts_bx }, /* Bx */
{ NULL, posts_bool }, /* Db */
{ NULL, NULL }, /* Dc */
{ NULL, NULL }, /* Do */
@@ -2095,6 +2097,24 @@ post_prol(POST_ARGS)
}
static int
+post_bx(POST_ARGS)
+{
+ struct mdoc_node *n;
+
+ /*
+ * Make `Bx's second argument always start with an uppercase
+ * letter. Groff checks if it's an "accepted" term, but we just
+ * uppercase blindly.
+ */
+
+ n = mdoc->last->child;
+ if (n && NULL != (n = n->next))
+ *n->string = toupper((unsigned char)*n->string);
+
+ return(1);
+}
+
+static int
post_os(POST_ARGS)
{
struct mdoc_node *n;