=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.99 retrieving revision 1.104 diff -u -p -r1.99 -r1.104 --- mandoc/mdoc_man.c 2017/01/10 21:59:47 1.99 +++ mandoc/mdoc_man.c 2017/02/17 19:15:41 1.104 @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.99 2017/01/10 21:59:47 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.104 2017/02/17 19:15:41 schwarze Exp $ */ /* * Copyright (c) 2011-2017 Ingo Schwarze * @@ -79,7 +79,6 @@ static int pre_bf(DECL_ARGS); static int pre_bk(DECL_ARGS); static int pre_bl(DECL_ARGS); static int pre_br(DECL_ARGS); -static int pre_bx(DECL_ARGS); static int pre_dl(DECL_ARGS); static int pre_en(DECL_ARGS); static int pre_enc(DECL_ARGS); @@ -103,14 +102,12 @@ static int pre_no(DECL_ARGS); static int pre_ns(DECL_ARGS); static int pre_pp(DECL_ARGS); static int pre_rs(DECL_ARGS); -static int pre_rv(DECL_ARGS); static int pre_sm(DECL_ARGS); static int pre_sp(DECL_ARGS); static int pre_sect(DECL_ARGS); static int pre_sy(DECL_ARGS); static void pre_syn(const struct roff_node *); static int pre_vt(DECL_ARGS); -static int pre_ux(DECL_ARGS); static int pre_xr(DECL_ARGS); static void print_word(const char *); static void print_line(const char *, int); @@ -158,7 +155,7 @@ static const struct manact manacts[MDOC_MAX + 1] = { { cond_body, pre_enc, post_enc, "[", "]" }, /* Op */ { NULL, pre_ft, post_font, NULL, NULL }, /* Ot */ { NULL, pre_em, post_font, NULL, NULL }, /* Pa */ - { NULL, pre_rv, NULL, NULL, NULL }, /* Rv */ + { NULL, pre_ex, NULL, NULL, NULL }, /* Rv */ { NULL, NULL, NULL, NULL, NULL }, /* St */ { NULL, pre_em, post_font, NULL, NULL }, /* Va */ { NULL, pre_vt, post_vt, NULL, NULL }, /* Vt */ @@ -183,7 +180,7 @@ static const struct manact manacts[MDOC_MAX + 1] = { { cond_body, pre_enc, post_enc, "[", "]" }, /* Bo */ { cond_body, pre_enc, post_enc, "[", "]" }, /* Bq */ { NULL, NULL, NULL, NULL, NULL }, /* Bsx */ - { NULL, pre_bx, NULL, NULL, NULL }, /* Bx */ + { NULL, NULL, NULL, NULL, NULL }, /* Bx */ { NULL, pre_skip, NULL, NULL, NULL }, /* Db */ { NULL, NULL, NULL, NULL, NULL }, /* Dc */ { cond_body, pre_enc, post_enc, "\\(Lq", "\\(Rq" }, /* Do */ @@ -224,10 +221,10 @@ static const struct manact manacts[MDOC_MAX + 1] = { { NULL, NULL, NULL, NULL, NULL }, /* Oc */ { NULL, pre_bk, post_bk, NULL, NULL }, /* Bk */ { NULL, NULL, NULL, NULL, NULL }, /* Ek */ - { NULL, pre_ux, NULL, "is currently in beta test.", NULL }, /* Bt */ + { NULL, NULL, NULL, NULL, NULL }, /* Bt */ { NULL, NULL, NULL, NULL, NULL }, /* Hf */ { NULL, pre_em, post_font, NULL, NULL }, /* Fr */ - { NULL, pre_ux, NULL, "currently under development.", NULL }, /* Ud */ + { NULL, NULL, NULL, NULL, NULL }, /* Ud */ { NULL, NULL, post_lb, NULL, NULL }, /* Lb */ { NULL, pre_pp, NULL, NULL, NULL }, /* Lp */ { NULL, pre_lk, NULL, NULL, NULL }, /* Lk */ @@ -601,10 +598,14 @@ print_node(DECL_ARGS) printf("\\&"); outflags &= ~MMAN_spc; } - if (outflags & MMAN_Sm && ! (n->flags & NODE_DELIMC)) + if (n->flags & NODE_DELIMC) + outflags &= ~(MMAN_spc | MMAN_spc_force); + else if (outflags & MMAN_Sm) outflags |= MMAN_spc_force; print_word(n->string); - if (outflags & MMAN_Sm && ! (n->flags & NODE_DELIMO)) + if (n->flags & NODE_DELIMO) + outflags &= ~(MMAN_spc | MMAN_spc_force); + else if (outflags & MMAN_Sm) outflags |= MMAN_spc; } else { /* @@ -638,9 +639,6 @@ print_node(DECL_ARGS) if (ENDBODY_NOT != n->end) n->body->flags |= NODE_ENDED; - - if (ENDBODY_NOSPACE == n->end) - outflags &= ~(MMAN_spc | MMAN_nl); } static int @@ -685,36 +683,8 @@ post_enc(DECL_ARGS) static int pre_ex(DECL_ARGS) { - struct roff_node *nch; - outflags |= MMAN_br | MMAN_nl; - - print_word("The"); - - for (nch = n->child; nch != NULL; nch = nch->next) { - font_push('B'); - print_word(nch->string); - font_pop(); - - if (nch->next == NULL) - continue; - - if (nch->prev != NULL || nch->next->next != NULL) { - outflags &= ~MMAN_spc; - print_word(","); - } - if (nch->next->next == NULL) - print_word("and"); - } - - if (n->child != NULL && n->child->next != NULL) - print_word("utilities exit\\~0"); - else - print_word("utility exits\\~0"); - - print_word("on success, and\\~>0 if an error occurs."); - outflags |= MMAN_nl; - return 0; + return 1; } static void @@ -747,8 +717,7 @@ pre__t(DECL_ARGS) if (n->parent && MDOC_Rs == n->parent->tok && n->parent->norm->Rs.quote_T) { - print_word(""); - putchar('\"'); + print_word("\\(lq"); outflags &= ~MMAN_spc; } else font_push('I'); @@ -762,8 +731,7 @@ post__t(DECL_ARGS) if (n->parent && MDOC_Rs == n->parent->tok && n->parent->norm->Rs.quote_T) { outflags &= ~MMAN_spc; - print_word(""); - putchar('\"'); + print_word("\\(rq"); } else font_pop(); post_percent(meta, n); @@ -1054,26 +1022,6 @@ pre_br(DECL_ARGS) } static int -pre_bx(DECL_ARGS) -{ - - n = n->child; - if (n) { - print_word(n->string); - outflags &= ~MMAN_spc; - n = n->next; - } - print_word("BSD"); - if (NULL == n) - return 0; - outflags &= ~MMAN_spc; - print_word("-"); - outflags &= ~MMAN_spc; - print_word(n->string); - return 0; -} - -static int pre_dl(DECL_ARGS) { @@ -1565,7 +1513,7 @@ pre_nm(DECL_ARGS) } if (n->type != ROFFT_ELEM && n->type != ROFFT_HEAD) return 1; - name = n->child ? n->child->string : meta->name; + name = n->child == NULL ? NULL : n->child->string; if (NULL == name) return 0; if (n->type == ROFFT_HEAD) { @@ -1576,8 +1524,6 @@ pre_nm(DECL_ARGS) outflags |= MMAN_nl; } font_push('B'); - if (NULL == n->child) - print_word(meta->name); return 1; } @@ -1591,7 +1537,7 @@ post_nm(DECL_ARGS) break; case ROFFT_HEAD: case ROFFT_ELEM: - if (n->child != NULL || meta->name != NULL) + if (n->child != NULL && n->child->string != NULL) font_pop(); break; default: @@ -1646,57 +1592,6 @@ pre_rs(DECL_ARGS) } static int -pre_rv(DECL_ARGS) -{ - struct roff_node *nch; - - outflags |= MMAN_br | MMAN_nl; - - if (n->child != NULL) { - print_word("The"); - - for (nch = n->child; nch != NULL; nch = nch->next) { - font_push('B'); - print_word(nch->string); - font_pop(); - - outflags &= ~MMAN_spc; - print_word("()"); - - if (nch->next == NULL) - continue; - - if (nch->prev != NULL || nch->next->next != NULL) { - outflags &= ~MMAN_spc; - print_word(","); - } - if (nch->next->next == NULL) - print_word("and"); - } - - if (n->child != NULL && n->child->next != NULL) - print_word("functions return"); - else - print_word("function returns"); - - print_word("the value\\~0 if successful;"); - } else - print_word("Upon successful completion, " - "the value\\~0 is returned;"); - - print_word("otherwise the value\\~\\-1 is returned" - " and the global variable"); - - font_push('I'); - print_word("errno"); - font_pop(); - - print_word("is set to indicate the error."); - outflags |= MMAN_nl; - return 0; -} - -static int pre_skip(DECL_ARGS) { @@ -1791,17 +1686,4 @@ pre_xr(DECL_ARGS) print_node(meta, n); print_word(")"); return 0; -} - -static int -pre_ux(DECL_ARGS) -{ - - print_word(manacts[n->tok].prefix); - if (NULL == n->child) - return 0; - outflags &= ~MMAN_spc; - print_word("\\ "); - outflags &= ~MMAN_spc; - return 1; }