From 3510deaa7145c250603c428001812dbacf4b2e18 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 29 Nov 2010 14:56:43 +0000 Subject: Move `Lb' handling from mdoc_action.c into mdoc_validate.c. --- mdoc_validate.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'mdoc_validate.c') 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 * @@ -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) -- cgit v1.2.3