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 054265ea; for ; Fri, 6 Feb 2015 02:13:44 -0500 (EST) Date: Fri, 6 Feb 2015 02:13:44 -0500 (EST) Message-Id: <10278873734487109816.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: Delete the legacy generic warning type MANDOCERR_ARGCWARN, X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Delete the legacy generic warning type MANDOCERR_ARGCWARN, replacing the last instances by more specific warnings. Improved functionality, minus 50 lines of code. Modified Files: -------------- mdocml: man_validate.c mandoc.1 mandoc.h mdoc_macro.c mdoc_validate.c read.c Revision Data ------------- Index: read.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/read.c,v retrieving revision 1.123 retrieving revision 1.124 diff -Lread.c -Lread.c -u -p -r1.123 -r1.124 --- read.c +++ read.c @@ -136,8 +136,8 @@ static const char * const mandocerrs[MAN "skipping empty request", "conditional request controls empty scope", "skipping empty macro", + "empty block", "empty argument, using 0n", - "argument count wrong", "missing display type, using -ragged", "list type is not the first argument", "missing -width in -tag list, using 8n", Index: man_validate.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/man_validate.c,v retrieving revision 1.109 retrieving revision 1.110 diff -Lman_validate.c -Lman_validate.c -u -p -r1.109 -r1.110 --- man_validate.c +++ man_validate.c @@ -252,9 +252,9 @@ static void check_part(CHKARGS) { - if (MAN_BODY == n->type && 0 == n->nchild) - mandoc_msg(MANDOCERR_ARGCWARN, man->parse, n->line, - n->pos, "want children (have none)"); + if (n->type == MAN_BODY && n->child == NULL) + mandoc_msg(MANDOCERR_BLK_EMPTY, man->parse, + n->line, n->pos, man_macronames[n->tok]); } static void Index: mandoc.1 =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v retrieving revision 1.146 retrieving revision 1.147 diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.146 -r1.147 --- mandoc.1 +++ mandoc.1 @@ -994,8 +994,19 @@ except that it may control a following clause. .It Sy "skipping empty macro" .Pq mdoc -The indicated macro has no arguments or no body content -and hence no effect. +The indicated macro has no arguments and hence no effect. +.It Sy "empty block" +.Pq mdoc , man +A +.Ic \&Bd , +.Ic \&Bk , +.Ic \&Bl , +.Ic \&D1 , +.Ic \&Dl , +.Ic \&RS , +or +.Ic \&UR +block contains nothing in its body and will produce no output. .It Sy "empty argument, using 0n" .Pq mdoc The required width is missing after @@ -1005,12 +1016,6 @@ or .Fl offset or .Fl width. -.It Sy "argument count wrong" -.Pq mdoc , man -The indicated macro has too few or too many arguments. -The syntax tree will contain the wrong number of arguments as given. -Formatting behaviour depends on the specific macro in question. -Note that the same message may also occur as an ERROR, see below. .It Sy "missing display type, using -ragged" .Pq mdoc The Index: mdoc_macro.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_macro.c,v retrieving revision 1.178 retrieving revision 1.179 diff -Lmdoc_macro.c -Lmdoc_macro.c -u -p -r1.178 -r1.179 --- mdoc_macro.c +++ mdoc_macro.c @@ -1403,9 +1403,10 @@ in_line_eoln(MACRO_PROT_ARGS) rew_last(mdoc, mdoc->last->parent); } - if (buf[*pos] == '\0' && tok == MDOC_Fd) { + if (buf[*pos] == '\0' && + (tok == MDOC_Fd || mdoc_macronames[tok][0] == '%')) { mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, - line, ppos, "Fd"); + line, ppos, mdoc_macronames[tok]); return; } Index: mdoc_validate.c =================================================================== RCS file: /home/cvs/mdocml/mdocml/mdoc_validate.c,v retrieving revision 1.274 retrieving revision 1.275 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.274 -r1.275 --- mdoc_validate.c +++ mdoc_validate.c @@ -56,8 +56,6 @@ struct valids { v_post post; }; -static void check_count(struct mdoc *, enum mdoc_type, - enum check_ineq, int); static void check_text(struct mdoc *, int, int, char *); static void check_argv(struct mdoc *, struct mdoc_node *, struct mdoc_argv *); @@ -67,9 +65,6 @@ static enum mdoc_sec a2sec(const char *) static size_t macro2len(enum mdoct); static void rewrite_macro2len(char **); -static void ewarn_eq1(POST_ARGS); -static void ewarn_ge1(POST_ARGS); - static void post_an(POST_ARGS); static void post_at(POST_ARGS); static void post_bf(POST_ARGS); @@ -92,7 +87,6 @@ static void post_fn(POST_ARGS); static void post_fname(POST_ARGS); static void post_fo(POST_ARGS); static void post_hyph(POST_ARGS); -static void post_hyphtext(POST_ARGS); static void post_ignpar(POST_ARGS); static void post_it(POST_ARGS); static void post_lb(POST_ARGS); @@ -167,17 +161,17 @@ static const struct valids mdoc_valids[M { NULL, NULL }, /* Va */ { NULL, post_vt }, /* Vt */ { NULL, NULL }, /* Xr */ - { NULL, ewarn_ge1 }, /* %A */ - { NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */ - { NULL, ewarn_ge1 }, /* %D */ - { NULL, ewarn_ge1 }, /* %I */ - { NULL, ewarn_ge1 }, /* %J */ - { NULL, post_hyphtext }, /* %N */ - { NULL, post_hyphtext }, /* %O */ - { NULL, ewarn_ge1 }, /* %P */ - { NULL, post_hyphtext }, /* %R */ - { NULL, post_hyphtext }, /* %T */ /* FIXME: can be used outside Rs/Re. */ - { NULL, ewarn_ge1 }, /* %V */ + { NULL, NULL }, /* %A */ + { NULL, post_hyph }, /* %B */ /* FIXME: can be used outside Rs/Re. */ + { NULL, NULL }, /* %D */ + { NULL, NULL }, /* %I */ + { NULL, NULL }, /* %J */ + { NULL, post_hyph }, /* %N */ + { NULL, post_hyph }, /* %O */ + { NULL, NULL }, /* %P */ + { NULL, post_hyph }, /* %R */ + { NULL, post_hyph }, /* %T */ /* FIXME: can be used outside Rs/Re. */ + { NULL, NULL }, /* %V */ { NULL, NULL }, /* Ac */ { NULL, NULL }, /* Ao */ { NULL, NULL }, /* Aq */ @@ -239,14 +233,14 @@ static const struct valids mdoc_valids[M { NULL, NULL }, /* Brq */ { NULL, NULL }, /* Bro */ { NULL, NULL }, /* Brc */ - { NULL, ewarn_ge1 }, /* %C */ + { NULL, NULL }, /* %C */ { pre_obsolete, post_es }, /* Es */ { pre_obsolete, post_en }, /* En */ { NULL, NULL }, /* Dx */ - { NULL, ewarn_ge1 }, /* %Q */ + { NULL, NULL }, /* %Q */ { NULL, post_par }, /* br */ { NULL, post_par }, /* sp */ - { NULL, ewarn_eq1 }, /* %U */ + { NULL, NULL }, /* %U */ { NULL, NULL }, /* Ta */ { NULL, NULL }, /* ll */ }; @@ -366,53 +360,6 @@ mdoc_valid_post(struct mdoc *mdoc) } static void -check_count(struct mdoc *mdoc, enum mdoc_type type, - enum check_ineq ineq, int val) -{ - const char *p; - - if (mdoc->last->type != type) - return; - - switch (ineq) { - case CHECK_LT: - p = "less than "; - if (mdoc->last->nchild < val) - return; - break; - case CHECK_GT: - p = "more than "; - if (mdoc->last->nchild > val) - return; - break; - case CHECK_EQ: - p = ""; - if (val == mdoc->last->nchild) - return; - break; - default: - abort(); - /* NOTREACHED */ - } - - mandoc_vmsg(MANDOCERR_ARGCWARN, mdoc->parse, mdoc->last->line, - mdoc->last->pos, "want %s%d children (have %d)", - p, val, mdoc->last->nchild); -} - -static void -ewarn_eq1(POST_ARGS) -{ - check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); -} - -static void -ewarn_ge1(POST_ARGS) -{ - check_count(mdoc, MDOC_ELEM, CHECK_GT, 0); -} - -static void check_args(struct mdoc *mdoc, struct mdoc_node *n) { int i; @@ -920,7 +867,6 @@ post_lb(POST_ARGS) const char *stdlibname; char *libname; - check_count(mdoc, MDOC_ELEM, CHECK_EQ, 1); n = mdoc->last->child; assert(MDOC_TEXT == n->type); @@ -1089,7 +1035,7 @@ post_d1(POST_ARGS) return; if (n->child == NULL) - mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse, n->line, n->pos, "D1"); post_hyph(mdoc); @@ -1106,7 +1052,7 @@ post_literal(POST_ARGS) return; if (n->child == NULL) - mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse, n->line, n->pos, mdoc_macronames[n->tok]); if (n->tok == MDOC_Bd && @@ -1513,7 +1459,7 @@ post_bl(POST_ARGS) nchild = nbody->child; if (nchild == NULL) { - mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse, nbody->line, nbody->pos, "Bl"); return; } @@ -1581,7 +1527,7 @@ post_bk(POST_ARGS) n = mdoc->last; if (n->type == MDOC_BLOCK && n->body->child == NULL) { - mandoc_msg(MANDOCERR_MACRO_EMPTY, + mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse, n->line, n->pos, "Bk"); mdoc_node_delete(mdoc, n); } @@ -1790,14 +1736,6 @@ post_hyph(POST_ARGS) isalpha((unsigned char)cp[1])) *cp = ASCII_HYPH; } -} - -static void -post_hyphtext(POST_ARGS) -{ - - ewarn_ge1(mdoc); - post_hyph(mdoc); } static void Index: mandoc.h =================================================================== RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v retrieving revision 1.197 retrieving revision 1.198 diff -Lmandoc.h -Lmandoc.h -u -p -r1.197 -r1.198 --- mandoc.h +++ mandoc.h @@ -92,8 +92,8 @@ enum mandocerr { MANDOCERR_REQ_EMPTY, /* skipping empty request: request */ MANDOCERR_COND_EMPTY, /* conditional request controls empty scope */ MANDOCERR_MACRO_EMPTY, /* skipping empty macro: macro */ + MANDOCERR_BLK_EMPTY, /* empty block: macro */ MANDOCERR_ARG_EMPTY, /* empty argument, using 0n: macro arg */ - MANDOCERR_ARGCWARN, /* argument count wrong */ MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged: Bd */ MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */ MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv