aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-07-07 09:35:40 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-07-07 09:35:40 +0000
commita8956f17f2df33668bc794d12afe580b5e0424d8 (patch)
tree0e1007362ebeba794d0378b05769152159f833b1
parent3860db271ca3940d6599dea0919eb1a74bcd725c (diff)
downloadmandoc-a8956f17f2df33668bc794d12afe580b5e0424d8.tar.gz
mandoc-a8956f17f2df33668bc794d12afe580b5e0424d8.tar.zst
mandoc-a8956f17f2df33668bc794d12afe580b5e0424d8.zip
Tabularised error strings in libman.
-rw-r--r--libman.h7
-rw-r--r--man.c52
2 files changed, 20 insertions, 39 deletions
diff --git a/libman.h b/libman.h
index 56c9b996..af72cd96 100644
--- a/libman.h
+++ b/libman.h
@@ -1,4 +1,4 @@
-/* $Id: libman.h,v 1.13 2009/07/06 13:04:52 kristaps Exp $ */
+/* $Id: libman.h,v 1.14 2009/07/07 09:35:40 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -39,7 +39,7 @@ struct man {
};
enum merr {
- WNPRINT,
+ WNPRINT = 0,
WNMEM,
WMSEC,
WDATE,
@@ -48,7 +48,8 @@ enum merr {
WTQUOTE,
WNODATA,
WNOTITLE,
- WESCAPE
+ WESCAPE,
+ WERRMAX
};
__BEGIN_DECLS
diff --git a/man.c b/man.c
index c20f1a43..c27ddaf8 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.26 2009/07/04 09:01:55 kristaps Exp $ */
+/* $Id: man.c,v 1.27 2009/07/07 09:35:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -23,6 +23,19 @@
#include "libman.h"
+const char *const __man_merrnames[WERRMAX] = {
+ "invalid character", /* WNPRINT */
+ "system: malloc error", /* WNMEM */
+ "invalid manual section", /* WMSEC */
+ "invalid date format", /* WDATE */
+ "scope of prior line violated", /* WLNSCOPE */
+ "trailing whitespace", /* WTSPACE */
+ "unterminated quoted parameter", /* WTQUOTE */
+ "document has no body", /* WNODATA */
+ "document has no title/section", /* WNOTITLE */
+ "invalid escape sequence", /* WESCAPE */
+};
+
const char *const __man_macronames[MAN_MAX] = {
"br", "TH", "SH", "SS",
"TP", "LP", "PP", "P",
@@ -438,44 +451,11 @@ man_vwarn(struct man *man, int ln, int pos, const char *fmt, ...)
int
-man_err(struct man *m, int line, int pos,
- int iserr, enum merr type)
+man_err(struct man *m, int line, int pos, int iserr, enum merr type)
{
const char *p;
- p = NULL;
- switch (type) {
- case (WNPRINT):
- p = "invalid character";
- break;
- case (WNMEM):
- p = "memory exhausted";
- break;
- case (WMSEC):
- p = "invalid manual section";
- break;
- case (WDATE):
- p = "invalid date format";
- break;
- case (WLNSCOPE):
- p = "scope of prior line violated";
- break;
- case (WTSPACE):
- p = "trailing whitespace at end of line";
- break;
- case (WTQUOTE):
- p = "unterminated quotation";
- break;
- case (WNODATA):
- p = "document has no data";
- break;
- case (WNOTITLE):
- p = "document has no title/section";
- break;
- case (WESCAPE):
- p = "invalid escape sequence";
- break;
- }
+ p = __man_merrnames[(int)type];
assert(p);
if (iserr)