From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 180d97de; for ; Thu, 5 Feb 2015 22:39:15 -0500 (EST) Date: Thu, 5 Feb 2015 22:39:15 -0500 (EST) Message-Id: <6961133144194525127.enqueue@fantadrom.bsd.lv> 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: better handle .Fo and .Fd without argument better handle .Fo X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- better handle .Fo and .Fd without argument better handle .Fo with more than one argument Modified Files: -------------- mdocml: mandoc.1 mandoc.h mdoc_macro.c mdoc_man.c mdoc_validate.c read.c Revision Data ------------- Index: mdoc_macro.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_macro.c,v retrieving revision 1.177 retrieving revision 1.178 diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.177 -r1.178 --- mdoc_macro.c +++ mdoc_macro.c @@ -1403,6 +1403,12 @@ in_line_eoln(MACRO_PROT_ARGS) rew_last(mdoc, mdoc->last->parent); } + if (buf[*pos] == '\0' && tok == MDOC_Fd) { + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + line, ppos, "Fd"); + return; + } + mdoc_argv(mdoc, line, tok, &arg, pos, buf); mdoc_elem_alloc(mdoc, line, ppos, tok, arg); if (parse_rest(mdoc, tok, line, pos, buf)) Index: mdoc_validate.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v retrieving revision 1.273 retrieving revision 1.274 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.273 -r1.274 --- mdoc_validate.c +++ mdoc_validate.c @@ -67,7 +67,6 @@ static enum mdoc_sec a2sec(const char *) static size_t macro2len(enum mdoct); static void rewrite_macro2len(char **); -static void bwarn_ge1(POST_ARGS); static void ewarn_eq1(POST_ARGS); static void ewarn_ge1(POST_ARGS); @@ -151,7 +150,7 @@ static const struct valids mdoc_valids[M { NULL, NULL }, /* Ev */ { pre_std, post_ex }, /* Ex */ { NULL, post_fa }, /* Fa */ - { NULL, ewarn_ge1 }, /* Fd */ + { NULL, NULL }, /* Fd */ { NULL, NULL }, /* Fl */ { NULL, post_fn }, /* Fn */ { NULL, NULL }, /* Ft */ @@ -402,12 +401,6 @@ check_count(struct mdoc *mdoc, enum mdoc } static void -bwarn_ge1(POST_ARGS) -{ - check_count(mdoc, MDOC_BODY, CHECK_GT, 0); -} - -static void ewarn_eq1(POST_ARGS) { check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); @@ -980,11 +973,27 @@ post_fn(POST_ARGS) static void post_fo(POST_ARGS) { + const struct mdoc_node *n; + + n = mdoc->last; - check_count(mdoc, MDOC_HEAD, CHECK_EQ, 1); - bwarn_ge1(mdoc); - if (mdoc->last->type == MDOC_HEAD && mdoc->last->nchild) - post_fname(mdoc); + if (n->type != MDOC_HEAD) + return; + + if (n->child == NULL) { + mandoc_msg(MANDOCERR_FO_NOHEAD, mdoc->parse, + n->line, n->pos, "Fo"); + return; + } + if (n->child != n->last) { + mandoc_vmsg(MANDOCERR_ARG_EXCESS, mdoc->parse, + n->child->next->line, n->child->next->pos, + "Fo ... %s", n->child->next->string); + while (n->child != n->last) + mdoc_node_delete(mdoc, n->last); + } + + post_fname(mdoc); } static void Index: read.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/read.c,v retrieving revision 1.122 retrieving revision 1.123 diff -Lread.c -Lread.c -u -p -r1.122 -r1.123 --- read.c +++ read.c @@ -142,6 +142,7 @@ static const char * const mandocerrs[MAN "list type is not the first argument", "missing -width in -tag list, using 8n", "missing utility name, using \"\"", + "missing function name, using \"\"", "empty head in list item", "empty list item", "missing font type, using \\fR", Index: mandoc.1 =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v retrieving revision 1.145 retrieving revision 1.146 diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.145 -r1.146 --- mandoc.1 +++ mandoc.1 @@ -1042,6 +1042,12 @@ The macro is called without an argument before .Ic \&Nm has first been called with an argument. +.It Sy "missing function name, using \(dq\(dq" +.Pq mdoc +The +.Ic \&Fo +macro is called without an argument. +No function name is printed. .It Sy "empty head in list item" .Pq mdoc In a @@ -1637,6 +1643,8 @@ macro is invoked with another argument a .Fl split or .Fl nosplit , +.Ic \&Fo +is invoked with more than one argument, .Ic \&Bd , .Ic \&Bk , or Index: mdoc_man.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v retrieving revision 1.84 retrieving revision 1.85 diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.84 -r1.85 --- mdoc_man.c +++ mdoc_man.c @@ -1284,12 +1284,14 @@ pre_fo(DECL_ARGS) pre_syn(n); break; case MDOC_HEAD: + if (n->child == NULL) + return(0); if (MDOC_SYNPRETTY & n->flags) print_block(".HP 4n", MMAN_nl); font_push('B'); break; case MDOC_BODY: - outflags &= ~MMAN_spc; + outflags &= ~(MMAN_spc | MMAN_nl); print_word("("); outflags &= ~MMAN_spc; break; @@ -1305,7 +1307,8 @@ post_fo(DECL_ARGS) switch (n->type) { case MDOC_HEAD: - font_pop(); + if (n->child != NULL) + font_pop(); break; case MDOC_BODY: post_fn(meta, n); Index: mandoc.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v retrieving revision 1.196 retrieving revision 1.197 diff -Lmandoc.h -Lmandoc.h -u -p -r1.196 -r1.197 --- mandoc.h +++ mandoc.h @@ -98,6 +98,7 @@ enum mandocerr { MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */ MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ MANDOCERR_EX_NONAME, /* missing utility name, using "": Ex */ + MANDOCERR_FO_NOHEAD, /* missing function name, using "": Fo */ MANDOCERR_IT_NOHEAD, /* empty head in list item: Bl -type It */ MANDOCERR_IT_NOBODY, /* empty list item: Bl -type It */ MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */ -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv