summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-02 12:54:33 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-02 12:54:33 +0000
commit93a6626101a75d16172b09ad5201078daf1c61b3 (patch)
tree85382023409b33ff7c59b10f3eb8e2545165ef84 /mdoc_validate.c
parent966c1bc6fc8cf98168d9d17b82cc2e7b414d2e15 (diff)
downloadmandoc-93a6626101a75d16172b09ad5201078daf1c61b3.tar.gz
mandoc-93a6626101a75d16172b09ad5201078daf1c61b3.tar.zst
mandoc-93a6626101a75d16172b09ad5201078daf1c61b3.zip
Stash `Bf' parameters into struct mdoc_bf.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c80
1 files changed, 57 insertions, 23 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index d9de3f9f..6e839e78 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.104 2010/07/01 22:56:17 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.105 2010/07/02 12:54:33 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -931,38 +931,72 @@ pre_dd(PRE_ARGS)
static int
post_bf(POST_ARGS)
{
- char *p;
- struct mdoc_node *head;
+ struct mdoc_node *np;
+ int arg;
- if (MDOC_BLOCK != mdoc->last->type)
- return(1);
+ /*
+ * Unlike other data pointers, these are "housed" by the HEAD
+ * element, which contains the goods.
+ */
- head = mdoc->last->head;
+ if (MDOC_HEAD != mdoc->last->type) {
+ if (ENDBODY_NOT != mdoc->last->end) {
+ assert(mdoc->last->pending);
+ np = mdoc->last->pending->parent->head;
+ } else if (MDOC_BLOCK != mdoc->last->type) {
+ np = mdoc->last->parent->head;
+ } else
+ np = mdoc->last->head;
- if (mdoc->last->args && head->child) {
- /* FIXME: this should provide a default. */
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SYNTARGVCOUNT);
- return(0);
- } else if (mdoc->last->args)
+ assert(np);
+ assert(MDOC_HEAD == np->type);
+ assert(MDOC_Bf == np->tok);
+ assert(np->data.Bf);
+ mdoc->last->data.Bf = np->data.Bf;
return(1);
+ }
+
+ np = mdoc->last;
+ np->data.Bf = mandoc_calloc(1, sizeof(struct mdoc_bf));
+
+ /*
+ * Cannot have both argument and parameter.
+ * If neither is specified, let it through with a warning.
+ */
- if (NULL == head->child || MDOC_TEXT != head->child->type) {
- /* FIXME: this should provide a default. */
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_SYNTARGVCOUNT);
+ if (np->args && np->child) {
+ mdoc_nmsg(mdoc, np, MANDOCERR_SYNTARGVCOUNT);
return(0);
+ } else if (NULL == np->args && NULL == np->child)
+ return(mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE));
+
+ /* Extract argument into data. */
+
+ if (np->args) {
+ arg = np->args->argv[0].arg;
+ if (MDOC_Emphasis == arg)
+ np->data.Bf->font = FONT_Em;
+ else if (MDOC_Literal == arg)
+ np->data.Bf->font = FONT_Li;
+ else if (MDOC_Symbolic == arg)
+ np->data.Bf->font = FONT_Sy;
+ else
+ abort();
+ return(1);
}
- p = head->child->string;
+ /* Extract parameter into data. */
- if (0 == strcmp(p, "Em"))
- return(1);
- else if (0 == strcmp(p, "Li"))
- return(1);
- else if (0 == strcmp(p, "Sy"))
- return(1);
+ if (0 == strcmp(np->child->string, "Em"))
+ np->data.Bf->font = FONT_Em;
+ else if (0 == strcmp(np->child->string, "Li"))
+ np->data.Bf->font = FONT_Li;
+ else if (0 == strcmp(np->child->string, "Sy"))
+ np->data.Bf->font = FONT_Sy;
+ else if ( ! mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE))
+ return(0);
- mdoc_nmsg(mdoc, head, MANDOCERR_FONTTYPE);
- return(0);
+ return(1);
}