summaryrefslogtreecommitdiffstats
path: root/action.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-17 16:47:02 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-17 16:47:02 +0000
commit0b5cea59a912aaf566e5d1258761bd53beaf6a35 (patch)
tree1d2a1351289794a1d8982befa66a2cbc08193af2 /action.c
parentc6e35c35ae3f9fc589c153d500eb8d77813f2780 (diff)
downloadmandoc-0b5cea59a912aaf566e5d1258761bd53beaf6a35.tar.gz
Added tests to makefile.
Diffstat (limited to 'action.c')
-rw-r--r--action.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/action.c b/action.c
index c5c84c27..1b10dcd3 100644
--- a/action.c
+++ b/action.c
@@ -27,6 +27,7 @@ struct actions {
int (*post)(struct mdoc *);
};
+/* Per-macro action routines. */
static int post_sh(struct mdoc *);
static int post_os(struct mdoc *);
@@ -34,6 +35,8 @@ static int post_dt(struct mdoc *);
static int post_dd(struct mdoc *);
static int post_nm(struct mdoc *);
+/* Array of macro action routines. */
+
const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL }, /* \" */
{ post_dd }, /* Dd */
@@ -155,12 +158,12 @@ post_nm(struct mdoc *mdoc)
if (mdoc->meta.name)
return(1);
- if ( ! xstrlcats(buf, mdoc->last->child, 64))
- return(mdoc_err(mdoc, "macro parameters too long"));
+ if (xstrlcats(buf, mdoc->last->child, 64)) {
+ mdoc->meta.name = xstrdup(buf);
+ return(1);
+ }
- mdoc->meta.name = xstrdup(buf);
- mdoc_msg(mdoc, "parsed name: %s", mdoc->meta.name);
- return(1);
+ return(mdoc_err(mdoc, "macro parameters too long"));
}
@@ -172,14 +175,14 @@ post_sh(struct mdoc *mdoc)
if (MDOC_HEAD != mdoc->last->type)
return(1);
- if ( ! xstrlcats(buf, mdoc->last->child, 64))
- return(mdoc_err(mdoc, "macro parameters too long"));
-
- if (SEC_CUSTOM != (sec = mdoc_atosec(buf)))
- mdoc->sec_lastn = sec;
- mdoc->sec_last = sec;
+ if (xstrlcats(buf, mdoc->last->child, 64)) {
+ if (SEC_CUSTOM != (sec = mdoc_atosec(buf)))
+ mdoc->sec_lastn = sec;
+ mdoc->sec_last = sec;
+ return(1);
+ }
- return(1);
+ return(mdoc_err(mdoc, "macro parameters too long"));
}
@@ -223,9 +226,6 @@ post_dt(struct mdoc *mdoc)
if (NULL == mdoc->meta.title)
mdoc->meta.title = xstrdup("untitled");
-
- mdoc_msg(mdoc, "parsed title: %s", mdoc->meta.title);
- /* TODO: print vol2a functions. */
return(1);
}
@@ -243,7 +243,6 @@ post_os(struct mdoc *mdoc)
return(mdoc_err(mdoc, "macro parameters too long"));
mdoc->meta.os = xstrdup(buf[0] ? buf : "local");
- mdoc_msg(mdoc, "parsed operating system: %s", mdoc->meta.os);
mdoc->sec_lastn = mdoc->sec_last = SEC_BODY;
return(1);
}
@@ -285,19 +284,12 @@ post_dd(struct mdoc *mdoc)
return(mdoc_nerr(mdoc, n, "invalid parameter syntax"));
}
- if (mdoc->meta.date && NULL == n) {
- mdoc_msg(mdoc, "parsed time: %u since epoch",
- mdoc->meta.date);
+ if (mdoc->meta.date && NULL == n)
return(1);
- } else if (n)
+ else if (n)
return(mdoc_err(mdoc, "invalid parameter syntax"));
-
- if ((mdoc->meta.date = mdoc_atotime(date))) {
- mdoc_msg(mdoc, "parsed time: %u since epoch",
- mdoc->meta.date);
+ if ((mdoc->meta.date = mdoc_atotime(date)))
return(1);
- }
-
return(mdoc_err(mdoc, "invalid parameter syntax"));
}