aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-11-29 14:56:43 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-11-29 14:56:43 +0000
commit3510deaa7145c250603c428001812dbacf4b2e18 (patch)
treec25d8acc69466fc80a094a6b34ad65117e693251 /mdoc_validate.c
parentb81f17883462f1019033c564159f0345761e3acb (diff)
downloadmandoc-3510deaa7145c250603c428001812dbacf4b2e18.tar.gz
mandoc-3510deaa7145c250603c428001812dbacf4b2e18.tar.zst
mandoc-3510deaa7145c250603c428001812dbacf4b2e18.zip
Move `Lb' handling from mdoc_action.c into mdoc_validate.c.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index ee5ee77a..14d2834e 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.126 2010/11/29 14:50:33 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.127 2010/11/29 14:56:43 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -1077,16 +1077,37 @@ post_bf(POST_ARGS)
return(1);
}
-
static int
post_lb(POST_ARGS)
{
+ const char *p;
+ char *buf;
+ size_t sz;
+
+ assert(mdoc->last->child);
+ assert(MDOC_TEXT == mdoc->last->child->type);
+
+ p = mdoc_a2lib(mdoc->last->child->string);
- if (mdoc_a2lib(mdoc->last->child->string))
+ /* If lookup ok, replace with table value. */
+
+ if (p) {
+ free(mdoc->last->child->string);
+ mdoc->last->child->string = mandoc_strdup(p);
return(1);
- return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_BADLIB));
-}
+ }
+ /* If not, use "library ``xxxx''. */
+
+ sz = strlen(mdoc->last->child->string) +
+ 2 + strlen("\\(lqlibrary\\(rq");
+ buf = mandoc_malloc(sz);
+ snprintf(buf, sz, "library \\(lq%s\\(rq",
+ mdoc->last->child->string);
+ free(mdoc->last->child->string);
+ mdoc->last->child->string = buf;
+ return(1);
+}
static int
post_eoln(POST_ARGS)