aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-07-07 16:12:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-07-07 16:12:20 +0000
commita70595124021b19985ca649bfe1c53c913a5e414 (patch)
treebc17f6625aac057dc2cbbd3d99a9499164c4679e /mdoc_validate.c
parentbf71220a9f906bbab505a3c280f4f04c52f383ff (diff)
downloadmandoc-a70595124021b19985ca649bfe1c53c913a5e414.tar.gz
mandoc-a70595124021b19985ca649bfe1c53c913a5e414.tar.zst
mandoc-a70595124021b19985ca649bfe1c53c913a5e414.zip
no need to delete any content from .Rs blocks,
and downgrade the related message from ERROR to WARNING
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c47
1 files changed, 12 insertions, 35 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 54d5c7a2..9e52365a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.229 2014/07/06 19:09:00 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.230 2014/07/07 16:12:20 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1768,42 +1768,9 @@ post_rs(POST_ARGS)
}
/*
- * Make sure only certain types of nodes are allowed within the
- * the `Rs' body. Delete offending nodes and raise a warning.
- * Do this before re-ordering for the sake of clarity.
- */
-
- next = NULL;
- for (nn = mdoc->last->child; nn; nn = next) {
- for (i = 0; i < RSORD_MAX; i++)
- if (nn->tok == rsord[i])
- break;
-
- if (i < RSORD_MAX) {
- if (MDOC__J == rsord[i] || MDOC__B == rsord[i])
- mdoc->last->norm->Rs.quote_T++;
- next = nn->next;
- continue;
- }
-
- next = nn->next;
- mandoc_msg(MANDOCERR_RS_SKIP, mdoc->parse,
- nn->line, nn->pos, mdoc_macronames[nn->tok]);
- mdoc_node_delete(mdoc, nn);
- }
-
- /*
- * Nothing to sort if only invalid nodes were found
- * inside the `Rs' body.
- */
-
- if (NULL == mdoc->last->child)
- return(1);
-
- /*
* The full `Rs' block needs special handling to order the
* sub-elements according to `rsord'. Pick through each element
- * and correctly order it. This is a insertion sort.
+ * and correctly order it. This is an insertion sort.
*/
next = NULL;
@@ -1813,6 +1780,14 @@ post_rs(POST_ARGS)
if (rsord[i] == nn->tok)
break;
+ if (i == RSORD_MAX) {
+ mandoc_msg(MANDOCERR_RS_BAD,
+ mdoc->parse, nn->line, nn->pos,
+ mdoc_macronames[nn->tok]);
+ i = -1;
+ } else if (MDOC__J == nn->tok || MDOC__B == nn->tok)
+ mdoc->last->norm->Rs.quote_T++;
+
/*
* Remove `nn' from the chain. This somewhat
* repeats mdoc_node_unlink(), but since we're
@@ -1838,6 +1813,8 @@ post_rs(POST_ARGS)
for (j = 0; j < RSORD_MAX; j++)
if (rsord[j] == prev->tok)
break;
+ if (j == RSORD_MAX)
+ j = -1;
if (j <= i)
break;