-/* $Id: mdoc.c,v 1.213 2014/04/20 16:46:05 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.216 2014/07/01 22:37:15 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
#include "libmdoc.h"
#include "libmandoc.h"
-const char *const __mdoc_macronames[MDOC_MAX] = {
+const char *const __mdoc_macronames[MDOC_MAX + 1] = {
"Ap", "Dd", "Dt", "Os",
"Sh", "Ss", "Pp", "D1",
"Dl", "Bd", "Ed", "Bl",
"Lk", "Mt", "Brq", "Bro",
"Brc", "%C", "Es", "En",
"Dx", "%Q", "br", "sp",
- "%U", "Ta", "ll",
+ "%U", "Ta", "ll", "text",
};
const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
if (MDOC_PROLOGUE & mdoc_macros[tok].flags &&
MDOC_PBODY & mdoc->flags) {
- mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADBODY);
+ mandoc_vmsg(MANDOCERR_PROLOG_ONLY, mdoc->parse,
+ line, ppos, "%s", mdoc_macronames[tok]);
return(1);
}
if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) &&
! (MDOC_PBODY & mdoc->flags)) {
- mdoc_pmsg(mdoc, line, ppos, MANDOCERR_BADPROLOG);
+ mandoc_vmsg(MANDOCERR_PROLOG_BAD, mdoc->parse,
+ line, ppos, "%s", mdoc_macronames[tok]);
if (NULL == mdoc->meta.msec)
mdoc->meta.msec = mandoc_strdup("1");
if (NULL == mdoc->meta.title)
mac[i] = '\0';
- tok = (i > 1 || i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
+ tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : MDOC_MAX;
if (MDOC_MAX == tok) {
mandoc_vmsg(MANDOCERR_MACRO, mdoc->parse,