diff options
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bx/Makefile | 6 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bx/args.in | 23 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bx/args.out_ascii | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 22 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 28 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 24 |
8 files changed, 111 insertions, 20 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bx/Makefile b/regress/usr.bin/mandoc/mdoc/Bx/Makefile new file mode 100644 index 00000000000..85858aad56b --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bx/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1 2011/01/30 18:28:02 schwarze Exp $ + +REGRESS_TARGETS=args +GROFF_TARGETS=args + +.include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/Bx/args.in b/regress/usr.bin/mandoc/mdoc/Bx/args.in new file mode 100644 index 00000000000..23f81259b84 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bx/args.in @@ -0,0 +1,23 @@ +.Dd January 30, 2011 +.Dt BX-ARGS 1 +.Os +.Sh NAME +.Nm Bx-args +.Nd arguments to the BSD macro +.Sh DESCRIPTION +no arguments: +.Bx +.Pp +one standard argument: +.Bx 4.4 +.Pp +one non-standard argument: +.Bx nett +.Pp +two standard arguments: +.Bx 4.3 reno +.Pp +more arguments: +.Bx 4.3 tahoe and some additional words +.Pp +end of test document diff --git a/regress/usr.bin/mandoc/mdoc/Bx/args.out_ascii b/regress/usr.bin/mandoc/mdoc/Bx/args.out_ascii new file mode 100644 index 00000000000..1b66008aa5a --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bx/args.out_ascii @@ -0,0 +1,18 @@ +BX-ARGS(1) OpenBSD Reference Manual BX-ARGS(1) + +NNAAMMEE + BBxx--aarrggss - arguments to the BSD macro + +DDEESSCCRRIIPPTTIIOONN + no arguments: BSD + + one standard argument: 4.4BSD + + one non-standard argument: nettBSD + + two standard arguments: 4.3BSD-Reno + + more arguments: 4.3BSD-Tahoe and some additional words + + end of test document + diff --git a/regress/usr.bin/mandoc/mdoc/Makefile b/regress/usr.bin/mandoc/mdoc/Makefile index a480b603b6b..7e4ec7d22e0 100644 --- a/regress/usr.bin/mandoc/mdoc/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.10 2010/12/19 12:10:33 schwarze Exp $ +# $OpenBSD: Makefile,v 1.11 2011/01/30 18:28:02 schwarze Exp $ -SUBDIR+= Ar At Bd Bk Bl Fl Fo In Lb Li Mt Nm Op Rs Sm Xr +SUBDIR+= Ar At Bd Bk Bl Bx Fl Fo In Lb Li Mt Nm Op Rs Sm Xr SUBDIR+= blank # disabled, mandoc must be fixed: 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; |