From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s6U0JIPT020277 for ; Tue, 29 Jul 2014 20:19:18 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s6U0JGli007389; Tue, 29 Jul 2014 20:19:16 -0400 (EDT) Date: Tue, 29 Jul 2014 20:19:16 -0400 (EDT) Message-Id: <201407300019.s6U0JGli007389@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Various improvements related to .Ex and .Rv: * let .Nm fall back X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Various improvements related to .Ex and .Rv: * let .Nm fall back to the empty string, not to UNKNOWN * never let .Rv copy an argument from .Nm * avoid spurious \fR after empty .Nm in -Tman * correct handling of .Ex and .Rv in -Tman * correct the wording of the output for .Rv without arguments * use non-breaking spaces in .Ex and .Rv output where required * split MANDOCERR_NONAME into a warning for .Ex and an error for .Nm Modified Files: -------------- mdocml: mandoc.h mdoc_html.c mdoc_man.c mdoc_term.c mdoc_validate.c read.c Revision Data ------------- Index: mdoc_man.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v retrieving revision 1.66 retrieving revision 1.67 diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.66 -r1.67 --- mdoc_man.c +++ mdoc_man.c @@ -83,6 +83,7 @@ static int pre_en(DECL_ARGS); static int pre_enc(DECL_ARGS); static int pre_em(DECL_ARGS); static int pre_es(DECL_ARGS); +static int pre_ex(DECL_ARGS); static int pre_fa(DECL_ARGS); static int pre_fd(DECL_ARGS); static int pre_fl(DECL_ARGS); @@ -99,6 +100,7 @@ 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); @@ -139,9 +141,7 @@ static const struct manact manacts[MDOC_ { NULL, pre_li, post_font, NULL, NULL }, /* Dv */ { NULL, pre_li, post_font, NULL, NULL }, /* Er */ { NULL, pre_li, post_font, NULL, NULL }, /* Ev */ - { NULL, pre_enc, post_enc, "The \\fB", - "\\fP\nutility exits 0 on success, and >0 if an error occurs." - }, /* Ex */ + { NULL, pre_ex, NULL, NULL, NULL }, /* Ex */ { NULL, pre_fa, post_fa, NULL, NULL }, /* Fa */ { NULL, pre_fd, post_fd, NULL, NULL }, /* Fd */ { NULL, pre_fl, post_fl, NULL, NULL }, /* Fl */ @@ -155,11 +155,7 @@ static const struct manact manacts[MDOC_ { 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_enc, post_enc, "The \\fB", - "\\fP\nfunction returns the value 0 if successful;\n" - "otherwise the value -1 is returned and the global\n" - "variable \\fIerrno\\fP is set to indicate the error." - }, /* Rv */ + { NULL, pre_rv, 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 */ @@ -673,6 +669,42 @@ post_enc(DECL_ARGS) print_word(suffix); } +static int +pre_ex(DECL_ARGS) +{ + int nchild; + + outflags |= MMAN_br | MMAN_nl; + + print_word("The"); + + nchild = n->nchild; + for (n = n->child; n; n = n->next) { + font_push('B'); + print_word(n->string); + font_pop(); + + if (n->next == NULL) + continue; + + if (nchild > 2) { + outflags &= ~MMAN_spc; + print_word(","); + } + if (n->next->next == NULL) + print_word("and"); + } + + if (nchild > 1) + 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); +} + static void post_font(DECL_ARGS) { @@ -1511,7 +1543,8 @@ post_nm(DECL_ARGS) case MDOC_HEAD: /* FALLTHROUGH */ case MDOC_ELEM: - font_pop(); + if (n->child != NULL || meta->name != NULL) + font_pop(); break; default: break; @@ -1561,6 +1594,58 @@ pre_rs(DECL_ARGS) outflags &= ~MMAN_br; } return(1); +} + +static int +pre_rv(DECL_ARGS) +{ + int nchild; + + outflags |= MMAN_br | MMAN_nl; + + nchild = n->nchild; + if (nchild > 0) { + print_word("The"); + + for (n = n->child; n; n = n->next) { + font_push('B'); + print_word(n->string); + font_pop(); + + outflags &= ~MMAN_spc; + print_word("()"); + + if (n->next == NULL) + continue; + + if (nchild > 2) { + outflags &= ~MMAN_spc; + print_word(","); + } + if (n->next->next == NULL) + print_word("and"); + } + + if (nchild > 1) + 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 Index: mdoc_validate.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v retrieving revision 1.231 retrieving revision 1.232 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.231 -r1.232 --- mdoc_validate.c +++ mdoc_validate.c @@ -100,6 +100,7 @@ static int post_dt(POST_ARGS); static int post_en(POST_ARGS); static int post_es(POST_ARGS); static int post_eoln(POST_ARGS); +static int post_ex(POST_ARGS); static int post_hyph(POST_ARGS); static int post_ignpar(POST_ARGS); static int post_it(POST_ARGS); @@ -116,7 +117,6 @@ static int post_sh(POST_ARGS); static int post_sh_body(POST_ARGS); static int post_sh_head(POST_ARGS); static int post_st(POST_ARGS); -static int post_std(POST_ARGS); static int post_vt(POST_ARGS); static int pre_an(PRE_ARGS); static int pre_bd(PRE_ARGS); @@ -149,6 +149,7 @@ static v_post posts_dl[] = { post_liter static v_post posts_dt[] = { post_dt, post_prol, NULL }; static v_post posts_en[] = { post_en, NULL }; static v_post posts_es[] = { post_es, NULL }; +static v_post posts_ex[] = { post_ex, NULL }; static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL }; static v_post posts_hyph[] = { post_hyph, NULL }; static v_post posts_hyphtext[] = { ewarn_ge1, post_hyph, NULL }; @@ -165,7 +166,6 @@ static v_post posts_sh[] = { post_ignpa static v_post posts_sp[] = { post_par, ewarn_le1, NULL }; static v_post posts_ss[] = { post_ignpar, hwarn_ge1, post_hyph, NULL }; static v_post posts_st[] = { post_st, NULL }; -static v_post posts_std[] = { post_std, NULL }; static v_post posts_text[] = { ewarn_ge1, NULL }; static v_post posts_text1[] = { ewarn_eq1, NULL }; static v_post posts_vt[] = { post_vt, NULL }; @@ -207,7 +207,7 @@ static const struct valids mdoc_valids[M { NULL, NULL }, /* Dv */ { NULL, NULL }, /* Er */ { NULL, NULL }, /* Ev */ - { pres_std, posts_std }, /* Ex */ + { pres_std, posts_ex }, /* Ex */ { NULL, NULL }, /* Fa */ { NULL, posts_text }, /* Fd */ { NULL, NULL }, /* Fl */ @@ -221,7 +221,7 @@ static const struct valids mdoc_valids[M { NULL, NULL }, /* Op */ { pres_obsolete, NULL }, /* Ot */ { NULL, posts_defaults }, /* Pa */ - { pres_std, posts_std }, /* Rv */ + { pres_std, NULL }, /* Rv */ { NULL, posts_st }, /* St */ { NULL, NULL }, /* Va */ { NULL, posts_vt }, /* Vt */ @@ -534,12 +534,6 @@ check_argv(struct mdoc *mdoc, struct mdo for (i = 0; i < (int)v->sz; i++) check_text(mdoc, v->line, v->pos, v->value[i]); - - /* FIXME: move to post_std(). */ - - if (MDOC_Std == v->arg) - if ( ! (v->sz || mdoc->meta.name)) - mdoc_nmsg(mdoc, n, MANDOCERR_NONAME); } static void @@ -1128,10 +1122,8 @@ post_nm(POST_ARGS) mdoc_deroff(&mdoc->meta.name, mdoc->last); - if (NULL == mdoc->meta.name) { - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NONAME); - mdoc->meta.name = mandoc_strdup("UNKNOWN"); - } + if (NULL == mdoc->meta.name) + mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NM_NONAME); return(1); } @@ -2395,32 +2387,31 @@ post_os(POST_ARGS) return(1); } +/* + * If no argument is provided, + * fill in the name of the current manual page. + */ static int -post_std(POST_ARGS) +post_ex(POST_ARGS) { - struct mdoc_node *nn, *n; + struct mdoc_node *n; n = mdoc->last; - /* - * Macros accepting `-std' as an argument have the name of the - * current document (`Nm') filled in as the argument if it's not - * provided. - */ - if (n->child) return(1); - if (NULL == mdoc->meta.name) + if (mdoc->meta.name == NULL) { + mdoc_nmsg(mdoc, n, MANDOCERR_EX_NONAME); return(1); + } - nn = n; mdoc->next = MDOC_NEXT_CHILD; if ( ! mdoc_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name)) return(0); - mdoc->last = nn; + mdoc->last = n; return(1); } Index: mdoc_html.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v retrieving revision 1.192 retrieving revision 1.193 diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.192 -r1.193 --- mdoc_html.c +++ mdoc_html.c @@ -1069,11 +1069,11 @@ mdoc_ex_pre(MDOC_ARGS) } if (nchild > 1) - print_text(h, "utilities exit"); + print_text(h, "utilities exit\\~0"); else - print_text(h, "utility exits"); + print_text(h, "utility exits\\~0"); - print_text(h, "0 on success, and >0 if an error occurs."); + print_text(h, "on success, and\\~>0 if an error occurs."); return(0); } @@ -1744,35 +1744,41 @@ mdoc_rv_pre(MDOC_ARGS) PAIR_CLASS_INIT(&tag, "fname"); - print_text(h, "The"); - nchild = n->nchild; - for (n = n->child; n; n = n->next) { - assert(MDOC_TEXT == n->type); + if (nchild > 0) { + print_text(h, "The"); - t = print_otag(h, TAG_B, 1, &tag); - print_text(h, n->string); - print_tagq(h, t); - - h->flags |= HTML_NOSPACE; - print_text(h, "()"); + for (n = n->child; n; n = n->next) { + t = print_otag(h, TAG_B, 1, &tag); + print_text(h, n->string); + print_tagq(h, t); - if (nchild > 2 && n->next) { h->flags |= HTML_NOSPACE; - print_text(h, ","); + print_text(h, "()"); + + if (n->next == NULL) + continue; + + if (nchild > 2) { + h->flags |= HTML_NOSPACE; + print_text(h, ","); + } + if (n->next->next == NULL) + print_text(h, "and"); } - if (n->next && NULL == n->next->next) - print_text(h, "and"); - } + if (nchild > 1) + print_text(h, "functions return"); + else + print_text(h, "function returns"); - if (nchild > 1) - print_text(h, "functions return"); - else - print_text(h, "function returns"); + print_text(h, "the value\\~0 if successful;"); + } else + print_text(h, "Upon successful completion," + " the value\\~0 is returned;"); - print_text(h, "the value 0 if successful; otherwise the " - "value -1 is returned and the global variable"); + print_text(h, "otherwise the value\\~\\-1 is returned" + " and the global variable"); PAIR_CLASS_INIT(&tag, "var"); t = print_otag(h, TAG_B, 1, &tag); Index: mdoc_term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v retrieving revision 1.272 retrieving revision 1.273 diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.272 -r1.273 --- mdoc_term.c +++ mdoc_term.c @@ -1167,33 +1167,42 @@ termp_rv_pre(DECL_ARGS) int nchild; term_newln(p); - term_word(p, "The"); nchild = n->nchild; - for (n = n->child; n; n = n->next) { - term_fontpush(p, TERMFONT_BOLD); - term_word(p, n->string); - term_fontpop(p); + if (nchild > 0) { + term_word(p, "The"); - p->flags |= TERMP_NOSPACE; - term_word(p, "()"); + for (n = n->child; n; n = n->next) { + term_fontpush(p, TERMFONT_BOLD); + term_word(p, n->string); + term_fontpop(p); - if (nchild > 2 && n->next) { p->flags |= TERMP_NOSPACE; - term_word(p, ","); - } + term_word(p, "()"); - if (n->next && NULL == n->next->next) - term_word(p, "and"); - } + if (n->next == NULL) + continue; - if (nchild > 1) - term_word(p, "functions return"); - else - term_word(p, "function returns"); + if (nchild > 2) { + p->flags |= TERMP_NOSPACE; + term_word(p, ","); + } + if (n->next->next == NULL) + term_word(p, "and"); + } + + if (nchild > 1) + 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, "the value 0 if successful; otherwise the " - "value -1 is returned and the global variable"); + term_word(p, "otherwise the value\\~\\-1 is returned" + " and the global variable"); term_fontpush(p, TERMFONT_UNDER); term_word(p, "errno"); @@ -1229,11 +1238,11 @@ termp_ex_pre(DECL_ARGS) } if (nchild > 1) - term_word(p, "utilities exit"); + term_word(p, "utilities exit\\~0"); else - term_word(p, "utility exits"); + term_word(p, "utility exits\\~0"); - term_word(p, "0 on success, and >0 if an error occurs."); + term_word(p, "on success, and\\~>0 if an error occurs."); p->flags |= TERMP_SENTENCE; return(0); Index: mandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v retrieving revision 1.142 retrieving revision 1.143 diff -Lmandoc.h -Lmandoc.h -u -p -r1.142 -r1.143 --- mandoc.h +++ mandoc.h @@ -92,6 +92,7 @@ enum mandocerr { MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged */ MANDOCERR_BL_LATETYPE, /* list type is not the first argument: arg */ MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ + MANDOCERR_EX_NONAME, /* missing name for .Ex, using "" */ MANDOCERR_IT_NOHEAD, /* empty head in list item: type */ MANDOCERR_IT_NOBODY, /* empty list item: type */ MANDOCERR_BF_NOFONT, /* missing font type, using \fR */ @@ -147,8 +148,8 @@ enum mandocerr { /* related to request and macro arguments */ MANDOCERR_NAMESC, /* escaped character not allowed in a name */ - MANDOCERR_NONAME, /* manual name not yet set */ MANDOCERR_ARGCOUNT, /* argument count wrong */ + MANDOCERR_NM_NONAME, /* missing manual name, using "" */ MANDOCERR_ST_BAD, /* unknown standard specifier: standard */ MANDOCERR_UNAME, /* uname(3) system call failed */ MANDOCERR_NUMERIC, /* request requires a numeric argument */ Index: read.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v retrieving revision 1.69 retrieving revision 1.70 diff -Lread.c -Lread.c -u -p -r1.69 -r1.70 --- read.c +++ read.c @@ -136,6 +136,7 @@ static const char * const mandocerrs[MAN "missing display type, using -ragged", "list type is not the first argument", "missing -width in -tag list, using 8n", + "missing name for .Ex, using \"\"", "empty head in list item", "empty list item", "missing font type, using \\fR", @@ -191,8 +192,8 @@ static const char * const mandocerrs[MAN /* related to request and macro arguments */ "escaped character not allowed in a name", - "manual name not yet set", "argument count wrong", + "missing manual name, using \"\"", "unknown standard specifier", "uname(3) system call failed", "request requires a numeric argument", -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv