diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-07-06 19:08:58 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-07-06 19:08:58 +0000 |
commit | a9844262036e028323f7d11f70991b9a54447ec4 (patch) | |
tree | d20ae2fc8759280ad3aecc86197d981efcfff5ce /usr.bin/mandoc | |
parent | 656c11bd9c6a0d01822385b9ea5acafa9ba53171 (diff) |
Clean up messages related to plain text and to escape sequences.
* Mention invalid escape sequences and string names, and fallbacks.
* Hierarchical naming.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/eqn.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/man.c | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/man_validate.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 17 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 14 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_argv.c | 14 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 13 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 26 |
10 files changed, 65 insertions, 50 deletions
diff --git a/usr.bin/mandoc/eqn.c b/usr.bin/mandoc/eqn.c index 4226671384f..b0fc79790bc 100644 --- a/usr.bin/mandoc/eqn.c +++ b/usr.bin/mandoc/eqn.c @@ -1,4 +1,4 @@ -/* $Id: eqn.c,v 1.10 2014/07/04 16:11:41 schwarze Exp $ */ +/* $Id: eqn.c,v 1.11 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -764,7 +764,7 @@ again: ep->cur++; } else { if (q) - EQN_MSG(MANDOCERR_BADQUOTE, ep); + EQN_MSG(MANDOCERR_ARG_QUOTE, ep); next = strchr(start, '\0'); *sz = (size_t)(next - start); ep->cur += *sz; diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index e29d1ea03c6..ae94e373923 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.80 2014/05/07 14:11:24 schwarze Exp $ */ +/* $Id: man.c,v 1.81 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -443,7 +443,8 @@ man_ptext(struct man *man, int line, char *buf, int offs) if (' ' == buf[i - 1] || '\t' == buf[i - 1]) { if (i > 1 && '\\' != buf[i - 2]) - man_pmsg(man, line, i - 1, MANDOCERR_EOLNSPACE); + mandoc_msg(MANDOCERR_SPACE_EOL, man->parse, + line, i - 1, NULL); for (--i; i && ' ' == buf[i]; i--) /* Spin back to non-space. */ ; @@ -479,7 +480,8 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) struct man_node *n; if ('"' == buf[offs]) { - man_pmsg(man, ln, offs, MANDOCERR_BADCOMMENT); + mandoc_msg(MANDOCERR_COMMENT_BAD, man->parse, + ln, offs, NULL); return(1); } else if ('\0' == buf[offs]) return(1); @@ -517,7 +519,8 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) */ if ('\0' == buf[offs] && ' ' == buf[offs - 1]) - man_pmsg(man, ln, offs - 1, MANDOCERR_EOLNSPACE); + mandoc_msg(MANDOCERR_SPACE_EOL, man->parse, + ln, offs - 1, NULL); /* * Remove prior ELINE macro, as it's being clobbered by a new diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 4c2867c3354..bad90155585 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.70 2014/07/05 12:33:54 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.71 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -226,7 +226,8 @@ check_text(CHKARGS) cp = n->string; for (p = cp; NULL != (p = strchr(p, '\t')); p++) - man_pmsg(man, n->line, (int)(p - cp), MANDOCERR_BADTAB); + mandoc_msg(MANDOCERR_FI_TAB, man->parse, + n->line, n->pos + (p - cp), NULL); } #define INEQ_DEFINE(x, ineq, name) \ diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index 73e11c94b65..8c057d687a1 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.51 2014/07/06 18:36:49 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.52 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -425,7 +425,7 @@ mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos) /* Quoted argument without a closing quote. */ if (1 == quoted) - mandoc_msg(MANDOCERR_BADQUOTE, parse, ln, *pos, NULL); + mandoc_msg(MANDOCERR_ARG_QUOTE, parse, ln, *pos, NULL); /* NUL-terminate this argument and move to the next one. */ if (pairs) @@ -439,7 +439,7 @@ mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos) *cpp = cp; if ('\0' == *cp && (white || ' ' == cp[-1])) - mandoc_msg(MANDOCERR_EOLNSPACE, parse, ln, *pos, NULL); + mandoc_msg(MANDOCERR_SPACE_EOL, parse, ln, *pos, NULL); return(start); } diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index bad134ddc8c..e3d6b5fd544 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.80 2014/07/05 12:33:54 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.81 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -98,8 +98,9 @@ enum mandocerr { MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: macro font */ MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ - /* related to bad macro arguments */ + /* related to bad arguments */ MANDOCERR_IGNARGV, /* skipping argument */ + MANDOCERR_ARG_QUOTE, /* unterminated quoted argument */ MANDOCERR_ARG_REP, /* duplicate argument: macro arg */ MANDOCERR_BD_REP, /* skipping duplicate display type: type */ MANDOCERR_BL_REP, /* skipping duplicate list type: type */ @@ -108,12 +109,12 @@ enum mandocerr { MANDOCERR_FT_BAD, /* unknown font, skipping request: request font */ /* related to plain text */ - MANDOCERR_NOBLANKLN, /* blank line in non-literal context */ - MANDOCERR_BADTAB, /* tab in non-literal context */ - MANDOCERR_EOLNSPACE, /* end of line whitespace */ - MANDOCERR_BADCOMMENT, /* bad comment style */ - MANDOCERR_BADESCAPE, /* bad escape sequence */ - MANDOCERR_BADQUOTE, /* unterminated quoted string */ + MANDOCERR_FI_BLANK, /* blank line in fill mode, using .sp */ + MANDOCERR_FI_TAB, /* tab in filled text */ + MANDOCERR_SPACE_EOL, /* whitespace at end of input line */ + MANDOCERR_COMMENT_BAD, /* bad comment style */ + MANDOCERR_ESC_BAD, /* invalid escape sequence: esc */ + MANDOCERR_STR_UNDEF, /* undefined string, using "": name */ MANDOCERR_ERROR, /* ===== start of errors ===== */ diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 2203a693f96..d888f377236 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.107 2014/07/02 03:47:07 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.108 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -793,10 +793,12 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs) *end = '\0'; if (ws) - mdoc_pmsg(mdoc, line, (int)(ws-buf), MANDOCERR_EOLNSPACE); + mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse, + line, (int)(ws-buf), NULL); if ('\0' == buf[offs] && ! (MDOC_LITERAL & mdoc->flags)) { - mdoc_pmsg(mdoc, line, (int)(c-buf), MANDOCERR_NOBLANKLN); + mandoc_msg(MANDOCERR_FI_BLANK, mdoc->parse, + line, (int)(c - buf), NULL); /* * Insert a `sp' in the case of a blank line. Technically, @@ -846,7 +848,8 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) /* Empty post-control lines are ignored. */ if ('"' == buf[offs]) { - mdoc_pmsg(mdoc, ln, offs, MANDOCERR_BADCOMMENT); + mandoc_msg(MANDOCERR_COMMENT_BAD, mdoc->parse, + ln, offs, NULL); return(1); } else if ('\0' == buf[offs]) return(1); @@ -889,7 +892,8 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) */ if ('\0' == buf[offs] && ' ' == buf[offs - 1]) - mdoc_pmsg(mdoc, ln, offs - 1, MANDOCERR_EOLNSPACE); + mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse, + ln, offs - 1, NULL); /* * If an initial macro or a list invocation, divert directly diff --git a/usr.bin/mandoc/mdoc_argv.c b/usr.bin/mandoc/mdoc_argv.c index d33ac8a6539..60cf43e0cb3 100644 --- a/usr.bin/mandoc/mdoc_argv.c +++ b/usr.bin/mandoc/mdoc_argv.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_argv.c,v 1.51 2014/07/02 03:47:07 schwarze Exp $ */ +/* $Id: mdoc_argv.c,v 1.52 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -457,7 +457,8 @@ args(struct mdoc *mdoc, int line, int *pos, * is unterminated. */ if (MDOC_PHRASELIT & mdoc->flags) - mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE); + mandoc_msg(MANDOCERR_ARG_QUOTE, + mdoc->parse, line, *pos, NULL); mdoc->flags &= ~MDOC_PHRASELIT; return(ARGS_EOLN); @@ -516,7 +517,8 @@ args(struct mdoc *mdoc, int line, int *pos, /* Whitespace check for eoln case... */ if ('\0' == *p && ' ' == *(p - 1)) - mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE); + mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse, + line, *pos, NULL); *pos += (int)(p - *v); @@ -571,7 +573,8 @@ args(struct mdoc *mdoc, int line, int *pos, if ('\0' == buf[*pos]) { if (MDOC_PPHRASE & mdoc->flags) return(ARGS_QWORD); - mdoc_pmsg(mdoc, line, *pos, MANDOCERR_BADQUOTE); + mandoc_msg(MANDOCERR_ARG_QUOTE, + mdoc->parse, line, *pos, NULL); return(ARGS_QWORD); } @@ -585,7 +588,8 @@ args(struct mdoc *mdoc, int line, int *pos, (*pos)++; if ('\0' == buf[*pos]) - mdoc_pmsg(mdoc, line, *pos, MANDOCERR_EOLNSPACE); + mandoc_msg(MANDOCERR_SPACE_EOL, mdoc->parse, + line, *pos, NULL); return(ARGS_QWORD); } diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index f2c98fb0187..afdc1638126 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.146 2014/07/05 12:33:54 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.147 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -547,7 +547,8 @@ check_text(struct mdoc *mdoc, int ln, int pos, char *p) return; for (cp = p; NULL != (p = strchr(p, '\t')); p++) - mdoc_pmsg(mdoc, ln, pos + (int)(p - cp), MANDOCERR_BADTAB); + mandoc_msg(MANDOCERR_FI_TAB, mdoc->parse, + ln, pos + (int)(p - cp), NULL); } static int diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index b878966a834..da488a4661b 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.41 2014/07/05 12:33:54 schwarze Exp $ */ +/* $Id: read.c,v 1.42 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -136,6 +136,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { /* related to bad macro arguments */ "skipping argument", + "unterminated quoted argument", "duplicate argument", "skipping duplicate display type", "skipping duplicate list type", @@ -144,12 +145,12 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "unknown font, skipping request", /* related to plain text */ - "blank line in non-literal context", - "tab in non-literal context", - "end of line whitespace", + "blank line in fill mode, using .sp", + "tab in filled text", + "whitespace at end of input line", "bad comment style", - "bad escape sequence", - "unterminated quoted string", + "invalid escape sequence", + "undefined string, using \"\"", "generic error", diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 8f6e188250e..ceec0f7a274 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.91 2014/07/06 18:46:51 schwarze Exp $ */ +/* $Id: roff.c,v 1.92 2014/07/06 19:08:56 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -538,8 +538,9 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos) break; default: if (ESCAPE_ERROR == mandoc_escape(&cp, NULL, NULL)) - mandoc_msg(MANDOCERR_BADESCAPE, r->parse, - ln, (int)(stesc - *bufp), NULL); + mandoc_vmsg(MANDOCERR_ESC_BAD, + r->parse, ln, (int)(stesc - *bufp), + "%.*s", (int)(cp - stesc), stesc); continue; } @@ -584,8 +585,8 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos) arg_complete = 1; for (naml = 0; 0 == maxl || naml < maxl; naml++, cp++) { if ('\0' == *cp) { - mandoc_msg(MANDOCERR_BADESCAPE, r->parse, - ln, (int)(stesc - *bufp), NULL); + mandoc_msg(MANDOCERR_ESC_BAD, r->parse, + ln, (int)(stesc - *bufp), stesc); arg_complete = 0; break; } @@ -627,8 +628,9 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos) } if (NULL == res) { - mandoc_msg(MANDOCERR_BADESCAPE, r->parse, - ln, (int)(stesc - *bufp), NULL); + mandoc_vmsg(MANDOCERR_STR_UNDEF, + r->parse, ln, (int)(stesc - *bufp), + "%.*s", (int)naml, stnam); res = ""; } @@ -1890,9 +1892,8 @@ roff_tr(ROFF_ARGS) if ('\\' == *first) { esc = mandoc_escape(&p, NULL, NULL); if (ESCAPE_ERROR == esc) { - mandoc_msg(MANDOCERR_BADESCAPE, - r->parse, ln, - (int)(p - *bufp), NULL); + mandoc_msg(MANDOCERR_ESC_BAD, r->parse, + ln, (int)(p - *bufp), first); return(ROFF_IGN); } fsz = (size_t)(p - first); @@ -1902,9 +1903,8 @@ roff_tr(ROFF_ARGS) if ('\\' == *second) { esc = mandoc_escape(&p, NULL, NULL); if (ESCAPE_ERROR == esc) { - mandoc_msg(MANDOCERR_BADESCAPE, - r->parse, ln, - (int)(p - *bufp), NULL); + mandoc_msg(MANDOCERR_ESC_BAD, r->parse, + ln, (int)(p - *bufp), second); return(ROFF_IGN); } ssz = (size_t)(p - second); |