summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-01-11 17:39:53 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-01-11 17:39:53 +0000
commitb319284232133fdd31db9dc5894da706c99eda06 (patch)
tree83ab8d1f6f6dd343a1fc796d73b9551f8fafeb2c /mdoc_term.c
parentf1073511b0d42c759d7f3aac33e0f567c69e7dfe (diff)
downloadmandoc-b319284232133fdd31db9dc5894da706c99eda06.tar.gz
Do text production for .Bt, .Ex, .Rv, .Ud at the validation stage
rather than in the formatters. Use NODE_NOSRC flag for .Lb and NODE_NOSRC and NODE_NOPRT for .St. Results in a more rigorous syntax tree and in 135 lines less code. This work was triggered by a question from Abhinav Upadhyay <er dot abhinav dot upadhyay at gmail dot com> (NetBSD) on discuss@.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c110
1 files changed, 4 insertions, 106 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 0a420442..143dfb41 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -91,7 +91,6 @@ static int termp_bf_pre(DECL_ARGS);
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_cd_pre(DECL_ARGS);
static int termp_d1_pre(DECL_ARGS);
static int termp_eo_pre(DECL_ARGS);
@@ -114,7 +113,6 @@ static int termp_nm_pre(DECL_ARGS);
static int termp_ns_pre(DECL_ARGS);
static int termp_quote_pre(DECL_ARGS);
static int termp_rs_pre(DECL_ARGS);
-static int termp_rv_pre(DECL_ARGS);
static int termp_sh_pre(DECL_ARGS);
static int termp_skip_pre(DECL_ARGS);
static int termp_sm_pre(DECL_ARGS);
@@ -123,7 +121,6 @@ static int termp_ss_pre(DECL_ARGS);
static int termp_sy_pre(DECL_ARGS);
static int termp_tag_pre(DECL_ARGS);
static int termp_under_pre(DECL_ARGS);
-static int termp_ud_pre(DECL_ARGS);
static int termp_vt_pre(DECL_ARGS);
static int termp_xr_pre(DECL_ARGS);
static int termp_xx_pre(DECL_ARGS);
@@ -165,7 +162,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_quote_pre, termp_quote_post }, /* Op */
{ termp_ft_pre, NULL }, /* Ot */
{ termp_under_pre, NULL }, /* Pa */
- { termp_rv_pre, NULL }, /* Rv */
+ { termp_ex_pre, NULL }, /* Rv */
{ NULL, NULL }, /* St */
{ termp_under_pre, NULL }, /* Va */
{ termp_vt_pre, NULL }, /* Vt */
@@ -231,10 +228,10 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Oc */
{ termp_bk_pre, termp_bk_post }, /* Bk */
{ NULL, NULL }, /* Ek */
- { termp_bt_pre, NULL }, /* Bt */
+ { NULL, NULL }, /* Bt */
{ NULL, NULL }, /* Hf */
{ termp_under_pre, NULL }, /* Fr */
- { termp_ud_pre, NULL }, /* Ud */
+ { NULL, NULL }, /* Ud */
{ NULL, termp_lb_post }, /* Lb */
{ termp_sp_pre, NULL }, /* Lp */
{ termp_lk_pre, NULL }, /* Lk */
@@ -1113,91 +1110,10 @@ termp_rs_pre(DECL_ARGS)
}
static int
-termp_rv_pre(DECL_ARGS)
-{
- struct roff_node *nch;
-
- term_newln(p);
-
- if (n->child != NULL) {
- term_word(p, "The");
-
- for (nch = n->child; nch != NULL; nch = nch->next) {
- term_fontpush(p, TERMFONT_BOLD);
- term_word(p, nch->string);
- term_fontpop(p);
-
- p->flags |= TERMP_NOSPACE;
- term_word(p, "()");
-
- if (nch->next == NULL)
- continue;
-
- if (nch->prev != NULL || nch->next->next != NULL) {
- p->flags |= TERMP_NOSPACE;
- term_word(p, ",");
- }
- if (nch->next->next == NULL)
- term_word(p, "and");
- }
-
- if (n->child != NULL && n->child->next != NULL)
- term_word(p, "functions return");
- else
- term_word(p, "function returns");
-
- term_word(p, "the value\\~0 if successful;");
- } else
- term_word(p, "Upon successful completion,"
- " the value\\~0 is returned;");
-
- term_word(p, "otherwise the value\\~\\-1 is returned"
- " and the global variable");
-
- term_fontpush(p, TERMFONT_UNDER);
- term_word(p, "errno");
- term_fontpop(p);
-
- term_word(p, "is set to indicate the error.");
- p->flags |= TERMP_SENTENCE;
-
- return 0;
-}
-
-static int
termp_ex_pre(DECL_ARGS)
{
- struct roff_node *nch;
-
term_newln(p);
- term_word(p, "The");
-
- for (nch = n->child; nch != NULL; nch = nch->next) {
- term_fontpush(p, TERMFONT_BOLD);
- term_word(p, nch->string);
- term_fontpop(p);
-
- if (nch->next == NULL)
- continue;
-
- if (nch->prev != NULL || nch->next->next != NULL) {
- p->flags |= TERMP_NOSPACE;
- term_word(p, ",");
- }
-
- if (nch->next->next == NULL)
- term_word(p, "and");
- }
-
- if (n->child != NULL && n->child->next != NULL)
- term_word(p, "utilities exit\\~0");
- else
- term_word(p, "utility exits\\~0");
-
- term_word(p, "on success, and\\~>0 if an error occurs.");
-
- p->flags |= TERMP_SENTENCE;
- return 0;
+ return 1;
}
static int
@@ -1398,15 +1314,6 @@ termp_sh_post(DECL_ARGS)
}
}
-static int
-termp_bt_pre(DECL_ARGS)
-{
-
- term_word(p, "is currently in beta test.");
- p->flags |= TERMP_SENTENCE;
- return 0;
-}
-
static void
termp_lb_post(DECL_ARGS)
{
@@ -1416,15 +1323,6 @@ termp_lb_post(DECL_ARGS)
}
static int
-termp_ud_pre(DECL_ARGS)
-{
-
- term_word(p, "currently under development.");
- p->flags |= TERMP_SENTENCE;
- return 0;
-}
-
-static int
termp_d1_pre(DECL_ARGS)
{