summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-11-29 15:45:15 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-11-29 15:45:15 +0000
commitf723bb8c3ab45066352b08beae04fac690ddc6f3 (patch)
treee5c34ed8b8679cffe1dd401fb2fef40b98981923
parent3510deaa7145c250603c428001812dbacf4b2e18 (diff)
downloadmandoc-f723bb8c3ab45066352b08beae04fac690ddc6f3.tar.gz
mandoc-f723bb8c3ab45066352b08beae04fac690ddc6f3.tar.zst
mandoc-f723bb8c3ab45066352b08beae04fac690ddc6f3.zip
Remove left-over rsord[] in mdoc_actions.c.
Remove MANDOCERR_BADLIB (not used). Moved `St' handling from mdoc_action.c into mdoc_validate.c. Moved relevant MDOC_LITERAL macros (`Dl', `Bd' subtypes) from mdoc_action.c into mdoc_validate.c.
-rw-r--r--main.c5
-rw-r--r--mandoc.h5
-rw-r--r--mdoc_action.c93
-rw-r--r--mdoc_validate.c85
4 files changed, 82 insertions, 106 deletions
diff --git a/main.c b/main.c
index 4d94a3ca..e8031ae2 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.108 2010/10/11 15:46:19 kristaps Exp $ */
+/* $Id: main.c,v 1.109 2010/11/29 15:45:15 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -125,8 +125,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"out of order prologue",
"repeated prologue entry",
"list type must come first",
- "bad standard",
- "bad library",
"tab in non-literal context",
"bad escape sequence",
"unterminated quoted string",
@@ -145,6 +143,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"bad Boolean value",
"child violates parent syntax",
"bad AT&T symbol",
+ "bad standard",
"list type repeated",
"display type repeated",
"argument repeated",
diff --git a/mandoc.h b/mandoc.h
index 140e06d4..5a50f3fc 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.23 2010/10/11 15:46:19 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.24 2010/11/29 15:45:15 kristaps Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -51,8 +51,6 @@ enum mandocerr {
MANDOCERR_PROLOGOOO, /* out of order prologue */
MANDOCERR_PROLOGREP, /* repeated prologue entry */
MANDOCERR_LISTFIRST, /* list type must come first */
- MANDOCERR_BADSTANDARD, /* bad standard */
- MANDOCERR_BADLIB, /* bad library */
MANDOCERR_BADTAB, /* tab in non-literal context */
MANDOCERR_BADESCAPE, /* bad escape sequence */
MANDOCERR_BADQUOTE, /* unterminated quoted string */
@@ -71,6 +69,7 @@ enum mandocerr {
MANDOCERR_BADBOOL, /* bad Boolean value */
MANDOCERR_CHILD, /* child violates parent syntax */
MANDOCERR_BADATT, /* bad AT&T symbol */
+ MANDOCERR_BADSTANDARD, /* bad standard */
MANDOCERR_LISTREP, /* list type repeated */
MANDOCERR_DISPREP, /* display type repeated */
MANDOCERR_ARGVREP, /* argument repeated */
diff --git a/mdoc_action.c b/mdoc_action.c
index 6b800cd9..d7d03ea9 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.83 2010/11/29 14:56:43 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.84 2010/11/29 15:45:15 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -56,18 +56,13 @@ static int post_bl_head(POST_ARGS);
static int post_bl_tagwidth(POST_ARGS);
static int post_bl_width(POST_ARGS);
static int post_dd(POST_ARGS);
-static int post_display(POST_ARGS);
static int post_dt(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_os(POST_ARGS);
static int post_pa(POST_ARGS);
static int post_prol(POST_ARGS);
-static int post_st(POST_ARGS);
static int post_std(POST_ARGS);
-static int pre_bd(PRE_ARGS);
-static int pre_dl(PRE_ARGS);
-
static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Ap */
{ NULL, post_dd }, /* Dd */
@@ -77,8 +72,8 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Ss */
{ NULL, NULL }, /* Pp */
{ NULL, NULL }, /* D1 */
- { pre_dl, post_display }, /* Dl */
- { pre_bd, post_display }, /* Bd */
+ { NULL, NULL }, /* Dl */
+ { NULL, NULL }, /* Bd */
{ NULL, NULL }, /* Ed */
{ NULL, post_bl }, /* Bl */
{ NULL, NULL }, /* El */
@@ -106,7 +101,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Ot */
{ NULL, post_pa }, /* Pa */
{ NULL, post_std }, /* Rv */
- { NULL, post_st }, /* St */
+ { NULL, NULL }, /* St */
{ NULL, NULL }, /* Va */
{ NULL, NULL }, /* Vt */
{ NULL, NULL }, /* Xr */
@@ -193,25 +188,6 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Ta */
};
-#define RSORD_MAX 14
-
-static const enum mdoct rsord[RSORD_MAX] = {
- MDOC__A,
- MDOC__T,
- MDOC__B,
- MDOC__I,
- MDOC__J,
- MDOC__R,
- MDOC__N,
- MDOC__V,
- MDOC__P,
- MDOC__Q,
- MDOC__D,
- MDOC__O,
- MDOC__C,
- MDOC__U
-};
-
int
mdoc_action_pre(struct mdoc *m, struct mdoc_node *n)
@@ -331,27 +307,6 @@ post_nm(POST_ARGS)
}
/*
- * Substitute the value of `St' for the corresponding formatted string.
- * We're guaranteed that this exists (it's been verified during the
- * validation phase).
- */
-/* ARGSUSED */
-static int
-post_st(POST_ARGS)
-{
- const char *p;
-
- assert(MDOC_TEXT == n->child->type);
- p = mdoc_a2st(n->child->string);
- if (p != NULL) {
- free(n->child->string);
- n->child->string = mandoc_strdup(p);
- }
- return(1);
-}
-
-
-/*
* Parse out the contents of `Dt'. See in-line documentation for how we
* handle the various fields of this macro.
*/
@@ -763,43 +718,3 @@ post_prol(POST_ARGS)
m->flags |= MDOC_PBODY;
return(1);
}
-
-
-/*
- * Trigger a literal context.
- */
-static int
-pre_dl(PRE_ARGS)
-{
-
- if (MDOC_BODY == n->type)
- m->flags |= MDOC_LITERAL;
- return(1);
-}
-
-
-static int
-pre_bd(PRE_ARGS)
-{
-
- if (MDOC_BODY != n->type)
- return(1);
-
- assert(n->data.Bd);
- if (DISP_literal == n->data.Bd->type)
- m->flags |= MDOC_LITERAL;
- if (DISP_unfilled == n->data.Bd->type)
- m->flags |= MDOC_LITERAL;
-
- return(1);
-}
-
-
-static int
-post_display(POST_ARGS)
-{
-
- if (MDOC_BODY == n->type)
- m->flags &= ~MDOC_LITERAL;
- return(1);
-}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 14d2834e..d2ef944a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.127 2010/11/29 14:56:43 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.128 2010/11/29 15:45:15 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -86,6 +86,7 @@ static int post_bf(POST_ARGS);
static int post_bl(POST_ARGS);
static int post_bl_head(POST_ARGS);
static int post_defaults(POST_ARGS);
+static int post_literal(POST_ARGS);
static int post_eoln(POST_ARGS);
static int post_dt(POST_ARGS);
static int post_it(POST_ARGS);
@@ -105,6 +106,7 @@ static int pre_dd(PRE_ARGS);
static int pre_display(PRE_ARGS);
static int pre_dt(PRE_ARGS);
static int pre_it(PRE_ARGS);
+static int pre_literal(PRE_ARGS);
static int pre_os(PRE_ARGS);
static int pre_par(PRE_ARGS);
static int pre_rv(PRE_ARGS);
@@ -113,12 +115,14 @@ static int pre_ss(PRE_ARGS);
static v_post posts_an[] = { post_an, NULL };
static v_post posts_at[] = { post_at, post_defaults, NULL };
-static v_post posts_bd_bk[] = { hwarn_eq0, bwarn_ge1, NULL };
+static v_post posts_bd[] = { post_literal, hwarn_eq0, bwarn_ge1, NULL };
static v_post posts_bf[] = { hwarn_le1, post_bf, NULL };
+static v_post posts_bk[] = { hwarn_eq0, bwarn_ge1, NULL };
static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
static v_post posts_bool[] = { eerr_eq1, ebool, NULL };
static v_post posts_eoln[] = { post_eoln, NULL };
static v_post posts_defaults[] = { post_defaults, NULL };
+static v_post posts_dl[] = { post_literal, bwarn_ge1, herr_eq0, NULL };
static v_post posts_dt[] = { post_dt, NULL };
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
static v_post posts_it[] = { post_it, NULL };
@@ -137,9 +141,10 @@ static v_post posts_vt[] = { post_vt, NULL };
static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL };
static v_post posts_wtext[] = { ewarn_ge1, NULL };
static v_pre pres_an[] = { pre_an, NULL };
-static v_pre pres_bd[] = { pre_display, pre_bd, pre_par, NULL };
+static v_pre pres_bd[] = { pre_display, pre_bd, pre_literal, pre_par, NULL };
static v_pre pres_bl[] = { pre_bl, pre_par, NULL };
static v_pre pres_d1[] = { pre_display, NULL };
+static v_pre pres_dl[] = { pre_literal, pre_display, NULL };
static v_pre pres_dd[] = { pre_dd, NULL };
static v_pre pres_dt[] = { pre_dt, NULL };
static v_pre pres_er[] = { NULL, NULL };
@@ -161,8 +166,8 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ pres_ss, posts_ss }, /* Ss */
{ pres_pp, posts_notext }, /* Pp */
{ pres_d1, posts_wline }, /* D1 */
- { pres_d1, posts_wline }, /* Dl */
- { pres_bd, posts_bd_bk }, /* Bd */
+ { pres_dl, posts_dl }, /* Dl */
+ { pres_bd, posts_bd }, /* Bd */
{ NULL, NULL }, /* Ed */
{ pres_bl, posts_bl }, /* Bl */
{ NULL, NULL }, /* El */
@@ -253,7 +258,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Fc */
{ NULL, NULL }, /* Oo */
{ NULL, NULL }, /* Oc */
- { NULL, posts_bd_bk }, /* Bk */
+ { NULL, posts_bk }, /* Bk */
{ NULL, NULL }, /* Ek */
{ NULL, posts_eoln }, /* Bt */
{ NULL, NULL }, /* Hf */
@@ -582,6 +587,7 @@ pre_display(PRE_ARGS)
if (MDOC_BLOCK == node->type)
if (MDOC_Bd == node->tok)
break;
+
if (NULL == node)
return(1);
@@ -1157,6 +1163,23 @@ post_nm(POST_ARGS)
}
static int
+post_literal(POST_ARGS)
+{
+
+ /*
+ * The `Dl' (note "el" not "one") and `Bd' macros unset the
+ * MDOC_LITERAL flag as they leave. Note that `Bd' only sets
+ * this in literal mode, but it doesn't hurt to just switch it
+ * off in general since displays can't be nested.
+ */
+
+ if (MDOC_BODY == mdoc->last->type)
+ mdoc->last->flags &= ~MDOC_LITERAL;
+
+ return(1);
+}
+
+static int
post_defaults(POST_ARGS)
{
struct mdoc_node *nn;
@@ -1438,16 +1461,25 @@ post_root(POST_ARGS)
return(0);
}
-
static int
post_st(POST_ARGS)
{
+ const char *p;
- if (mdoc_a2st(mdoc->last->child->string))
- return(1);
- return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADSTANDARD));
-}
+ assert(MDOC_TEXT == mdoc->last->child->type);
+ p = mdoc_a2st(mdoc->last->child->string);
+
+ if (p == NULL) {
+ mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADSTANDARD);
+ mdoc_node_delete(mdoc, mdoc->last);
+ } else {
+ free(mdoc->last->child->string);
+ mdoc->last->child->string = mandoc_strdup(p);
+ }
+
+ return(1);
+}
static int
post_rs(POST_ARGS)
@@ -1715,3 +1747,34 @@ pre_par(PRE_ARGS)
mdoc_node_delete(mdoc, mdoc->last);
return(1);
}
+
+static int
+pre_literal(PRE_ARGS)
+{
+
+ if (MDOC_BODY != n->type)
+ return(1);
+
+ /*
+ * The `Dl' (note "el" not "one") and `Bd -literal' and `Bd
+ * -unfilled' macros set MDOC_LITERAL on entrance to the body.
+ */
+
+ switch (n->tok) {
+ case (MDOC_Dl):
+ mdoc->flags |= MDOC_LITERAL;
+ break;
+ case (MDOC_Bd):
+ assert(n->data.Bd);
+ if (DISP_literal == n->data.Bd->type)
+ mdoc->flags |= MDOC_LITERAL;
+ if (DISP_unfilled == n->data.Bd->type)
+ mdoc->flags |= MDOC_LITERAL;
+ break;
+ default:
+ abort();
+ /* NOTREACHED */
+ }
+
+ return(1);
+}