aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-01-10 21:59:47 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-01-10 21:59:47 +0000
commitb8b4c05111a45cab71949b527a6060013e5fac66 (patch)
tree8f6d68f2e548b7c715c5dbae5d85ca8e8a3ca0c4 /mdoc_term.c
parente5e6b19e8e4776c4e2703f500ffc8eb70f2285d4 (diff)
downloadmandoc-b8b4c05111a45cab71949b527a6060013e5fac66.tar.gz
mandoc-b8b4c05111a45cab71949b527a6060013e5fac66.tar.zst
mandoc-b8b4c05111a45cab71949b527a6060013e5fac66.zip
For the .Ux/.Ox family of macros, do text production at the validation
stage rather than in each and every individual formatter, using the new NODE_NOSRC flag. More rigorous and also ten lines less code.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c60
1 files changed, 18 insertions, 42 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index ccd3e931..0442165a 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,7 +1,7 @@
-/* $Id: mdoc_term.c,v 1.338 2017/01/10 13:47:00 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.339 2017/01/10 21:59:47 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -80,6 +80,7 @@ static void termp_pf_post(DECL_ARGS);
static void termp_quote_post(DECL_ARGS);
static void termp_sh_post(DECL_ARGS);
static void termp_ss_post(DECL_ARGS);
+static void termp_xx_post(DECL_ARGS);
static int termp__a_pre(DECL_ARGS);
static int termp__t_pre(DECL_ARGS);
@@ -189,7 +190,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_bf_pre, NULL }, /* Bf */
{ termp_quote_pre, termp_quote_post }, /* Bo */
{ termp_quote_pre, termp_quote_post }, /* Bq */
- { termp_xx_pre, NULL }, /* Bsx */
+ { termp_xx_pre, termp_xx_post }, /* Bsx */
{ termp_bx_pre, NULL }, /* Bx */
{ termp_skip_pre, NULL }, /* Db */
{ NULL, NULL }, /* Dc */
@@ -199,12 +200,12 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Ef */
{ termp_em_pre, NULL }, /* Em */
{ termp_eo_pre, termp_eo_post }, /* Eo */
- { termp_xx_pre, NULL }, /* Fx */
+ { termp_xx_pre, termp_xx_post }, /* Fx */
{ termp_bold_pre, NULL }, /* Ms */
{ termp_li_pre, NULL }, /* No */
{ termp_ns_pre, NULL }, /* Ns */
- { termp_xx_pre, NULL }, /* Nx */
- { termp_xx_pre, NULL }, /* Ox */
+ { termp_xx_pre, termp_xx_post }, /* Nx */
+ { termp_xx_pre, termp_xx_post }, /* Ox */
{ NULL, NULL }, /* Pc */
{ NULL, termp_pf_post }, /* Pf */
{ termp_quote_pre, termp_quote_post }, /* Po */
@@ -222,7 +223,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_under_pre, NULL }, /* Sx */
{ termp_sy_pre, NULL }, /* Sy */
{ NULL, NULL }, /* Tn */
- { termp_xx_pre, NULL }, /* Ux */
+ { termp_xx_pre, termp_xx_post }, /* Ux */
{ NULL, NULL }, /* Xc */
{ NULL, NULL }, /* Xo */
{ termp_fo_pre, termp_fo_post }, /* Fo */
@@ -245,7 +246,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, termp____post }, /* %C */
{ termp_skip_pre, NULL }, /* Es */
{ termp_quote_pre, termp_quote_post }, /* En */
- { termp_xx_pre, NULL }, /* Dx */
+ { termp_xx_pre, termp_xx_post }, /* Dx */
{ NULL, termp____post }, /* %Q */
{ termp_sp_pre, NULL }, /* br */
{ termp_sp_pre, NULL }, /* sp */
@@ -1677,41 +1678,16 @@ termp_bx_pre(DECL_ARGS)
static int
termp_xx_pre(DECL_ARGS)
{
- const char *pp;
- int flags;
-
- pp = NULL;
- switch (n->tok) {
- case MDOC_Bsx:
- pp = "BSD/OS";
- break;
- case MDOC_Dx:
- pp = "DragonFly";
- break;
- case MDOC_Fx:
- pp = "FreeBSD";
- break;
- case MDOC_Nx:
- pp = "NetBSD";
- break;
- case MDOC_Ox:
- pp = "OpenBSD";
- break;
- case MDOC_Ux:
- pp = "UNIX";
- break;
- default:
- abort();
- }
+ if ((n->aux = p->flags & TERMP_PREKEEP) == 0)
+ p->flags |= TERMP_PREKEEP;
+ return 1;
+}
- term_word(p, pp);
- if (n->child) {
- flags = p->flags;
- p->flags |= TERMP_KEEP;
- term_word(p, n->child->string);
- p->flags = flags;
- }
- return 0;
+static void
+termp_xx_post(DECL_ARGS)
+{
+ if (n->aux == 0)
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
}
static void