summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-24 16:16:45 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-24 16:16:45 +0000
commit67f1948113ec6a04bab25fb2e4c0a6914ddc6c14 (patch)
treed21937a396c15f699ae0dfaeb53d43ac673946fb
parent0a74490582c1c8f34566e9e4b5b980d88faa8da8 (diff)
downloadmandoc-67f1948113ec6a04bab25fb2e4c0a6914ddc6c14.tar.gz
Raft of mdocterm callbacks in place.
Fixed Fo/Fc handling in validate/mdocterm.
-rw-r--r--macro.c3
-rw-r--r--term.c99
-rw-r--r--term.h7
-rw-r--r--validate.c14
4 files changed, 100 insertions, 23 deletions
diff --git a/macro.c b/macro.c
index b05962fb..b1f25505 100644
--- a/macro.c
+++ b/macro.c
@@ -170,8 +170,7 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = {
{ macro_constant_scoped, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Xo */
/* XXX - .Fo supposed to be (but isn't) callable. */
{ macro_scoped, MDOC_EXPLICIT }, /* Fo */
- /* XXX - .Fc supposed to be (but isn't) callable. */
- { macro_scoped_close, MDOC_EXPLICIT }, /* Fc */
+ { macro_scoped_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Fc */
{ macro_constant_scoped, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Oo */
{ macro_scoped_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Oc */
{ macro_scoped, MDOC_EXPLICIT }, /* Bk */
diff --git a/term.c b/term.c
index 4aabbc6c..e71d297a 100644
--- a/term.c
+++ b/term.c
@@ -113,6 +113,7 @@ DECL_PREPOST(termp_fa);
DECL_PREPOST(termp_fd);
DECL_PREPOST(termp_fl);
DECL_PREPOST(termp_fn);
+DECL_PREPOST(termp_fo);
DECL_PREPOST(termp_ft);
DECL_PREPOST(termp_ic);
DECL_PREPOST(termp_in);
@@ -134,6 +135,7 @@ DECL_PRE(termp_at);
DECL_PRE(termp_bsx);
DECL_PRE(termp_bx);
DECL_PRE(termp_ex);
+DECL_PRE(termp_fx);
DECL_PRE(termp_nd);
DECL_PRE(termp_ns);
DECL_PRE(termp_nx);
@@ -142,6 +144,7 @@ DECL_PRE(termp_pp);
DECL_PRE(termp_rv);
DECL_PRE(termp_st);
DECL_PRE(termp_ud);
+DECL_PRE(termp_ux);
DECL_PRE(termp_xr);
DECL_POST(termp_bl);
@@ -217,7 +220,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Ef */
{ termp_em_pre, termp_em_post }, /* Em */
{ NULL, NULL }, /* Eo */
- { NULL, NULL }, /* Fx */
+ { termp_fx_pre, NULL }, /* Fx */
{ NULL, NULL }, /* Ms */
{ NULL, NULL }, /* No */
{ termp_ns_pre, NULL }, /* Ns */
@@ -228,7 +231,7 @@ const struct termact __termacts[MDOC_MAX] = {
{ termp_pq_pre, termp_pq_post }, /* Po */
{ termp_pq_pre, termp_pq_post }, /* Pq */
{ NULL, NULL }, /* Qc */
- { NULL, NULL }, /* Ql */
+ { termp_sq_pre, termp_sq_post }, /* Ql */
{ termp_qq_pre, termp_qq_post }, /* Qo */
{ termp_qq_pre, termp_qq_post }, /* Qq */
{ NULL, NULL }, /* Re */
@@ -240,12 +243,12 @@ const struct termact __termacts[MDOC_MAX] = {
{ termp_sx_pre, termp_sx_post }, /* Sx */
{ NULL, NULL }, /* Sy */
{ NULL, NULL }, /* Tn */
- { NULL, NULL }, /* Ux */
+ { termp_ux_pre, NULL }, /* Ux */
{ NULL, NULL }, /* Xc */
{ NULL, NULL }, /* Xo */
- { NULL, NULL }, /* Fo */
+ { termp_fo_pre, termp_fo_post }, /* Fo */
{ NULL, NULL }, /* Fc */
- { NULL, NULL }, /* Oo */
+ { termp_op_pre, termp_op_post }, /* Oo */
{ NULL, NULL }, /* Oc */
{ NULL, NULL }, /* Bk */
{ NULL, NULL }, /* Ek */
@@ -897,7 +900,6 @@ termp_fn_pre(DECL_ARGS)
word(p, node->child->data.text.string);
p->flags &= ~ttypes[TTYPE_FUNC_NAME];
- p->flags |= TERMP_NOSPACE;
word(p, "(");
p->flags |= TERMP_NOSPACE;
@@ -906,11 +908,10 @@ termp_fn_pre(DECL_ARGS)
p->flags |= ttypes[TTYPE_FUNC_ARG];
word(p, n->data.text.string);
p->flags &= ~ttypes[TTYPE_FUNC_ARG];
- if ((n->next))
+ if (n->next)
word(p, ",");
}
- p->flags |= TERMP_NOSPACE;
word(p, ")");
if (SEC_SYNOPSIS == node->sec)
@@ -954,9 +955,28 @@ termp_sx_post(DECL_ARGS)
static int
termp_fa_pre(DECL_ARGS)
{
+ struct mdoc_node *n;
- p->flags |= ttypes[TTYPE_FUNC_ARG];
- return(1);
+ if (node->parent->tok != MDOC_Fo) {
+ p->flags |= ttypes[TTYPE_FUNC_ARG];
+ return(1);
+ }
+
+ for (n = node->child; n; n = n->next) {
+ assert(MDOC_TEXT == n->type);
+
+ p->flags |= ttypes[TTYPE_FUNC_ARG];
+ word(p, n->data.text.string);
+ p->flags &= ~ttypes[TTYPE_FUNC_ARG];
+
+ if (n->next)
+ word(p, ",");
+ }
+
+ if (node->next && node->next->tok == MDOC_Fa)
+ word(p, ",");
+
+ return(0);
}
@@ -1110,6 +1130,26 @@ termp_ox_pre(DECL_ARGS)
/* ARGSUSED */
static int
+termp_ux_pre(DECL_ARGS)
+{
+
+ word(p, "UNIX");
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
+termp_fx_pre(DECL_ARGS)
+{
+
+ word(p, "FreeBSD");
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
termp_nx_pre(DECL_ARGS)
{
@@ -1350,7 +1390,6 @@ termp_bq_post(DECL_ARGS)
if (MDOC_BODY != node->type)
return;
- p->flags |= TERMP_NOSPACE;
word(p, "]");
}
@@ -1375,8 +1414,44 @@ termp_pq_post(DECL_ARGS)
if (MDOC_BODY != node->type)
return;
- p->flags |= TERMP_NOSPACE;
word(p, ")");
}
+/* ARGSUSED */
+static int
+termp_fo_pre(DECL_ARGS)
+{
+ const struct mdoc_node *n;
+
+ if (MDOC_BODY == node->type) {
+ word(p, "(");
+ p->flags |= TERMP_NOSPACE;
+ return(1);
+ } else if (MDOC_HEAD != node->type)
+ return(1);
+
+ p->flags |= ttypes[TTYPE_FUNC_NAME];
+ for (n = node->child; n; n = n->next) {
+ assert(MDOC_TEXT == n->type);
+ word(p, n->data.text.string);
+ }
+ p->flags &= ~ttypes[TTYPE_FUNC_NAME];
+
+ return(0);
+}
+
+
+/* ARGSUSED */
+static void
+termp_fo_post(DECL_ARGS)
+{
+
+ if (MDOC_BODY != node->type)
+ return;
+ word(p, ")");
+ word(p, ";");
+ newln(p);
+}
+
+
diff --git a/term.h b/term.h
index b7fb3cc0..622c355a 100644
--- a/term.h
+++ b/term.h
@@ -49,9 +49,6 @@ struct termact {
const struct mdoc_node *);
};
-void termprint(const struct mdoc_node *,
- const struct mdoc_meta *);
-
void newln(struct termp *);
void vspace(struct termp *);
void word(struct termp *, const char *);
@@ -59,6 +56,10 @@ void flushln(struct termp *);
void transcode(struct termp *,
const char *, size_t);
+void subtree(struct termp *,
+ const struct mdoc_meta *,
+ const struct mdoc_node *);
+
const struct termact *termacts;
__END_DECLS
diff --git a/validate.c b/validate.c
index 336275ac..06307d22 100644
--- a/validate.c
+++ b/validate.c
@@ -99,6 +99,7 @@ static int eerr_ge1(POST_ARGS);
static int ewarn_eq0(POST_ARGS);
static int ewarn_eq1(POST_ARGS);
static int bwarn_ge1(POST_ARGS);
+static int hwarn_eq1(POST_ARGS);
static int ewarn_ge1(POST_ARGS);
static int ebool(POST_ARGS);
@@ -154,7 +155,7 @@ static v_post posts_xr[] = { eerr_ge1, eerr_le2, post_xr, NULL };
static v_post posts_nm[] = { post_nm, NULL };
static v_post posts_bf[] = { herr_le1, post_bf, NULL };
static v_post posts_rs[] = { herr_eq0, bwarn_ge1, NULL };
-static v_post posts_fo[] = { bwarn_ge1, NULL };
+static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
static v_post posts_bk[] = { herr_eq0, bwarn_ge1, NULL };
static v_post posts_fd[] = { ewarn_ge1, post_fd, NULL };
@@ -355,8 +356,8 @@ warn_count(struct mdoc *m, const char *k,
{
return(mdoc_warn(m, WARN_SYNTAX,
- "suggests %s %d %s (has %d)",
- v, want, k, has));
+ "suggests %s %s %d (has %d)",
+ v, k, want, has));
}
@@ -365,8 +366,8 @@ err_count(struct mdoc *m, const char *k,
int want, const char *v, int has)
{
- return(mdoc_err(m, "requires %s %d %s (has %d)",
- v, want, k, has));
+ return(mdoc_err(m, "requires %s %s %d (has %d)",
+ v, k, want, has));
}
@@ -422,7 +423,7 @@ h##lvl##_##name(POST_ARGS) \
{ \
if (MDOC_HEAD != mdoc->last->type) \
return(1); \
- return(func(mdoc, "multiline parameters", (num))); \
+ return(func(mdoc, "line parameters", (num))); \
}
@@ -443,6 +444,7 @@ CHECK_ELEM_DEFN(ge1, err, err_child_gt, 0) /* eerr_ge1() */
CHECK_HEAD_DEFN(eq0, err, err_child_eq, 0) /* herr_eq0() */
CHECK_HEAD_DEFN(le1, err, err_child_lt, 2) /* herr_le1() */
CHECK_HEAD_DEFN(ge1, err, err_child_gt, 0) /* herr_ge1() */
+CHECK_HEAD_DEFN(eq1, warn, warn_child_eq, 1) /* hwarn_eq1() */
static int