diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-05-05 15:17:32 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-05-05 15:17:32 +0000 |
commit | 59ff183bfbf2ef15bb6bae96290e8347aef13fb0 (patch) | |
tree | 44bdd5ee7af707828e02619c5b92b76ff63f5a20 | |
parent | 3f8e564abc73c1abd2c1286b5e767b2b101aae57 (diff) | |
download | mandoc-59ff183bfbf2ef15bb6bae96290e8347aef13fb0.tar.gz |
Move .sp to the roff modules. Enough infrastructure is in place
now that this actually saves code: -70 LOC.
-rw-r--r-- | man.c | 2 | ||||
-rw-r--r-- | man_html.c | 22 | ||||
-rw-r--r-- | man_macro.c | 4 | ||||
-rw-r--r-- | man_term.c | 51 | ||||
-rw-r--r-- | man_validate.c | 5 | ||||
-rw-r--r-- | mandocdb.c | 1 | ||||
-rw-r--r-- | mdoc.c | 2 | ||||
-rw-r--r-- | mdoc_argv.c | 1 | ||||
-rw-r--r-- | mdoc_html.c | 28 | ||||
-rw-r--r-- | mdoc_macro.c | 6 | ||||
-rw-r--r-- | mdoc_man.c | 22 | ||||
-rw-r--r-- | mdoc_markdown.c | 4 | ||||
-rw-r--r-- | mdoc_state.c | 1 | ||||
-rw-r--r-- | mdoc_term.c | 44 | ||||
-rw-r--r-- | mdoc_validate.c | 8 | ||||
-rw-r--r-- | regress/man/blank/line.out_lint | 4 | ||||
-rw-r--r-- | regress/mdoc/Pp/arg.out_lint | 2 | ||||
-rw-r--r-- | regress/roff/cond/close.out_lint | 1 | ||||
-rw-r--r-- | roff.c | 10 | ||||
-rw-r--r-- | roff.h | 4 | ||||
-rw-r--r-- | roff_html.c | 22 | ||||
-rw-r--r-- | roff_term.c | 26 | ||||
-rw-r--r-- | roff_validate.c | 1 |
23 files changed, 95 insertions, 176 deletions
@@ -97,7 +97,7 @@ man_ptext(struct roff_man *man, int line, char *buf, int offs) /* Allocate a blank entry. */ if (man->last->tok != MAN_SH && man->last->tok != MAN_SS) { - roff_elem_alloc(man, line, offs, MAN_sp); + roff_elem_alloc(man, line, offs, ROFF_sp); man->next = ROFF_NEXT_SIBLING; } return 1; @@ -69,7 +69,6 @@ static int man_ign_pre(MAN_ARGS); static int man_in_pre(MAN_ARGS); static void man_root_post(MAN_ARGS); static void man_root_pre(MAN_ARGS); -static int man_sp_pre(MAN_ARGS); static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { NULL, NULL }, /* TH */ @@ -92,7 +91,6 @@ static const struct htmlman __mans[MAN_MAX - MAN_TH] = { { man_I_pre, NULL }, /* I */ { man_alt_pre, NULL }, /* IR */ { man_alt_pre, NULL }, /* RI */ - { man_sp_pre, NULL }, /* sp */ { NULL, NULL }, /* nf */ { NULL, NULL }, /* fi */ { NULL, NULL }, /* RE */ @@ -304,6 +302,7 @@ print_man_node(MAN_ARGS) t = h->tag; if (n->tok < ROFF_MAX) { roff_html_pre(h, n); + child = 0; break; } @@ -413,25 +412,6 @@ man_root_post(MAN_ARGS) print_tagq(h, t); } - -static int -man_sp_pre(MAN_ARGS) -{ - struct roffsu su; - - SCALE_VS_INIT(&su, 1); - if (NULL != (n = n->child)) - if ( ! a2roffsu(n->string, &su, SCALE_VS)) - su.scale = 1.0; - - print_otag(h, TAG_DIV, "suh", &su); - - /* So the div isn't empty: */ - print_text(h, "\\~"); - - return 0; -} - static int man_SH_pre(MAN_ARGS) { diff --git a/man_macro.c b/man_macro.c index a857957b..7b4f8de8 100644 --- a/man_macro.c +++ b/man_macro.c @@ -61,7 +61,6 @@ const struct man_macro __man_macros[MAN_MAX - MAN_TH] = { { in_line_eoln, MAN_SCOPED | MAN_JOIN }, /* I */ { in_line_eoln, 0 }, /* IR */ { in_line_eoln, 0 }, /* RI */ - { in_line_eoln, MAN_NSCOPED }, /* sp */ { in_line_eoln, MAN_NSCOPED }, /* nf */ { in_line_eoln, MAN_NSCOPED }, /* fi */ { blk_close, MAN_BSCOPE }, /* RE */ @@ -331,8 +330,7 @@ in_line_eoln(MACRO_PROT_ARGS) roff_name[tok], buf + *pos); break; } - if (buf[*pos] != '\0' && man->last != n && - (tok == MAN_PD || tok == MAN_sp)) { + if (buf[*pos] != '\0' && man->last != n && tok == MAN_PD) { mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse, line, *pos, "%s ... %s", roff_name[tok], buf + *pos); @@ -83,7 +83,6 @@ static int pre_alternate(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 void post_IP(DECL_ARGS); static void post_HP(DECL_ARGS); @@ -114,7 +113,6 @@ static const struct termact __termacts[MAN_MAX - MAN_TH] = { { pre_I, NULL, 0 }, /* I */ { pre_alternate, NULL, 0 }, /* IR */ { pre_alternate, NULL, 0 }, /* RI */ - { pre_sp, NULL, MAN_NOTEXT }, /* sp */ { pre_literal, NULL, 0 }, /* nf */ { pre_literal, NULL, 0 }, /* fi */ { NULL, NULL, 0 }, /* RE */ @@ -392,55 +390,6 @@ pre_in(DECL_ARGS) } static int -pre_sp(DECL_ARGS) -{ - struct roffsu su; - int i, len; - - if ((NULL == n->prev && n->parent)) { - switch (n->parent->tok) { - case MAN_SH: - case MAN_SS: - case MAN_PP: - case MAN_LP: - case MAN_P: - return 0; - default: - break; - } - } - - if (n->child == NULL) - len = 1; - else { - if ( ! a2roffsu(n->child->string, &su, SCALE_VS)) - su.scale = 1.0; - len = term_vspan(p, &su); - } - - if (len == 0) - term_newln(p); - else if (len < 0) - p->skipvsp -= len; - else - for (i = 0; i < len; i++) - term_vspace(p); - - /* - * Handle an explicit break request in the same way - * as an overflowing line. - */ - - if (p->flags & TERMP_BRIND) { - p->offset = p->rmargin; - p->rmargin = p->maxrmargin; - p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND); - } - - return 0; -} - -static int pre_HP(DECL_ARGS) { struct roffsu su; diff --git a/man_validate.c b/man_validate.c index 9b3ae239..ee74da7d 100644 --- a/man_validate.c +++ b/man_validate.c @@ -74,7 +74,6 @@ static const v_check __man_valids[MAN_MAX - MAN_TH] = { NULL, /* I */ NULL, /* IR */ NULL, /* RI */ - post_vs, /* sp */ NULL, /* nf */ NULL, /* fi */ NULL, /* RE */ @@ -125,6 +124,7 @@ man_node_validate(struct roff_man *man) if (n->tok < ROFF_MAX) { switch (n->tok) { case ROFF_br: + case ROFF_sp: post_vs(man, n); break; default: @@ -445,6 +445,9 @@ post_vs(CHKARGS) switch (n->parent->tok) { case MAN_SH: case MAN_SS: + case MAN_PP: + case MAN_LP: + case MAN_P: mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, n->line, n->pos, "%s after %s", roff_name[n->tok], roff_name[n->parent->tok]); @@ -302,7 +302,6 @@ static const struct mdoc_handler __mdocs[MDOC_MAX - MDOC_Dd] = { { NULL, 0, 0 }, /* En */ { NULL, TYPE_Dx, NODE_NOSRC }, /* Dx */ { NULL, 0, 0 }, /* %Q */ - { NULL, 0, 0 }, /* sp */ { NULL, 0, 0 }, /* %U */ { NULL, 0, 0 }, /* Ta */ }; @@ -253,7 +253,7 @@ mdoc_ptext(struct roff_man *mdoc, int line, char *buf, int offs) * blank lines aren't allowed, but enough manuals assume this * behaviour that we want to work around it. */ - roff_elem_alloc(mdoc, line, offs, MDOC_sp); + roff_elem_alloc(mdoc, line, offs, ROFF_sp); mdoc->last->flags |= NODE_VALID | NODE_ENDED; mdoc->next = ROFF_NEXT_SIBLING; return 1; diff --git a/mdoc_argv.c b/mdoc_argv.c index 3f22ec77..9e173485 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -263,7 +263,6 @@ static const struct mdocarg __mdocargs[MDOC_MAX - MDOC_Dd] = { { ARGSFL_DELIM, NULL }, /* En */ { ARGSFL_DELIM, NULL }, /* Dx */ { ARGSFL_NONE, NULL }, /* %Q */ - { ARGSFL_NONE, NULL }, /* sp */ { ARGSFL_NONE, NULL }, /* %U */ { ARGSFL_NONE, NULL }, /* Ta */ }; diff --git a/mdoc_html.c b/mdoc_html.c index 3c8ebdf8..85dfa5a5 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -108,7 +108,6 @@ static int mdoc_rs_pre(MDOC_ARGS); static int mdoc_sh_pre(MDOC_ARGS); static int mdoc_skip_pre(MDOC_ARGS); static int mdoc_sm_pre(MDOC_ARGS); -static int mdoc_sp_pre(MDOC_ARGS); static int mdoc_ss_pre(MDOC_ARGS); static int mdoc_st_pre(MDOC_ARGS); static int mdoc_sx_pre(MDOC_ARGS); @@ -237,7 +236,6 @@ static const struct htmlmdoc __mdocs[MDOC_MAX - MDOC_Dd] = { {mdoc_quote_pre, mdoc_quote_post}, /* En */ {mdoc_xx_pre, NULL}, /* Dx */ {mdoc__x_pre, mdoc__x_post}, /* %Q */ - {mdoc_sp_pre, NULL}, /* sp */ {mdoc__x_pre, mdoc__x_post}, /* %U */ {NULL, NULL}, /* Ta */ }; @@ -1009,9 +1007,9 @@ mdoc_bd_pre(MDOC_ARGS) * anyway, so don't sweat it. */ switch (nn->tok) { - case MDOC_Sm: case ROFF_br: - case MDOC_sp: + case ROFF_sp: + case MDOC_Sm: case MDOC_Bl: case MDOC_D1: case MDOC_Dl: @@ -1326,28 +1324,6 @@ mdoc_pp_pre(MDOC_ARGS) } static int -mdoc_sp_pre(MDOC_ARGS) -{ - struct roffsu su; - - SCALE_VS_INIT(&su, 1); - if (NULL != (n = n->child)) { - if ( ! a2roffsu(n->string, &su, SCALE_VS)) - su.scale = 1.0; - else if (su.scale < 0.0) - su.scale = 0.0; - } - - print_otag(h, TAG_DIV, "suh", &su); - - /* So the div isn't empty: */ - print_text(h, "\\~"); - - return 0; - -} - -static int mdoc_lk_pre(MDOC_ARGS) { struct tag *t; diff --git a/mdoc_macro.c b/mdoc_macro.c index ac2600c4..832494bf 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -197,7 +197,6 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX - MDOC_Dd] = { { blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* En */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Dx */ { in_line_eoln, MDOC_JOIN }, /* %Q */ - { in_line_eoln, 0 }, /* sp */ { in_line_eoln, 0 }, /* %U */ { phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */ }; @@ -249,9 +248,8 @@ lookup(struct roff_man *mdoc, int from, int line, int ppos, const char *p) if (res != TOKEN_NONE) { if (mdoc_macros[res].flags & MDOC_CALLABLE) return res; - if (res != MDOC_sp) - mandoc_msg(MANDOCERR_MACRO_CALL, - mdoc->parse, line, ppos, p); + mandoc_msg(MANDOCERR_MACRO_CALL, + mdoc->parse, line, ppos, p); } } return TOKEN_NONE; @@ -73,7 +73,6 @@ static void post_nm(DECL_ARGS); static void post_percent(DECL_ARGS); static void post_pf(DECL_ARGS); static void post_sect(DECL_ARGS); -static void post_sp(DECL_ARGS); static void post_vt(DECL_ARGS); static int pre__t(DECL_ARGS); static int pre_an(DECL_ARGS); @@ -109,7 +108,7 @@ static int pre_ns(DECL_ARGS); static int pre_pp(DECL_ARGS); static int pre_rs(DECL_ARGS); static int pre_sm(DECL_ARGS); -static int pre_sp(DECL_ARGS); +static void pre_sp(DECL_ARGS); static int pre_sect(DECL_ARGS); static int pre_sy(DECL_ARGS); static void pre_syn(const struct roff_node *); @@ -128,6 +127,7 @@ static const void_fp roff_manacts[ROFF_MAX] = { pre_br, pre_ft, pre_ll, + pre_sp, }; static const struct manact __manacts[MDOC_MAX - MDOC_Dd] = { @@ -249,7 +249,6 @@ static const struct manact __manacts[MDOC_MAX - MDOC_Dd] = { { cond_body, pre_en, post_en, NULL, NULL }, /* En */ { NULL, NULL, NULL, NULL, NULL }, /* Dx */ { NULL, NULL, post_percent, NULL, NULL }, /* %Q */ - { NULL, pre_sp, post_sp, NULL, NULL }, /* sp */ { NULL, NULL, post_percent, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ }; @@ -1694,22 +1693,17 @@ pre_sm(DECL_ARGS) return 0; } -static int +static void pre_sp(DECL_ARGS) { - - if (MMAN_PP & outflags) { + if (outflags & MMAN_PP) { outflags &= ~MMAN_PP; print_line(".PP", 0); - } else + } else { print_line(".sp", 0); - return 1; -} - -static void -post_sp(DECL_ARGS) -{ - + if (n->child != NULL) + print_word(n->child->string); + } outflags |= MMAN_nl; } diff --git a/mdoc_markdown.c b/mdoc_markdown.c index abb97836..e01eb2cd 100644 --- a/mdoc_markdown.c +++ b/mdoc_markdown.c @@ -222,7 +222,6 @@ static const struct md_act __md_acts[MDOC_MAX - MDOC_Dd] = { { md_cond_body, md_pre_En, md_post_En, NULL, NULL }, /* En */ { NULL, NULL, NULL, NULL, NULL }, /* Dx */ { NULL, NULL, md_post_pc, NULL, NULL }, /* %Q */ - { NULL, md_pre_Pp, NULL, NULL, NULL }, /* sp */ { NULL, md_pre_Lk, md_post_pc, NULL, NULL }, /* %U */ { NULL, NULL, NULL, NULL, NULL }, /* Ta */ }; @@ -323,6 +322,9 @@ md_node(struct roff_node *n) case ROFF_br: process_children = md_pre_br(n); break; + case ROFF_sp: + process_children = md_pre_Pp(n); + break; default: process_children = 0; break; diff --git a/mdoc_state.c b/mdoc_state.c index 2e67c63c..ecf06201 100644 --- a/mdoc_state.c +++ b/mdoc_state.c @@ -155,7 +155,6 @@ static const state_handler __state_handlers[MDOC_MAX - MDOC_Dd] = { NULL, /* En */ NULL, /* Dx */ NULL, /* %Q */ - NULL, /* sp */ NULL, /* %U */ NULL, /* Ta */ }; diff --git a/mdoc_term.c b/mdoc_term.c index 8f8938fd..0becd3b5 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -115,7 +115,7 @@ static int termp_rs_pre(DECL_ARGS); static int termp_sh_pre(DECL_ARGS); static int termp_skip_pre(DECL_ARGS); static int termp_sm_pre(DECL_ARGS); -static int termp_sp_pre(DECL_ARGS); +static int termp_pp_pre(DECL_ARGS); static int termp_ss_pre(DECL_ARGS); static int termp_sy_pre(DECL_ARGS); static int termp_tag_pre(DECL_ARGS); @@ -130,7 +130,7 @@ static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = { { NULL, NULL }, /* Os */ { termp_sh_pre, termp_sh_post }, /* Sh */ { termp_ss_pre, termp_ss_post }, /* Ss */ - { termp_sp_pre, NULL }, /* Pp */ + { termp_pp_pre, NULL }, /* Pp */ { termp_d1_pre, termp_bl_post }, /* D1 */ { termp_d1_pre, termp_bl_post }, /* Dl */ { termp_bd_pre, termp_bd_post }, /* Bd */ @@ -232,7 +232,7 @@ static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = { { termp_under_pre, NULL }, /* Fr */ { NULL, NULL }, /* Ud */ { NULL, termp_lb_post }, /* Lb */ - { termp_sp_pre, NULL }, /* Lp */ + { termp_pp_pre, NULL }, /* Lp */ { termp_lk_pre, NULL }, /* Lk */ { termp_under_pre, NULL }, /* Mt */ { termp_quote_pre, termp_quote_post }, /* Brq */ @@ -243,7 +243,6 @@ static const struct termact __termacts[MDOC_MAX - MDOC_Dd] = { { termp_quote_pre, termp_quote_post }, /* En */ { termp_xx_pre, termp_xx_post }, /* Dx */ { NULL, termp____post }, /* %Q */ - { termp_sp_pre, NULL }, /* sp */ { NULL, termp____post }, /* %U */ { NULL, NULL }, /* Ta */ }; @@ -1495,9 +1494,9 @@ termp_bd_pre(DECL_ARGS) * anyway, so don't sweat it. */ switch (nn->tok) { - case MDOC_Sm: case ROFF_br: - case MDOC_sp: + case ROFF_sp: + case MDOC_Sm: case MDOC_Bl: case MDOC_D1: case MDOC_Dl: @@ -1644,37 +1643,10 @@ termp_in_post(DECL_ARGS) } static int -termp_sp_pre(DECL_ARGS) +termp_pp_pre(DECL_ARGS) { - struct roffsu su; - int i, len; - - switch (n->tok) { - case MDOC_sp: - if (n->child) { - if ( ! a2roffsu(n->child->string, &su, SCALE_VS)) - su.scale = 1.0; - len = term_vspan(p, &su); - } else - len = 1; - break; - case ROFF_br: - len = 0; - break; - default: - len = 1; - fn_prio = 0; - break; - } - - if (0 == len) - term_newln(p); - else if (len < 0) - p->skipvsp -= len; - else - for (i = 0; i < len; i++) - term_vspace(p); - + fn_prio = 0; + term_vspace(p); return 0; } diff --git a/mdoc_validate.c b/mdoc_validate.c index 50ccab6d..fe4204be 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -227,7 +227,6 @@ static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] = { post_en, /* En */ post_xx, /* Dx */ NULL, /* %Q */ - post_par, /* sp */ NULL, /* %U */ NULL, /* Ta */ }; @@ -328,6 +327,7 @@ mdoc_node_validate(struct roff_man *mdoc) if (n->tok < ROFF_MAX) { switch(n->tok) { case ROFF_br: + case ROFF_sp: post_par(mdoc); break; default: @@ -2096,10 +2096,10 @@ post_par(POST_ARGS) struct roff_node *np; np = mdoc->last; - if (np->tok != ROFF_br && np->tok != MDOC_sp) + if (np->tok != ROFF_br && np->tok != ROFF_sp) post_prevpar(mdoc); - if (np->tok == MDOC_sp) { + if (np->tok == ROFF_sp) { if (np->child != NULL && np->child->next != NULL) mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, np->child->next->line, np->child->next->pos, @@ -2115,7 +2115,7 @@ post_par(POST_ARGS) return; } else if (np->tok != MDOC_Pp && np->tok != MDOC_Lp && (mdoc->last->tok != ROFF_br || - (np->tok != MDOC_sp && np->tok != ROFF_br))) + (np->tok != ROFF_sp && np->tok != ROFF_br))) return; mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, diff --git a/regress/man/blank/line.out_lint b/regress/man/blank/line.out_lint index 8480cfc2..cf3507f5 100644 --- a/regress/man/blank/line.out_lint +++ b/regress/man/blank/line.out_lint @@ -1,4 +1,8 @@ mandoc: line.in:5:2: WARNING: skipping paragraph macro: sp after SH +mandoc: line.in:23:2: WARNING: skipping paragraph macro: br after PP mandoc: line.in:25:2: WARNING: skipping paragraph macro: PP empty +mandoc: line.in:35:2: WARNING: skipping paragraph macro: sp after PP +mandoc: line.in:38:2: WARNING: skipping paragraph macro: sp after PP +mandoc: line.in:53:1: WARNING: skipping paragraph macro: sp after PP mandoc: line.in:81:2: WARNING: skipping paragraph macro: sp after SH mandoc: line.in:84:2: WARNING: skipping paragraph macro: sp after SS diff --git a/regress/mdoc/Pp/arg.out_lint b/regress/mdoc/Pp/arg.out_lint index 58b97965..048f13fa 100644 --- a/regress/mdoc/Pp/arg.out_lint +++ b/regress/mdoc/Pp/arg.out_lint @@ -1,3 +1,3 @@ mandoc: arg.in:11:5: ERROR: skipping all arguments: br drop this +mandoc: arg.in:13:8: ERROR: skipping excess arguments: sp ... drop this mandoc: arg.in:9:2: ERROR: skipping all arguments: Pp drop -mandoc: arg.in:13:8: ERROR: skipping excess arguments: sp ... drop diff --git a/regress/roff/cond/close.out_lint b/regress/roff/cond/close.out_lint index c59a98d7..4800694a 100644 --- a/regress/roff/cond/close.out_lint +++ b/regress/roff/cond/close.out_lint @@ -1 +1,2 @@ mandoc: close.in:14:2: ERROR: appending missing end of block: if +mandoc: close.in:14:9: WARNING: skipping paragraph macro: sp after PP @@ -211,7 +211,8 @@ static enum rofferr roff_userdef(ROFF_ARGS); #define ROFFNUM_WHITE (1 << 1) /* Skip whitespace in roff_evalnum(). */ const char *__roff_name[MAN_MAX + 1] = { - "br", "ft", "ll", NULL, + "br", "ft", "ll", "sp", + NULL, "ab", "ad", "af", "aln", "als", "am", "am1", "ami", "ami1", "as", "as1", "asciify", @@ -301,14 +302,14 @@ const char *__roff_name[MAN_MAX + 1] = { "Fr", "Ud", "Lb", "Lp", "Lk", "Mt", "Brq", "Bro", "Brc", "%C", "Es", "En", - "Dx", "%Q", "sp", - "%U", "Ta", NULL, + "Dx", "%Q", "%U", "Ta", + NULL, "TH", "SH", "SS", "TP", "LP", "PP", "P", "IP", "HP", "SM", "SB", "BI", "IB", "BR", "RB", "R", "B", "I", "IR", "RI", - "sp", "nf", "fi", + "nf", "fi", "RE", "RS", "DT", "UC", "PD", "AT", "in", "OP", "EX", "EE", "UR", @@ -320,6 +321,7 @@ static struct roffmac roffs[TOKEN_NONE] = { { roff_br, NULL, NULL, 0 }, /* br */ { roff_onearg, NULL, NULL, 0 }, /* ft */ { roff_onearg, NULL, NULL, 0 }, /* ll */ + { roff_onearg, NULL, NULL, 0 }, /* sp */ { NULL, NULL, NULL, 0 }, /* ROFF_MAX */ { roff_unsupp, NULL, NULL, 0 }, /* ab */ { roff_line_ignore, NULL, NULL, 0 }, /* ad */ @@ -69,6 +69,7 @@ enum roff_tok { ROFF_br = 0, ROFF_ft, ROFF_ll, + ROFF_sp, ROFF_MAX, ROFF_ab, ROFF_ad, @@ -261,7 +262,6 @@ enum roff_tok { ROFF_shift, ROFF_sizes, ROFF_so, - /* MAN_sp, MDOC_sp */ ROFF_spacewidth, ROFF_special, ROFF_spreadwarn, @@ -429,7 +429,6 @@ enum roff_tok { MDOC_En, MDOC_Dx, MDOC__Q, - MDOC_sp, MDOC__U, MDOC_Ta, MDOC_MAX, @@ -453,7 +452,6 @@ enum roff_tok { MAN_I, MAN_IR, MAN_RI, - MAN_sp, MAN_nf, MAN_fi, MAN_RE, diff --git a/roff_html.c b/roff_html.c index 3e30aa14..69e9ce54 100644 --- a/roff_html.c +++ b/roff_html.c @@ -1,6 +1,7 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv> + * Copyright (c) 2014, 2017 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -28,10 +29,13 @@ typedef void (*roff_html_pre_fp)(ROFF_HTML_ARGS); static void roff_html_pre_br(ROFF_HTML_ARGS); +static void roff_html_pre_sp(ROFF_HTML_ARGS); static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = { roff_html_pre_br, /* br */ NULL, /* ft */ + NULL, /* ll */ + roff_html_pre_sp, /* sp */ }; @@ -49,3 +53,19 @@ roff_html_pre_br(ROFF_HTML_ARGS) print_otag(h, TAG_DIV, ""); print_text(h, "\\~"); /* So the div isn't empty. */ } + +static void +roff_html_pre_sp(ROFF_HTML_ARGS) +{ + struct roffsu su; + + SCALE_VS_INIT(&su, 1); + if ((n = n->child) != NULL) { + if (a2roffsu(n->string, &su, SCALE_VS) == 0) + su.scale = 1.0; + else if (su.scale < 0.0) + su.scale = 0.0; + } + print_otag(h, TAG_DIV, "suh", &su); + print_text(h, "\\~"); /* So the div isn't empty. */ +} diff --git a/roff_term.c b/roff_term.c index 783bd2ee..ea34208e 100644 --- a/roff_term.c +++ b/roff_term.c @@ -1,6 +1,6 @@ /* $OpenBSD$ */ /* - * Copyright (c) 2010, 2014, 2017 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -30,11 +30,13 @@ typedef void (*roff_term_pre_fp)(ROFF_TERM_ARGS); static void roff_term_pre_br(ROFF_TERM_ARGS); static void roff_term_pre_ft(ROFF_TERM_ARGS); static void roff_term_pre_ll(ROFF_TERM_ARGS); +static void roff_term_pre_sp(ROFF_TERM_ARGS); static const roff_term_pre_fp roff_term_pre_acts[ROFF_MAX] = { roff_term_pre_br, /* br */ roff_term_pre_ft, /* ft */ roff_term_pre_ll, /* ft */ + roff_term_pre_sp, /* br */ }; @@ -87,3 +89,25 @@ roff_term_pre_ll(ROFF_TERM_ARGS) { term_setwidth(p, n->child != NULL ? n->child->string : NULL); } + +static void +roff_term_pre_sp(ROFF_TERM_ARGS) +{ + struct roffsu su; + int len; + + if (n->child != NULL) { + if (a2roffsu(n->child->string, &su, SCALE_VS) == 0) + su.scale = 1.0; + len = term_vspan(p, &su); + } else + len = 1; + + if (len < 0) + p->skipvsp -= len; + else + while (len--) + term_vspace(p); + + roff_term_pre_br(p, n); +} diff --git a/roff_validate.c b/roff_validate.c index 4fca0406..e18f3c1a 100644 --- a/roff_validate.c +++ b/roff_validate.c @@ -34,6 +34,7 @@ static const roff_valid_fp roff_valids[ROFF_MAX] = { NULL, /* br */ roff_valid_ft, /* ft */ NULL, /* ll */ + NULL, /* sp */ }; |