-/* $Id: action.c,v 1.10 2009/01/17 16:15:27 kristaps Exp $ */
+/* $Id: action.c,v 1.12 2009/01/19 17:02:58 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
int (*post)(struct mdoc *);
};
+/* Per-macro action routines. */
static int post_sh(struct mdoc *);
static int post_os(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 */
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"));
}
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"));
}
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);
}
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);
}
assert(MDOC_TEXT == n->type);
p = n->data.text.string;
- if (xstrcmp(p, "$Mdocdate: January 17 2009 $")) {
+ if (xstrcmp(p, "$Mdocdate: January 19 2009 $")) {
mdoc->meta.date = time(NULL);
continue;
} else if (xstrcmp(p, "$")) {
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"));
}
mdoc_action_post(struct mdoc *mdoc)
{
+ if (MDOC_ACTED & mdoc->last->flags)
+ return(1);
+ mdoc->last->flags |= MDOC_ACTED;
+
if (MDOC_TEXT == mdoc->last->type)
return(1);
if (MDOC_ROOT == mdoc->last->type)