diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-07-12 20:30:28 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-07-12 20:30:28 +0000 |
commit | 475001105e136851bef0c0389f449eb102901714 (patch) | |
tree | 0a16af1acf6f5fb2ab39f3e8bf213260bd92471b /usr.bin/mandoc/man.c | |
parent | a434aaccc80703d795f7b657854c13afc56100c5 (diff) |
sync to 1.7.23: unify the various "enum merr" into libman.h and libmdoc.h,
use it as a new argument to mdoc_err(), the same way as for for man_err(),
and use string tables instead of switch statements to select error messages
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r-- | usr.bin/mandoc/man.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index 5e0a1c4133c..a5cefdcb058 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.6 2009/07/07 00:54:46 schwarze Exp $ */ +/* $Id: man.c,v 1.7 2009/07/12 20:30:27 schwarze 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) |