Added warning against bogus `Lb' (like groff does).
Added proper quotes around `Lb' in mdoc_term.c.
Moved mdoc_a2lib -> libmdoc (where it belongs).
-/* $Id: libmdoc.h,v 1.17 2009/07/12 20:30:35 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.18 2009/07/12 20:50:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
EQUOTPHR,
ENOCTX,
ESPACE,
+ ELIB,
MERRMAX
};
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 *);
-/* $Id: mdoc.c,v 1.89 2009/07/07 09:29:15 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.90 2009/07/12 20:50:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
"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] = {
-/* $Id: mdoc.h,v 1.64 2009/07/12 20:30:35 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.65 2009/07/12 20:50:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
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*/
-/* $Id: mdoc_action.c,v 1.26 2009/07/12 20:30:35 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.27 2009/07/12 20:50:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
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);
{ 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 */
}
+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)
{
-/* $Id: mdoc_term.c,v 1.36 2009/07/12 20:30:35 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.37 2009/07/12 20:50:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
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);
{ 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 */
}
-/* 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)
-/* $Id: mdoc_validate.c,v 1.30 2009/07/12 20:30:35 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.31 2009/07/12 20:50:08 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
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);
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);
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 };
}
+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)
{