From b569fb3a78ad114031c38c25bfcbca862217ae64 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 9 Jan 2017 01:37:03 +0000 Subject: Warnings and errors that occur during mdoc_validate() or during man_validate() have to affect the mandoc(1) EXIT STATUS. Many thanks to (illumos developer) for reporting this regression. --- main.c | 5 +++-- mandoc.3 | 33 +++++++++++++++++++++++++++++---- mandoc.h | 3 ++- read.c | 9 ++++++++- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 30ef3d6f..0aa714bb 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ -/* $Id: main.c,v 1.277 2016/09/18 15:47:45 schwarze Exp $ */ +/* $Id: main.c,v 1.278 2017/01/09 01:37:03 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze + * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze * Copyright (c) 2010 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -781,6 +781,7 @@ parse(struct curparse *curp, int fd, const char *file) break; } } + mparse_updaterc(curp->mp, &rc); } static void diff --git a/mandoc.3 b/mandoc.3 index 18b5707c..6f7c3eb0 100644 --- a/mandoc.3 +++ b/mandoc.3 @@ -1,7 +1,7 @@ -.\" $Id: mandoc.3,v 1.37 2016/07/07 19:19:01 schwarze Exp $ +.\" $Id: mandoc.3,v 1.38 2017/01/09 01:37:03 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons -.\" Copyright (c) 2010-2016 Ingo Schwarze +.\" Copyright (c) 2010-2017 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 7 2016 $ +.Dd $Mdocdate: January 9 2017 $ .Dt MANDOC 3 .Os .Sh NAME @@ -34,7 +34,8 @@ .Nm mparse_reset , .Nm mparse_result , .Nm mparse_strerror , -.Nm mparse_strlevel +.Nm mparse_strlevel , +.Nm mparse_updaterc .Nd mandoc macro compiler library .Sh SYNOPSIS .In sys/types.h @@ -100,6 +101,11 @@ .Fo mparse_strlevel .Fa "enum mandoclevel" .Fc +.Ft void +.Fo mparse_updaterc +.Fa "struct mparse *parse" +.Fa "enum mandoclevel *rc" +.Fc .In roff.h .Ft void .Fo deroff @@ -181,6 +187,9 @@ or .Fn man_validate , respectively; .It +if information about the validity of the input is needed, fetch it with +.Fn mparse_updaterc ; +.It iterate over parse nodes with starting from the .Fa first member of the returned @@ -416,6 +425,22 @@ Declared in .In mandoc.h , implemented in .Pa read.c . +.It Fn mparse_updaterc +If the highest warning or error level that occurred during the current +.Fa parse +is higher than +.Pf * Fa rc , +update +.Pf * Fa rc +accordingly. +This is useful after calling +.Fn mdoc_validate +or +.Fn man_validate . +Declared in +.In mandoc.h , +implemented in +.Pa read.c . .El .Ss Variables .Bl -ohang diff --git a/mandoc.h b/mandoc.h index 89458d39..2ea64ea0 100644 --- a/mandoc.h +++ b/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.212 2017/01/08 00:11:23 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.213 2017/01/09 01:37:03 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -435,3 +435,4 @@ void mparse_result(struct mparse *, const char *mparse_getkeep(const struct mparse *); const char *mparse_strerror(enum mandocerr); const char *mparse_strlevel(enum mandoclevel); +void mparse_updaterc(struct mparse *, enum mandoclevel *); diff --git a/read.c b/read.c index 54cc8530..d20a6098 100644 --- a/read.c +++ b/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.156 2017/01/08 00:11:24 schwarze Exp $ */ +/* $Id: read.c,v 1.157 2017/01/09 01:37:03 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -866,6 +866,13 @@ mparse_result(struct mparse *curp, struct roff_man **man, *man = curp->man; } +void +mparse_updaterc(struct mparse *curp, enum mandoclevel *rc) +{ + if (curp->file_status > *rc) + *rc = curp->file_status; +} + void mandoc_vmsg(enum mandocerr t, struct mparse *m, int ln, int pos, const char *fmt, ...) -- cgit v1.2.3