diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-02-04 18:03:29 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-02-04 18:03:29 +0000 |
commit | 2abdea8dd24252d6e41ca4a6954edff1fe8d3454 (patch) | |
tree | 587ff7f575889219da675474554719336b204a9e | |
parent | 203bd5d9c4f0078a07e5c626d95626aaeb40d522 (diff) |
discard .Rs head arguments and improve .Rs diagnostics
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/Makefile | 11 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/args.in | 18 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/args.out_ascii | 13 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/args.out_lint | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/empty.in | 16 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/empty.out_ascii | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Rs/empty.out_lint | 2 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 13 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 70 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 3 |
11 files changed, 120 insertions, 45 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Rs/Makefile b/regress/usr.bin/mandoc/mdoc/Rs/Makefile index 50a32b500be..45fd8cb2f1a 100644 --- a/regress/usr.bin/mandoc/mdoc/Rs/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Rs/Makefile @@ -1,6 +1,11 @@ -# $OpenBSD: Makefile,v 1.6 2014/07/07 16:12:06 schwarze Exp $ +# $OpenBSD: Makefile,v 1.7 2015/02/04 18:03:28 schwarze Exp $ -REGRESS_TARGETS = allch break three_authors -LINT_TARGETS = allch +REGRESS_TARGETS = allch args break empty three_authors +LINT_TARGETS = allch args empty + +# groff-1.22.3 defect: +# - arguments after .Rs cause the macro to be ignored + +SKIP_GROFF = args .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/Rs/args.in b/regress/usr.bin/mandoc/mdoc/Rs/args.in new file mode 100644 index 00000000000..2f292013358 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Rs/args.in @@ -0,0 +1,18 @@ +.Dd February 4, 2015 +.Dt RS-ARGS 1 +.Os OpenBSD +.Sh NAME +.Nm Rs-args +.Nd arguments on a reference block header line +.Sh SEE ALSO +initial text +.Rs bogus +.%A author name +.%B book title +.Re +middle text +.Rs Sy bogus +.%A author name +.%B book title +.Re +final text diff --git a/regress/usr.bin/mandoc/mdoc/Rs/args.out_ascii b/regress/usr.bin/mandoc/mdoc/Rs/args.out_ascii new file mode 100644 index 00000000000..30cb3c86405 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Rs/args.out_ascii @@ -0,0 +1,13 @@ +RS-ARGS(1) General Commands Manual RS-ARGS(1) + +NNAAMMEE + RRss--aarrggss - arguments on a reference block header line + +SSEEEE AALLSSOO + initial text + + author name, _b_o_o_k _t_i_t_l_e. middle text + + author name, _b_o_o_k _t_i_t_l_e. final text + +OpenBSD February 4, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Rs/args.out_lint b/regress/usr.bin/mandoc/mdoc/Rs/args.out_lint new file mode 100644 index 00000000000..f5bccd15323 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Rs/args.out_lint @@ -0,0 +1,2 @@ +mandoc: args.in:9:5: ERROR: skipping all arguments: Rs bogus +mandoc: args.in:14:5: ERROR: skipping all arguments: Rs Sy diff --git a/regress/usr.bin/mandoc/mdoc/Rs/empty.in b/regress/usr.bin/mandoc/mdoc/Rs/empty.in new file mode 100644 index 00000000000..36d806636cb --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Rs/empty.in @@ -0,0 +1,16 @@ +.Dd February 4, 2015 +.Dt RS-EMPTY 1 +.Os OpenBSD +.Sh NAME +.Nm Rs-empty +.Nd empty reference blocks +.Sh DESCRIPTION +initial text +.Rs +.Re +final text +.Sh SEE ALSO +initial text +.Rs +.Re +final text diff --git a/regress/usr.bin/mandoc/mdoc/Rs/empty.out_ascii b/regress/usr.bin/mandoc/mdoc/Rs/empty.out_ascii new file mode 100644 index 00000000000..9dad8f6a0e9 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Rs/empty.out_ascii @@ -0,0 +1,14 @@ +RS-EMPTY(1) General Commands Manual RS-EMPTY(1) + +NNAAMMEE + RRss--eemmppttyy - empty reference blocks + +DDEESSCCRRIIPPTTIIOONN + initial text final text + +SSEEEE AALLSSOO + initial text + + final text + +OpenBSD February 4, 2015 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Rs/empty.out_lint b/regress/usr.bin/mandoc/mdoc/Rs/empty.out_lint new file mode 100644 index 00000000000..afaf9a102e4 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Rs/empty.out_lint @@ -0,0 +1,2 @@ +mandoc: empty.in:9:2: WARNING: empty reference block: Rs +mandoc: empty.in:14:2: WARNING: empty reference block: Rs diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index cd752d11127..a34095a48a2 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.137 2015/02/04 16:38:31 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.138 2015/02/04 18:03:28 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -103,6 +103,7 @@ enum mandocerr { MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */ MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */ MANDOCERR_PF_SKIP, /* nothing follows prefix: Pf arg */ + MANDOCERR_RS_EMPTY, /* empty reference block: Rs */ MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ MANDOCERR_EQN_NOBOX, /* missing eqn box, using "": op */ diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 3d91845b321..b4e81d68608 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.128 2015/02/03 18:19:27 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.129 2015/02/04 18:03:28 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -1025,8 +1025,6 @@ blk_full(MACRO_PROT_ARGS) la = *pos; lac = ac; ac = mdoc_args(mdoc, line, pos, buf, tok, &p); - if (ac == ARGS_PUNCT) - break; if (ac == ARGS_EOLN) { if (lac != ARGS_PPHRASE && lac != ARGS_PHRASE) break; @@ -1042,6 +1040,13 @@ blk_full(MACRO_PROT_ARGS) body = mdoc_body_alloc(mdoc, line, ppos, tok); break; } + if (tok == MDOC_Rs) { + mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, + line, la, "Rs %s", buf + la); + break; + } + if (ac == ARGS_PUNCT) + break; /* * Emit leading punctuation (i.e., punctuation before @@ -1098,7 +1103,7 @@ blk_full(MACRO_PROT_ARGS) return; if (head == NULL) head = mdoc_head_alloc(mdoc, line, ppos, tok); - if (nl) + if (nl && tok != MDOC_Rs) append_delims(mdoc, line, pos, buf); if (body != NULL) goto out; diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 772969ce183..6873ab49870 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.183 2015/02/04 16:38:31 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.184 2015/02/04 18:03:28 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -1649,19 +1649,17 @@ post_st(POST_ARGS) static void post_rs(POST_ARGS) { - struct mdoc_node *nn, *next, *prev; + struct mdoc_node *np, *nch, *next, *prev; int i, j; - switch (mdoc->last->type) { - case MDOC_HEAD: - check_count(mdoc, MDOC_HEAD, CHECK_EQ, 0); - return; - case MDOC_BODY: - if (mdoc->last->child) - break; - check_count(mdoc, MDOC_BODY, CHECK_GT, 0); + np = mdoc->last; + + if (np->type != MDOC_BODY) return; - default: + + if (np->child == NULL) { + mandoc_msg(MANDOCERR_RS_EMPTY, mdoc->parse, + np->line, np->pos, "Rs"); return; } @@ -1672,38 +1670,38 @@ post_rs(POST_ARGS) */ next = NULL; - for (nn = mdoc->last->child->next; nn; nn = next) { - /* Determine order of `nn'. */ + for (nch = np->child->next; nch != NULL; nch = next) { + /* Determine order number of this child. */ for (i = 0; i < RSORD_MAX; i++) - if (rsord[i] == nn->tok) + if (rsord[i] == nch->tok) break; if (i == RSORD_MAX) { mandoc_msg(MANDOCERR_RS_BAD, - mdoc->parse, nn->line, nn->pos, - mdoc_macronames[nn->tok]); + mdoc->parse, nch->line, nch->pos, + mdoc_macronames[nch->tok]); i = -1; - } else if (MDOC__J == nn->tok || MDOC__B == nn->tok) - mdoc->last->norm->Rs.quote_T++; + } else if (nch->tok == MDOC__J || nch->tok == MDOC__B) + np->norm->Rs.quote_T++; /* - * Remove `nn' from the chain. This somewhat + * Remove this child from the chain. This somewhat * repeats mdoc_node_unlink(), but since we're * just re-ordering, there's no need for the * full unlink process. */ - if (NULL != (next = nn->next)) - next->prev = nn->prev; + if ((next = nch->next) != NULL) + next->prev = nch->prev; - if (NULL != (prev = nn->prev)) - prev->next = nn->next; + if ((prev = nch->prev) != NULL) + prev->next = nch->next; - nn->prev = nn->next = NULL; + nch->prev = nch->next = NULL; /* * Scan back until we reach a node that's - * ordered before `nn'. + * to be ordered before this child. */ for ( ; prev ; prev = prev->prev) { @@ -1719,21 +1717,21 @@ post_rs(POST_ARGS) } /* - * Set `nn' back into its correct place in front - * of the `prev' node. + * Set this child back into its correct place + * in front of the `prev' node. */ - nn->prev = prev; + nch->prev = prev; - if (prev) { - if (prev->next) - prev->next->prev = nn; - nn->next = prev->next; - prev->next = nn; + if (prev == NULL) { + np->child->prev = nch; + nch->next = np->child; + np->child = nch; } else { - mdoc->last->child->prev = nn; - nn->next = mdoc->last->child; - mdoc->last->child = nn; + if (prev->next) + prev->next->prev = nch; + nch->next = prev->next; + prev->next = nch; } } } diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 9282797b95e..d70803bebd2 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.96 2015/02/04 16:38:31 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.97 2015/02/04 18:03:28 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -142,6 +142,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "missing font type, using \\fR", "unknown font type, using \\fR", "nothing follows prefix", + "empty reference block", "missing -std argument, adding it", "missing eqn box, using \"\"", |