From: schwarze Date: Sun, 2 Jul 2017 21:17:12 +0000 (+0000) Subject: If a single page references the same non-existent manual more than X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bff2a0c301a2f68ac08618b63a82f0a27dcaf3f1;p=openbsd If a single page references the same non-existent manual more than once, print "(N times)" after the message "referenced manual not found", to lessen the risk that people fix the first instance and miss the others; jmc@ confirmed that this is useful. --- diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index ed40dff9fa9..20b6b1e4ccc 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.200 2017/07/02 15:31:48 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.201 2017/07/02 21:17:12 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze @@ -814,7 +814,11 @@ check_xr(const char *file) continue; if (fs_search(&search, &paths, 1, &xr->name, NULL, &sz)) continue; - mandoc_asprintf(&cp, "Xr %s %s", xr->name, xr->sec); + if (xr->count == 1) + mandoc_asprintf(&cp, "Xr %s %s", xr->name, xr->sec); + else + mandoc_asprintf(&cp, "Xr %s %s (%d times)", + xr->name, xr->sec, xr->count); mmsg(MANDOCERR_XR_BAD, MANDOCLEVEL_STYLE, file, xr->line, xr->pos + 1, cp); free(cp); diff --git a/usr.bin/mandoc/mandoc_xr.c b/usr.bin/mandoc/mandoc_xr.c index a8564693579..a4b2e905323 100644 --- a/usr.bin/mandoc/mandoc_xr.c +++ b/usr.bin/mandoc/mandoc_xr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc_xr.c,v 1.2 2017/07/02 15:31:48 schwarze Exp $ */ +/* $OpenBSD: mandoc_xr.c,v 1.3 2017/07/02 21:17:12 schwarze Exp $ */ /* * Copyright (c) 2017 Ingo Schwarze * @@ -81,6 +81,7 @@ mandoc_xr_add(const char *sec, const char *name, int line, int pos) xr->name = xr->hashkey + ssz; xr->line = line; xr->pos = pos; + xr->count = 1; memcpy(xr->sec, sec, ssz); memcpy(xr->name, name, nsz); @@ -97,6 +98,7 @@ mandoc_xr_add(const char *sec, const char *name, int line, int pos) return 0; } + oxr->count++; ret = (oxr->line == -1) ^ (xr->line == -1); if (xr->line == -1) oxr->line = -1; diff --git a/usr.bin/mandoc/mandoc_xr.h b/usr.bin/mandoc/mandoc_xr.h index 4bd8abaf513..708f5021770 100644 --- a/usr.bin/mandoc/mandoc_xr.h +++ b/usr.bin/mandoc/mandoc_xr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc_xr.h,v 1.2 2017/07/02 15:31:48 schwarze Exp $ */ +/* $OpenBSD: mandoc_xr.h,v 1.3 2017/07/02 21:17:12 schwarze Exp $ */ /* * Copyright (c) 2017 Ingo Schwarze * @@ -21,6 +21,7 @@ struct mandoc_xr { char *name; int line; /* Or -1 for this page's own names. */ int pos; + int count; char hashkey[]; };