summaryrefslogtreecommitdiffstats
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
commit4b6281d011b796bb8e659d02bba89300b58df31b (patch)
treefafac8f1cf47b47398058124fd3cd38c89a51f09
parentb29fdc329252f18b7e126d0b5bca94e997f64de5 (diff)
downloadmandoc-4b6281d011b796bb8e659d02bba89300b58df31b.tar.gz
Tabularised error strings in libman.
-rw-r--r--libman.h5
-rw-r--r--man.c50
2 files changed, 18 insertions, 37 deletions
diff --git a/libman.h b/libman.h
index 5bbf39b1..be8e4369 100644
--- a/libman.h
+++ b/libman.h
@@ -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 b3f103c7..e9bb7a56 100644
--- a/man.c
+++ b/man.c
@@ -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)