From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Remove left-over rsord[] in mdoc_actions.c.
Date: Mon, 29 Nov 2010 10:45:15 -0500 (EST) [thread overview]
Message-ID: <201011291545.oATFjFjO022741@krisdoz.my.domain> (raw)
Log Message:
-----------
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.
Modified Files:
--------------
mdocml:
main.c
mandoc.h
mdoc_action.c
mdoc_validate.c
Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.127 -r1.128
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -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, N
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)
@@ -1713,5 +1745,36 @@ pre_par(PRE_ARGS)
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNPAR);
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);
}
Index: mdoc_action.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_action.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -Lmdoc_action.c -Lmdoc_action.c -u -p -r1.83 -r1.84
--- mdoc_action.c
+++ mdoc_action.c
@@ -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
{ 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
{ 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
{ 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.
*/
@@ -761,45 +716,5 @@ post_prol(POST_ARGS)
mdoc_node_delete(m, n);
if (m->meta.title && m->meta.date && m->meta.os)
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);
}
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -Lmandoc.h -Lmandoc.h -u -p -r1.23 -r1.24
--- mandoc.h
+++ mandoc.h
@@ -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 */
Index: main.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -Lmain.c -Lmain.c -u -p -r1.108 -r1.109
--- main.c
+++ main.c
@@ -125,8 +125,6 @@ static const char * const mandocerrs[MAN
"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[MAN
"bad Boolean value",
"child violates parent syntax",
"bad AT&T symbol",
+ "bad standard",
"list type repeated",
"display type repeated",
"argument repeated",
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2010-11-29 15:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201011291545.oATFjFjO022741@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).