From a1567e8417f169edf6c71532dc11bfa763ac444b Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 20 Aug 2010 01:02:07 +0000 Subject: Implement a simple, consistent user interface for error handling. We now have sufficient practical experience to know what we want, so this is intended to be final: - provide -Wlevel (warning, error or fatal) to select what you care about - provide -Wstop to stop after parsing a file with warnings you care about - provide consistent exit status codes for those warnings you care about - fully document what warnings, errors and fatal errors mean - remove all other cruft from the user interface, less is more: - remove all -f knobs along with the whole -f option - remove the old -Werror because calling warnings "fatal" is silly - always finish parsing each file, unless fatal errors prevent that This commit also includes a couple of related simplifications behind the scenes regarding error handling. Feedback and OK kristaps@; Joerg Sonnenberger (NetBSD) and Sascha Wildner (DragonFly BSD) agree with the general direction. --- man.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'man.c') diff --git a/man.c b/man.c index d0e577a6..618aaf53 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.86 2010/08/08 14:51:32 schwarze Exp $ */ +/* $Id: man.c,v 1.87 2010/08/20 01:02:07 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -56,7 +56,6 @@ static int man_ptext(struct man *, int, char *, int); static int man_pmacro(struct man *, int, char *, int); static void man_free1(struct man *); static void man_alloc1(struct man *); -static int macrowarn(struct man *, int, const char *, int); const struct man_node * @@ -94,8 +93,7 @@ man_free(struct man *man) struct man * -man_alloc(struct regset *regs, void *data, - int pflags, mandocmsg msg) +man_alloc(struct regset *regs, void *data, mandocmsg msg) { struct man *p; @@ -103,7 +101,6 @@ man_alloc(struct regset *regs, void *data, man_hash_init(); p->data = data; - p->pflags = pflags; p->msg = msg; p->regs = regs; @@ -435,19 +432,6 @@ descope: } -static int -macrowarn(struct man *m, int ln, const char *buf, int offs) -{ - int rc; - - rc = man_vmsg(m, MANDOCERR_MACRO, ln, offs, - "unknown macro: %s%s", - buf, strlen(buf) > 3 ? "..." : ""); - - return(MAN_IGN_MACRO & m->pflags ? rc : 0); -} - - int man_pmacro(struct man *m, int ln, char *buf, int offs) { @@ -490,15 +474,11 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) mac[j++] = buf[i++]; mac[j] = '\0'; - if (j == 4 || j < 1) { - if ( ! macrowarn(m, ln, mac, ppos)) - goto err; - return(1); - } - - if (MAN_MAX == (tok = man_hash_find(mac))) { - if ( ! macrowarn(m, ln, mac, ppos)) - goto err; + tok = (j > 0 && j < 4) ? man_hash_find(mac) : MAN_MAX; + if (MAN_MAX == tok) { + man_vmsg(m, MANDOCERR_MACRO, ln, ppos, + "unknown macro: %s%s", + buf, strlen(buf) > 3 ? "..." : ""); return(1); } -- cgit v1.2.3