summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmdoc.h2
-rw-r--r--mdoc.c1
-rw-r--r--mdoc.h2
-rw-r--r--mdoc_action.c33
-rw-r--r--mdoc_term.c20
-rw-r--r--mdoc_validate.c14
6 files changed, 49 insertions, 23 deletions
diff --git a/libmdoc.h b/libmdoc.h
index 55f018da..1b3efc27 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -97,6 +97,7 @@ enum merr {
EQUOTPHR,
ENOCTX,
ESPACE,
+ ELIB,
MERRMAX
};
@@ -154,6 +155,7 @@ time_t mdoc_atotime(const char *);
size_t mdoc_macro2len(int);
const char *mdoc_a2att(const char *);
+const char *mdoc_a2lib(const char *);
const char *mdoc_a2st(const char *);
const char *mdoc_a2arch(const char *);
const char *mdoc_a2vol(const char *);
diff --git a/mdoc.c b/mdoc.c
index 42141d63..74c5262d 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -79,6 +79,7 @@ const char *const __mdoc_merrnames[MERRMAX] = {
"unterminated quoted phrase", /* EQUOTPHR */
"closure macro without prior context", /* ENOCTX */
"invalid whitespace after control character", /* ESPACE */
+ "no description found for library" /* ELIB */
};
const char *const __mdoc_macronames[MDOC_MAX] = {
diff --git a/mdoc.h b/mdoc.h
index 38618648..ff005e97 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -295,8 +295,6 @@ const struct mdoc_node *mdoc_node(const struct mdoc *);
const struct mdoc_meta *mdoc_meta(const struct mdoc *);
int mdoc_endparse(struct mdoc *);
-const char *mdoc_a2lib(const char *);
-
__END_DECLS
#endif /*!MDOC_H*/
diff --git a/mdoc_action.c b/mdoc_action.c
index 3da58be7..b3e471fc 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -41,6 +41,7 @@ static int post_bl_width(POST_ARGS);
static int post_dd(POST_ARGS);
static int post_display(POST_ARGS);
static int post_dt(POST_ARGS);
+static int post_lb(POST_ARGS);
static int post_lk(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_os(POST_ARGS);
@@ -159,7 +160,7 @@ const struct actions mdoc_actions[MDOC_MAX] = {
{ NULL, NULL }, /* Hf */
{ NULL, NULL }, /* Fr */
{ NULL, NULL }, /* Ud */
- { NULL, NULL }, /* Lb */
+ { NULL, post_lb }, /* Lb */
{ NULL, NULL }, /* Lp */
{ NULL, post_lk }, /* Lk */
{ NULL, NULL }, /* Mt */
@@ -291,6 +292,36 @@ post_nm(POST_ARGS)
static int
+post_lb(POST_ARGS)
+{
+ const char *p;
+ char *buf;
+ size_t sz;
+
+ assert(MDOC_TEXT == m->last->child->type);
+ p = mdoc_a2lib(m->last->child->string);
+ if (NULL == p) {
+ sz = strlen(m->last->child->string) +
+ 2 + strlen("\\(lqlibrary\\(rq");
+ buf = malloc(sz);
+ if (NULL == buf)
+ return(mdoc_nerr(m, m->last, EMALLOC));
+ (void)snprintf(buf, sz, "library \\(lq%s\\(rq",
+ m->last->child->string);
+ free(m->last->child->string);
+ m->last->child->string = buf;
+ return(1);
+ }
+
+ free(m->last->child->string);
+ m->last->child->string = strdup(p);
+ if (NULL == m->last->child->string)
+ return(mdoc_nerr(m, m->last, EMALLOC));
+ return(1);
+}
+
+
+static int
post_st(POST_ARGS)
{
const char *p;
diff --git a/mdoc_term.c b/mdoc_term.c
index 1728400e..df2258c1 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -147,7 +147,6 @@ static int termp_ft_pre(DECL_ARGS);
static int termp_ic_pre(DECL_ARGS);
static int termp_in_pre(DECL_ARGS);
static int termp_it_pre(DECL_ARGS);
-static int termp_lb_pre(DECL_ARGS);
static int termp_lk_pre(DECL_ARGS);
static int termp_ms_pre(DECL_ARGS);
static int termp_mt_pre(DECL_ARGS);
@@ -281,7 +280,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ NULL, NULL }, /* Hf */
{ NULL, NULL }, /* Fr */
{ termp_ud_pre, NULL }, /* Ud */
- { termp_lb_pre, termp_lb_post }, /* Lb */
+ { NULL, termp_lb_post }, /* Lb */
{ termp_pp_pre, NULL }, /* Lp */
{ termp_lk_pre, NULL }, /* Lk */
{ termp_mt_pre, NULL }, /* Mt */
@@ -1284,23 +1283,6 @@ termp_bt_pre(DECL_ARGS)
/* ARGSUSED */
-static int
-termp_lb_pre(DECL_ARGS)
-{
- const char *lb;
-
- assert(node->child && MDOC_TEXT == node->child->type);
- lb = mdoc_a2lib(node->child->string);
- if (lb) {
- term_word(p, lb);
- return(0);
- }
- term_word(p, "library");
- return(1);
-}
-
-
-/* ARGSUSED */
static void
termp_lb_post(DECL_ARGS)
{
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 8ac9ba24..9202df65 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -90,6 +90,7 @@ static int berr_ge1(POST_ARGS);
static int hwarn_eq1(POST_ARGS);
static int ewarn_ge1(POST_ARGS);
static int ebool(POST_ARGS);
+
static int post_an(POST_ARGS);
static int post_args(POST_ARGS);
static int post_at(POST_ARGS);
@@ -97,6 +98,7 @@ static int post_bf(POST_ARGS);
static int post_bl(POST_ARGS);
static int post_bl_head(POST_ARGS);
static int post_it(POST_ARGS);
+static int post_lb(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_root(POST_ARGS);
static int post_sh(POST_ARGS);
@@ -133,7 +135,7 @@ static v_post posts_in[] = { eerr_eq1, NULL };
static v_post posts_ss[] = { herr_ge1, NULL };
static v_post posts_nd[] = { berr_ge1, NULL };
static v_post posts_pf[] = { eerr_eq1, NULL };
-static v_post posts_lb[] = { eerr_eq1, NULL };
+static v_post posts_lb[] = { eerr_eq1, post_lb, NULL };
static v_post posts_st[] = { eerr_eq1, post_st, NULL };
static v_post posts_pp[] = { ewarn_eq0, NULL };
static v_post posts_ex[] = { eerr_eq0, post_args, NULL };
@@ -875,6 +877,16 @@ post_bf(POST_ARGS)
static int
+post_lb(POST_ARGS)
+{
+
+ if (mdoc_a2lib(mdoc->last->child->string))
+ return(1);
+ return(mdoc_nwarn(mdoc, mdoc->last, ELIB));
+}
+
+
+static int
post_nm(POST_ARGS)
{